-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-108948: tarfile should handle sticky bit in FreeBSD #108950
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
Changes from 1 commit
6a4be8f
50729f7
3587710
41491bb
4f6536d
fe7dfed
4009573
7b784b5
02d7c21
94efbbb
d1824c8
bd1dba7
417e31a
83c08fc
54f5548
b60ada6
5a51aab
cac6595
23a6fd5
060bcb2
5ae3e30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3061,6 +3061,8 @@ def test_keyword_only(self, mock_geteuid): | |||||
|
||||||
|
||||||
def can_chmod_set_sticky(): | ||||||
"""Can chmod set the sticky bit on a file?""" | ||||||
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. Please explain in the docstring that it returns False if chmod() doesn't fail but ignores the sticky bit. 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. Done. |
||||||
|
||||||
def can_chmod_set_sticky_inner(): | ||||||
< 8000 span class='blob-code-inner blob-code-marker ' data-code-marker=" "> if not os_helper.can_chmod(): | ||||||
return False | ||||||
|
@@ -3085,27 +3087,23 @@ def can_chmod_set_sticky_inner(): | |||||
|
||||||
@os_helper.skip_unless_working_chmod | ||||||
class FileModesTest(unittest.TestCase): | ||||||
@unittest.skipUnless(hasattr(errno, "EFTYPE"), "errno.EFTYPE required") | ||||||
@unittest.skipUnless(hasattr(errno, "EFTYPE"), "requires errno.EFTYPE") | ||||||
def test_extract_chmod_eftype(self): | ||||||
# Extracting a file as non-root should skip the sticky bit (gh-108948) | ||||||
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.
Suggested change
|
||||||
# even on platforms where chmod fails with EFTYPE (i.e. FreeBSD). But | ||||||
# we need to take care that any other error is preserved. | ||||||
mode = "-rwxrwxrwt" | ||||||
expected_mode = mode if can_chmod_set_sticky() else "-rwxrwxrwx" | ||||||
with ArchiveMaker() as arc: | ||||||
arc.add("sticky1", mode=mode) | ||||||
arc.add("sticky2", mode=mode) | ||||||
tar = arc.open(errorlevel=2) | ||||||
DIR = os.path.join(TEMPDIR, "chmod") | ||||||
os.mkdir(DIR) | ||||||
self.addCleanup(os_helper.rmtree, DIR) | ||||||
with tar: | ||||||
with arc.open(errorlevel=2) as tar: | ||||||
# this should not raise: | ||||||
tar.extract("sticky1", DIR, filter="fully_trusted") | ||||||
got_mode = stat.filemode(os.stat(os.path.join(DIR, "sticky1")).st_mode) | ||||||
if can_chmod_set_sticky(): | ||||||
expected_mode = "-rwxrwxrwt" | ||||||
else: | ||||||
expected_mode = "-rwxrwxrwx" | ||||||
self.assertEqual(got_mode, expected_mode) | ||||||
|
||||||
# but we can create a situation where it does raise: | ||||||
|
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.
You should move it to support.os_helper.
I suggest to rename to can_chmod_set_sticky_bit().
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.
Done.