-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #30807 -- Fix permissions when extracting archives #11854
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,6 @@ def test_extract_function(self): | |
def test_extract_file_permissions(self): | ||
"""archive.extract() preserves file permissions.""" | ||
mask = stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO | ||
umask = os.umask(0) | ||
os.umask(umask) # Restore the original umask. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure what you expected here, but this was added to fetch the umask on the system the tests are being run on so that it could be applied below to avoid failures where systems have different umask configured. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand was the intention was, however it was only being applied for the test on the Having said that, looking at it again I see the umask does need to be applied when testing directory creation, where it currently isn't - agree? Again, appreciate the comments, sorry for having switched gears too fast being eager to start contributing :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pope1ni : If so, my suggestion would be to:
Would appreciate your input! :) |
||
for entry in os.scandir(self.testdir): | ||
if entry.name.startswith('leadpath_'): | ||
continue | ||
|
@@ -44,4 +42,4 @@ def test_extract_file_permissions(self): | |
self.assertEqual(os.stat(filepath).st_mode & mask, 0o775) | ||
# A file is readable even if permission data is missing. | ||
filepath = os.path.join(tmpdir, 'no_permissions') | ||
self.assertEqual(os.stat(filepath).st_mode & mask, 0o664 & ~umask) | ||
self.assertEqual(os.stat(filepath).st_mode & mask, 0o4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S_IROTH
is "other read", not "owner read".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Nick, thanks for the comment! Apologies for having switched gears too fast here.
Agree, that should have been
mode | stat.S_IRUSR
to ensure "read by owner".