Skip to content

Commit

Permalink
[CERTTF-413] fix: include chmod method in the tarfile patch (#368)
Browse files Browse the repository at this point in the history
This allows for directories to be extracted. The filtered `mode`
for directories is `None` and the unpatched `chmod` is not
forgiving of that.
  • Loading branch information
boukeas authored Oct 3, 2024
1 parent 7e2e334 commit a634fc1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions agent/testflinger_agent/tarfile_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a634fc1

Please # to comment.