def make_private(path):
    """
    Make `path` accessible only by 'owner'.

    path: string
        Path to file or directory to be made private.

    .. note::

        On Windows this requires the pywin32 extension.

    """
    if sys.platform == 'win32':  #pragma no cover
        if not HAVE_PYWIN32:
            raise ImportError('No pywin32')

        # Find the SIDs for user and system.
        username = win32api.GetUserNameEx(win32con.NameSamCompatible)

        # Map Cygwin 'root' to 'Administrator'. Typically these are intended
        # to be identical, but /etc/passwd might configure them differently.
        if username.endswith('\\root'):
            username = username.replace('\\root', '\\Administrator')
        user, domain, type = win32security.LookupAccountName('', username)
        system, domain, type = win32security.LookupAccountName('', 'System')

        # Find the DACL part of the Security Descriptor for the file
        sd = win32security.GetFileSecurity(path,
                                        win32security.DACL_SECURITY_INFORMATION)

        # Create a blank DACL and add the ACEs we want.
        dacl = win32security.ACL()
        dacl.AddAccessAllowedAce(win32security.ACL_REVISION,
                                 ntsecuritycon.FILE_ALL_ACCESS, user)
        dacl.AddAccessAllowedAce(win32security.ACL_REVISION, 
                                 ntsecuritycon.FILE_ALL_ACCESS, system)

        # Put our new DACL into the Security Descriptor and update the file
        # with the updated SD.
        sd.SetSecurityDescriptorDacl(1, dacl, 0)
        win32security.SetFileSecurity(path,
                                      win32security.DACL_SECURITY_INFORMATION,
                                      sd)
    else:
        # Normal chmod() works on test machines with ACLs enabled, but a user
        # in the field reported a situation where it didn't. This code tries
        # using libacl if it can. Doesn't seem to cause any problems, not
        # verifed that it helps though.
        try:
            # From pylibacl, which requires 'libacl1-dev'.
            import posix1e
        except __HOLE__:
            mode = 0700 if os.path.isdir(path) else 0600
            os.chmod(path, mode)  # Read/Write/Execute
        else:
            if os.path.isdir(path):
                acl = posix1e.ACL(text='u::rwx,g::-,o::-')
            else:
                acl = posix1e.ACL(text='u::rw,g::-,o::-')
            acl.applyto(path)

    if not is_private(path):
        raise RuntimeError("Can't make %r private" % path)
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.util/src/openmdao/util/publickey.py/make_private