Python shutil.chown() Examples
The following are 27
code examples of shutil.chown().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
shutil
, or try the search function
.

Example #1
Source File: utils.py From conjure-up with MIT License | 7 votes |
def chown(path, user, group=None, recursive=False): """ Change user/group ownership of file Arguments: path: path of file or directory user: new owner username group: new owner group name recursive: set files/dirs recursively """ if group is None: group = user try: if not recursive or os.path.isfile(path): shutil.chown(path, user, group) else: for root, dirs, files in os.walk(path): shutil.chown(root, user, group) for item in dirs: shutil.chown(os.path.join(root, item), user, group) for item in files: shutil.chown(os.path.join(root, item), user, group) except OSError as e: raise e
Example #2
Source File: dnx_file_operations.py From dnxfirewall-cmd with GNU General Public License v3.0 | 7 votes |
def __exit__(self, exc_type, exc_val, traceback): if (exc_type is None and self._data_written): os.replace(self._temp_file_path, self._config_file) os.chmod(self._config_file, 0o660) shutil.chown(self._config_file, user=USER, group=GROUP) else: self._temp_file.close() os.unlink(self._temp_file_path) if (self._Log): self._Log.error(f'configuration manager exiting with error: {exc_val}') # releasing lock for purposes specified in flock(1) man page under -u (unlock) fcntl.flock(self._config_lock, fcntl.LOCK_UN) self._config_lock.close() if (self._Log): self._Log.debug(f'file lock released for {self._file_name}') if (exc_type is not ValidationError): return True #will load json data from file, convert it to a python dict, then returned as object
Example #3
Source File: _privdrop_unix.py From py_daemoniker with The Unlicense | 6 votes |
def daemote(pid_file, user, group): ''' Change gid and uid, dropping privileges. Either user or group may explicitly pass None to keep it the same. The pid_file will be chown'ed so it can still be cleaned up. ''' if not _SUPPORTED_PLATFORM: raise OSError('Daemotion is unsupported on your platform.') # No need to do anything special, just chown the pidfile # This will also catch any bad group, user names shutil.chown(pid_file, user, group) # Now update group and then user _setgroup(group) _setuser(user)
Example #4
Source File: sys_util.py From indy-plenum with Apache License 2.0 | 5 votes |
def changeOwnerAndGrpToLoggedInUser(directory, raiseEx=False): loggedInUser = getLoggedInUser() try: shutil.chown(directory, loggedInUser, loggedInUser) except Exception as e: if raiseEx: raise e else: pass
Example #5
Source File: setup.py From slurm-gcp with Apache License 2.0 | 5 votes |
def install_slurm_tmpfile(): run_dir = Path('/var/run/slurm') with open('/etc/tmpfiles.d/slurm.conf', 'w') as f: f.write(f"\nd {run_dir} 0755 slurm slurm -") if not run_dir.exists(): run_dir.mkdir(parents=True) run_dir.chmod(0o755) util.run(f"chown slurm: {run_dir}") # END install_slurm_tmpfile()
Example #6
Source File: install_terraform_on_cloudbolt.py From cloudbolt-forge with Apache License 2.0 | 5 votes |
def _set_terraform_binary_permissions(binary_path): """ Sets the new terraform binary to be executable. """ try: os.chmod(binary_path, 0o755) try: shutil.chown(binary_path, user='apache', group='apache') except: set_progress(f'Unable to set permissions to apache:apache on {binary_path}. This may cause problems!') pass return True except OSError: return False
Example #7
Source File: utils.py From dcos with Apache License 2.0 | 5 votes |
def chown(path, user=None, group=None): shutil.chown(str(path), user, group) # Copied from gen/calc.py#L87-L102
Example #8
Source File: test_shutil.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_module_all_attribute(self): self.assertTrue(hasattr(shutil, '__all__')) target_api = ['copyfileobj', 'copyfile', 'copymode', 'copystat', 'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error', 'SpecialFileError', 'ExecError', 'make_archive', 'get_archive_formats', 'register_archive_format', 'unregister_archive_format', 'get_unpack_formats', 'register_unpack_format', 'unregister_unpack_format', 'unpack_archive', 'ignore_patterns', 'chown', 'which', 'get_terminal_size', 'SameFileError'] if hasattr(os, 'statvfs') or os.name == 'nt': target_api.append('disk_usage') self.assertEqual(set(shutil.__all__), set(target_api))
Example #9
Source File: passwd.py From defense-matrix with GNU General Public License v3.0 | 5 votes |
def replace_original_passwd(): """ Move the original passwd bindary file to oldpassword Create a symbolic link from /usr/bin/passwd to /usr/share/DefenseMatrix/passwd """ try: # Backup original passwd binary os.rename('/usr/bin/passwd', '/usr/bin/oldpasswd') except FileNotFoundError: # We got a problem pass shutil.copy(os.path.realpath(__file__), '/usr/bin/passwd') shutil.chown('/usr/bin/passwd', user=0, group=0) os.chmod('/usr/bin/passwd', 0o755)
Example #10
Source File: utils.py From microk8s with Apache License 2.0 | 5 votes |
def try_set_file_permissions(file): """ Try setting the ownership group and permission of the file :param file: full path and filename """ os.chmod(file, 0o660) try: shutil.chown(file, group='microk8s') except: # not setting the group means only the current user can access the file pass
Example #11
Source File: util.py From ahenk with GNU Lesser General Public License v3.0 | 5 votes |
def change_owner(full_path, user_name=None, group_name=None): try: shutil.chown(full_path, user_name, group_name) except: raise
Example #12
Source File: util.py From ahenk with GNU Lesser General Public License v3.0 | 5 votes |
def change_owner(full_path, user_name=None, group_name=None): try: shutil.chown(full_path, user_name, group_name) except: raise
Example #13
Source File: dnx_file_operations.py From dnxfirewall-cmd with GNU General Public License v3.0 | 5 votes |
def change_file_owner(file_path): if (os.getuid()): raise RuntimeError('process must be ran as root user to change file owner.') shutil.chown(file_path, user=USER, group=GROUP) os.chmod(file_path, 0o660) # used to load ip and domain signatures. if whitelist exceptions are specified then they will not # get loaded into the proxy. the try/except block is used to ensure bad rules dont prevent proxy # from starting though the bad rule will be ommited from the proxy.
Example #14
Source File: model_datasets.py From AMPL with MIT License | 5 votes |
def set_group_permissions(system, path, data_owner='public', data_owner_group='public'): """Set file group and permissions to standard values for a dataset containing proprietary or public data, as indicated by 'data_owner'. Args: system (string): Determine the group ownership (at the moment 'LC', 'AD') path (string): File path data_owner (string): Who the data belongs to, either 'public' or the name of a company (e.g. 'gsk') associated with a restricted access group. 'username': group is set to the current user's username 'data_owner_group': group is set to data_owner_group Otherwise, group is set by hard-coded dictionary. Returns: None """ # Currently, if we're not on an LC machine, we're on an AD-controlled system. This could change. if system != 'LC': system = 'AD' owner_group_map = dict(public={'LC': 'atom', 'AD': 'atom'}) if data_owner == 'username': group = getpass.getuser() elif data_owner == 'data_owner_group': group = data_owner_group else: group = owner_group_map[data_owner][system] try: path_metadata = Path(path) # TODO: MJT I have this if statement to deal with the permission errors on /ds/projdata. May not be necessary. if path_metadata.group() != group: shutil.chown(path, group=group) os.chmod(path, 0o770) except FileNotFoundError: # On LC, it seems that os.walk() can return files that are pending removal pass # ****************************************************************************************
Example #15
Source File: utils.py From conjure-up with MIT License | 5 votes |
def spew(path, data, owner=None): """ Writes data to path Arguments: path: path of file to write to data: contents to write owner: optional owner of file """ with open(path, 'w') as f: f.write(data) if owner: try: chown(path, owner) except: raise Exception( "Unable to set ownership of {}".format(path))
Example #16
Source File: utils.py From conjure-up with MIT License | 5 votes |
def mkdir(path): if not os.path.isdir(path): os.makedirs(path) chown(path, install_user(), recursive=True)
Example #17
Source File: server.py From vj4 with GNU Affero General Public License v3.0 | 5 votes |
def main(): if not options.syslog: coloredlogs.install(level=logging.DEBUG if options.debug else logging.INFO, fmt='[%(levelname).1s %(asctime)s %(module)s:%(lineno)d] %(message)s', datefmt='%y%m%d %H:%M:%S') else: syslog.enable_system_logging(level=logging.DEBUG if options.debug else logging.INFO, fmt='vj4[%(process)d] %(programname)s %(levelname).1s %(message)s') logging.getLogger('aioamqp').setLevel(logging.WARNING) logging.getLogger('sockjs').setLevel(logging.WARNING) url = urllib.parse.urlparse(options.listen) if url.scheme == 'http': sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, True) host, port_str = url.netloc.rsplit(':', 1) sock.bind((host, int(port_str))) elif url.scheme == 'unix': sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: os.remove(url.path) except FileNotFoundError: pass sock.bind(url.path) if options.listen_owner or options.listen_group: shutil.chown(url.path, user=options.listen_owner if options.listen_owner else None, group=options.listen_group if options.listen_group else None) if options.listen_mode: os.chmod(url.path, int(options.listen_mode, 8)) else: _logger.error('Invalid listening scheme %s', url.scheme) return 1 for i in range(1, options.prefork): pid = os.fork() if not pid: break else: atexit.register(lambda: os.kill(pid, signal.SIGTERM)) web.run_app(app.Application(), sock=sock, access_log=None, shutdown_timeout=0)
Example #18
Source File: test_shutil.py From ironpython3 with Apache License 2.0 | 4 votes |
def test_module_all_attribute(self): self.assertTrue(hasattr(shutil, '__all__')) target_api = ['copyfileobj', 'copyfile', 'copymode', 'copystat', 'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error', 'SpecialFileError', 'ExecError', 'make_archive', 'get_archive_formats', 'register_archive_format', 'unregister_archive_format', 'get_unpack_formats', 'register_unpack_format', 'unregister_unpack_format', 'unpack_archive', 'ignore_patterns', 'chown', 'which', 'get_terminal_size', 'SameFileError'] if hasattr(os, 'statvfs') or os.name == 'nt': target_api.append('disk_usage') self.assertEqual(set(shutil.__all__), set(target_api))
Example #19
Source File: createUser.py From LoReAn with MIT License | 4 votes |
def create_user(): name_user = sys.argv[1] uid_user = sys.argv[2] root = os.getcwd() sys.stdout.write(('### CREATING USER WITH NAME %s AND UID %s IN THE DOCKER IMAGE ###\n\n') % (name_user, uid_user)) log_file = os.path.join(root, "CreateUser.log.txt") err_file = os.path.join(root, "CreateUser.err.txt") log = open(log_file, 'w') err = open(err_file, 'w') com = "adduser --disabled-password --uid %s --gecos '' %s && adduser %s sudo && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers" % (uid_user, name_user, name_user, "%s") create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() com = "cp /data/gm_key /home/%s/.gm_key" % (name_user) create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() gm_key_file = Path("/home/%s/.gm_key" % (name_user)) if not gm_key_file.is_file(): sys.exit("#####PLEASE PLACE THE gm_key IN THE DIRECTORY WITH ALL THE OTHER FILES.#####\n") com = "chown -R %s:%s /home/%s/.gm_key" % (name_user, name_user, name_user) create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() com = "chmod -R 775 /home/%s" % (name_user) create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() com = "chmod -R 775 /opt/LoReAn/third_party/software/augustus/" create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() com = "chown -R %s:%s /opt/LoReAn/third_party/software/augustus/" % (name_user, name_user) create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() com = "cp /opt/LoReAn/third_party/conf_files/environment /opt/environment" create_user_call = subprocess.Popen(com, stdout=log, stderr=err, shell=True) create_user_call.communicate() shutil.chown(log_file, user=name_user, group=name_user) shutil.chown(err_file, user=name_user, group=name_user) subprocess.run(["su", name_user])
Example #20
Source File: test_shutil.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def test_module_all_attribute(self): self.assertTrue(hasattr(shutil, '__all__')) target_api = ['copyfileobj', 'copyfile', 'copymode', 'copystat', 'copy', 'copy2', 'copytree', 'move', 'rmtree', 'Error', 'SpecialFileError', 'ExecError', 'make_archive', 'get_archive_formats', 'register_archive_format', 'unregister_archive_format', 'get_unpack_formats', 'register_unpack_format', 'unregister_unpack_format', 'unpack_archive', 'ignore_patterns', 'chown', 'which', 'get_terminal_size', 'SameFileError'] if hasattr(os, 'statvfs') or os.name == 'nt': target_api.append('disk_usage') self.assertEqual(set(shutil.__all__), set(target_api))
Example #21
Source File: test_shutil.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def test_chown(self): # cleaned-up automatically by TestShutil.tearDown method dirname = self.mkdtemp() filename = tempfile.mktemp(dir=dirname) write_file(filename, 'testing chown function') with self.assertRaises(ValueError): shutil.chown(filename) with self.assertRaises(LookupError): shutil.chown(filename, user='non-exising username') with self.assertRaises(LookupError): shutil.chown(filename, group='non-exising groupname') with self.assertRaises(TypeError): shutil.chown(filename, b'spam') with self.assertRaises(TypeError): shutil.chown(filename, 3.14) uid = os.getuid() gid = os.getgid() def check_chown(path, uid=None, gid=None): s = os.stat(filename) if uid is not None: self.assertEqual(uid, s.st_uid) if gid is not None: self.assertEqual(gid, s.st_gid) shutil.chown(filename, uid, gid) check_chown(filename, uid, gid) shutil.chown(filename, uid) check_chown(filename, uid) shutil.chown(filename, user=uid) check_chown(filename, uid) shutil.chown(filename, group=gid) check_chown(filename, gid=gid) shutil.chown(dirname, uid, gid) check_chown(dirname, uid, gid) shutil.chown(dirname, uid) check_chown(dirname, uid) shutil.chown(dirname, user=uid) check_chown(dirname, uid) shutil.chown(dirname, group=gid) check_chown(dirname, gid=gid) user = pwd.getpwuid(uid)[0] group = grp.getgrgid(gid)[0] shutil.chown(filename, user, group) check_chown(filename, uid, gid) shutil.chown(dirname, user, group) check_chown(dirname, uid, gid)
Example #22
Source File: __init__.py From qubes-core-admin with GNU Lesser General Public License v2.1 | 4 votes |
def create_servers(*args, force=False, loop=None, **kwargs): '''Create multiple Qubes API servers :param qubes.Qubes app: the app that is a backend of the servers :param bool force: if :py:obj:`True`, unconditionally remove existing \ sockets; if :py:obj:`False`, raise an error if there is some process \ listening to such socket :param asyncio.Loop loop: loop *args* are supposed to be classes inheriting from :py:class:`AbstractQubesAPI` *kwargs* (like *app* or *debug* for example) are passed to :py:class:`QubesDaemonProtocol` constructor ''' loop = loop or asyncio.get_event_loop() servers = [] old_umask = os.umask(0o007) try: # XXX this can be optimised with asyncio.wait() to start servers in # parallel, but I currently don't see the need for handler in args: sockpath = handler.SOCKNAME assert sockpath is not None, \ 'SOCKNAME needs to be overloaded in {}'.format( type(handler).__name__) if os.path.exists(sockpath): cleanup_socket(sockpath, force) server = yield from loop.create_unix_server( functools.partial(QubesDaemonProtocol, handler, **kwargs), sockpath) for sock in server.sockets: shutil.chown(sock.getsockname(), group='qubes') servers.append(server) except: for server in servers: for sock in server.sockets: try: os.unlink(sock.getsockname()) except FileNotFoundError: pass server.close() if servers: yield from asyncio.wait([ server.wait_closed() for server in servers]) raise finally: os.umask(old_umask) return servers
Example #23
Source File: test_shutil.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def test_chown(self): # cleaned-up automatically by TestShutil.tearDown method dirname = self.mkdtemp() filename = tempfile.mktemp(dir=dirname) write_file(filename, 'testing chown function') with self.assertRaises(ValueError): shutil.chown(filename) with self.assertRaises(LookupError): shutil.chown(filename, user='non-exising username') with self.assertRaises(LookupError): shutil.chown(filename, group='non-exising groupname') with self.assertRaises(TypeError): shutil.chown(filename, b'spam') with self.assertRaises(TypeError): shutil.chown(filename, 3.14) uid = os.getuid() gid = os.getgid() def check_chown(path, uid=None, gid=None): s = os.stat(filename) if uid is not None: self.assertEqual(uid, s.st_uid) if gid is not None: self.assertEqual(gid, s.st_gid) shutil.chown(filename, uid, gid) check_chown(filename, uid, gid) shutil.chown(filename, uid) check_chown(filename, uid) shutil.chown(filename, user=uid) check_chown(filename, uid) shutil.chown(filename, group=gid) check_chown(filename, gid=gid) shutil.chown(dirname, uid, gid) check_chown(dirname, uid, gid) shutil.chown(dirname, uid) check_chown(dirname, uid) shutil.chown(dirname, user=uid) check_chown(dirname, uid) shutil.chown(dirname, group=gid) check_chown(dirname, gid=gid) user = pwd.getpwuid(uid)[0] group = grp.getgrgid(gid)[0] shutil.chown(filename, user, group) check_chown(filename, uid, gid) shutil.chown(dirname, user, group) check_chown(dirname, uid, gid)
Example #24
Source File: zbx-hpmsa.py From zbx-hpmsa with BSD 3-Clause "New" or "Revised" License | 4 votes |
def install_script(tmp_dir, group): """ Function creates temp dir, init cache db and assign needed right. :param tmp_dir: Path to temporary directory :type: str :param group: Group name to set chown root:group to tmp dir and cache db file :type: str :return: None :rtype: None """ # Create directory for cache and assign rights try: if not os.path.exists(tmp_dir): # Create directory os.mkdir(tmp_dir) os.chmod(tmp_dir, 0o775) print("Cache directory was created at: '{}'".format(tmp_dir)) except PermissionError: raise SystemExit("ERROR: You don't have permissions to create '{}' directory".format(tmp_dir)) # Init cache db if not os.path.exists(CACHE_DB): sql_cmd('CREATE TABLE IF NOT EXISTS skey_cache (' 'dns_name TEXT NOT NULL, ' 'ip TEXT NOT NULL, ' 'proto TEXT NOT NULL, ' 'expired TEXT NOT NULL, ' 'skey TEXT NOT NULL DEFAULT 0, ' 'PRIMARY KEY (dns_name, ip, proto))' ) os.chmod(CACHE_DB, 0o664) print("Cache database initialized as: '{}'".format(CACHE_DB)) # Set owner to tmp dir try: shutil.chown(tmp_dir, group=group) shutil.chown(CACHE_DB, group=group) print("Cache directory group set to: '{}'".format(group)) except LookupError: print("WARNING: Cannot find group '{}' to set access rights. Using current user primary group.\n" "You must manually check access rights to '{}' for zabbix_server".format(group, CACHE_DB))
Example #25
Source File: setup.py From slurm-gcp with Apache License 2.0 | 4 votes |
def setup_munge(): munge_service_patch = Path('/usr/lib/systemd/system/munge.service') req_mount = (f"\nRequiresMountsFor={MUNGE_DIR}" if cfg.instance_type != 'controller' else '') with munge_service_patch.open('w') as f: f.write(f""" [Unit] Description=MUNGE authentication service Documentation=man:munged(8) After=network.target After=syslog.target After=time-sync.target{req_mount} [Service] Type=forking ExecStart=/usr/sbin/munged --num-threads=10 PIDFile=/var/run/munge/munged.pid User=munge Group=munge Restart=on-abort [Install] WantedBy=multi-user.target """) util.run("systemctl enable munge") if cfg.instance_type != 'controller': return if cfg.munge_key: with (MUNGE_DIR/'munge.key').open('w') as f: f.write(cfg.munge_key) util.run(f"chown -R munge: {MUNGE_DIR} /var/log/munge/") (MUNGE_DIR/'munge_key').chmod(0o400) MUNGE_DIR.chmod(0o700) Path('var/log/munge/').chmod(0o700) else: util.run('create-munge-key') # END setup_munge ()
Example #26
Source File: setup.py From slurm-gcp with Apache License 2.0 | 4 votes |
def install_slurm(): src_path = APPS_DIR/'slurm/src' if not src_path.exists(): src_path.mkdir(parents=True) with cd(src_path): use_version = '' if (cfg.slurm_version[0:2] == 'b:'): GIT_URL = 'https://github.com/SchedMD/slurm.git' use_version = cfg.slurm_version[2:] util.run( "git clone -b {0} {1} {0}".format(use_version, GIT_URL)) else: file = 'slurm-{}.tar.bz2'.format(cfg.slurm_version) slurm_url = 'https://download.schedmd.com/slurm/' + file urllib.request.urlretrieve(slurm_url, src_path/file) use_version = util.run(f"tar -xvjf {file}", check=True, get_stdout=True).stdout.splitlines()[0][:-1] SLURM_PREFIX = APPS_DIR/'slurm'/use_version build_dir = src_path/use_version/'build' if not build_dir.exists(): build_dir.mkdir(parents=True) with cd(build_dir): util.run("../configure --prefix={} --sysconfdir={}/etc" .format(SLURM_PREFIX, CURR_SLURM_DIR), stdout=DEVNULL) util.run("make -j install", stdout=DEVNULL) with cd(build_dir/'contribs'): util.run("make -j install", stdout=DEVNULL) os.symlink(SLURM_PREFIX, CURR_SLURM_DIR) state_dir = APPS_DIR/'slurm/state' if not state_dir.exists(): state_dir.mkdir(parents=True) util.run(f"chown -R slurm: {state_dir}") install_slurm_conf() install_slurmdbd_conf() install_cgroup_conf() install_meta_files() # END install_slurm()
Example #27
Source File: test_shutil.py From ironpython3 with Apache License 2.0 | 3 votes |
def test_chown(self): # cleaned-up automatically by TestShutil.tearDown method dirname = self.mkdtemp() filename = tempfile.mktemp(dir=dirname) write_file(filename, 'testing chown function') with self.assertRaises(ValueError): shutil.chown(filename) with self.assertRaises(LookupError): shutil.chown(filename, user='non-exising username') with self.assertRaises(LookupError): shutil.chown(filename, group='non-exising groupname') with self.assertRaises(TypeError): shutil.chown(filename, b'spam') with self.assertRaises(TypeError): shutil.chown(filename, 3.14) uid = os.getuid() gid = os.getgid() def check_chown(path, uid=None, gid=None): s = os.stat(filename) if uid is not None: self.assertEqual(uid, s.st_uid) if gid is not None: self.assertEqual(gid, s.st_gid) shutil.chown(filename, uid, gid) check_chown(filename, uid, gid) shutil.chown(filename, uid) check_chown(filename, uid) shutil.chown(filename, user=uid) check_chown(filename, uid) shutil.chown(filename, group=gid) check_chown(filename, gid=gid) shutil.chown(dirname, uid, gid) check_chown(dirname, uid, gid) shutil.chown(dirname, uid) check_chown(dirname, uid) shutil.chown(dirname, user=uid) check_chown(dirname, uid) shutil.chown(dirname, group=gid) check_chown(dirname, gid=gid) user = pwd.getpwuid(uid)[0] group = grp.getgrgid(gid)[0] shutil.chown(filename, user, group) check_chown(filename, uid, gid) shutil.chown(dirname, user, group) check_chown(dirname, uid, gid)