mirror of
https://github.com/python/cpython.git
synced 2025-07-21 10:15:46 +00:00
gh-108948: Skip test_tarfile.test_modes() on EFTYPE error (#109697)
On FreeBSD, regular users cannot set the sticky bit. Skip the test if chmod() fails with EFTYPE error.
This commit is contained in:
parent
608c1f3083
commit
26e06ad617
1 changed files with 21 additions and 8 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import errno
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
|
@ -3823,14 +3824,26 @@ class TestExtractionFilters(unittest.TestCase):
|
||||||
tmp_filename = os.path.join(TEMPDIR, "tmp.file")
|
tmp_filename = os.path.join(TEMPDIR, "tmp.file")
|
||||||
with open(tmp_filename, 'w'):
|
with open(tmp_filename, 'w'):
|
||||||
pass
|
pass
|
||||||
new_mode = (os.stat(tmp_filename).st_mode
|
try:
|
||||||
| stat.S_ISVTX | stat.S_ISGID | stat.S_ISUID)
|
new_mode = (os.stat(tmp_filename).st_mode
|
||||||
os.chmod(tmp_filename, new_mode)
|
| stat.S_ISVTX | stat.S_ISGID | stat.S_ISUID)
|
||||||
got_mode = os.stat(tmp_filename).st_mode
|
try:
|
||||||
_t_file = 't' if (got_mode & stat.S_ISVTX) else 'x'
|
os.chmod(tmp_filename, new_mode)
|
||||||
_suid_file = 's' if (got_mode & stat.S_ISUID) else 'x'
|
except OSError as exc:
|
||||||
_sgid_file = 's' if (got_mode & stat.S_ISGID) else 'x'
|
if exc.errno == getattr(errno, "EFTYPE", 0):
|
||||||
os.unlink(tmp_filename)
|
# gh-108948: On FreeBSD, regular users cannot set
|
||||||
|
# the sticky bit.
|
||||||
|
self.skipTest("chmod() failed with EFTYPE: "
|
||||||
|
"regular users cannot set sticky bit")
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
||||||
|
got_mode = os.stat(tmp_filename).st_mode
|
||||||
|
_t_file = 't' if (got_mode & stat.S_ISVTX) else 'x'
|
||||||
|
_suid_file = 's' if (got_mode & stat.S_ISUID) else 'x'
|
||||||
|
_sgid_file = 's' if (got_mode & stat.S_ISGID) else 'x'
|
||||||
|
finally:
|
||||||
|
os.unlink(tmp_filename)
|
||||||
|
|
||||||
os.mkdir(tmp_filename)
|
os.mkdir(tmp_filename)
|
||||||
new_mode = (os.stat(tmp_filename).st_mode
|
new_mode = (os.stat(tmp_filename).st_mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue