diff --git a/agent/testflinger_agent/tarfile_patch.py b/agent/testflinger_agent/tarfile_patch.py index 1cc3ad42..2abbad1d 100644 --- a/agent/testflinger_agent/tarfile_patch.py +++ b/agent/testflinger_agent/tarfile_patch.py @@ -258,6 +258,15 @@ def extractall( except ExtractError as e: self._handle_nonfatal_error(e) + def chmod(self, tarinfo, targetpath): + """Set file permissions of targetpath according to tarinfo.""" + if tarinfo.mode is None: + return + try: + os.chmod(targetpath, tarinfo.mode) + except OSError: + raise ExtractError("could not change mode") + # make sure `open` is available when this module is imported and it # returns a `TarFilePatched` object instead of a `TarFile` one