Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit da07840

Browse filesBrowse files
committed
pythongh-102950: Adjust tarfile filter tests for systems that don't set the sticky bit (pythonGH-103831)
Also remove expilcit `type=tarfile.DIRTYPE`, the slash at the end is enough. Backport of c8c3956
1 parent 0669095 commit da07840
Copy full SHA for da07840

File tree

1 file changed

+25
-5
lines changed
Filter options

1 file changed

+25
-5
lines changed

‎Lib/test/test_tarfile.py

Copy file name to clipboardExpand all lines: Lib/test/test_tarfile.py
+25-5Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3473,23 +3473,43 @@ def test_modes(self):
34733473
arc.add('exec_group_other', mode='?rw-rwxrwx')
34743474
arc.add('read_group_only', mode='?---r-----')
34753475
arc.add('no_bits', mode='?---------')
3476-
arc.add('dir/', mode='?---rwsrwt', type=tarfile.DIRTYPE)
3476+
arc.add('dir/', mode='?---rwsrwt')
3477+
3478+
# On some systems, setting the sticky bit is a no-op.
3479+
# Check if that's the case.
3480+
tmp_filename = os.path.join(TEMPDIR, "tmp.file")
3481+
with open(tmp_filename, 'w'):
3482+
pass
3483+
os.chmod(tmp_filename, os.stat(tmp_filename).st_mode | stat.S_ISVTX)
3484+
have_sticky_files = (os.stat(tmp_filename).st_mode & stat.S_ISVTX)
3485+
os.unlink(tmp_filename)
3486+
3487+
os.mkdir(tmp_filename)
3488+
os.chmod(tmp_filename, os.stat(tmp_filename).st_mode | stat.S_ISVTX)
3489+
have_sticky_dirs = (os.stat(tmp_filename).st_mode & stat.S_ISVTX)
3490+
os.rmdir(tmp_filename)
34773491

34783492
with self.check_context(arc.open(), 'fully_trusted'):
3479-
self.expect_file('all_bits', mode='?rwsrwsrwt')
3493+
if have_sticky_files:
3494+
self.expect_file('all_bits', mode='?rwsrwsrwt')
3495+
else:
3496+
self.expect_file('all_bits', mode='?rwsrwsrwx')
34803497
self.expect_file('perm_bits', mode='?rwxrwxrwx')
34813498
self.expect_file('exec_group_other', mode='?rw-rwxrwx')
34823499
self.expect_file('read_group_only', mode='?---r-----')
34833500
self.expect_file('no_bits', mode='?---------')
3484-
self.expect_file('dir', type=tarfile.DIRTYPE, mode='?---rwsrwt')
3501+
if have_sticky_dirs:
3502+
self.expect_file('dir/', mode='?---rwsrwt')
3503+
else:
3504+
self.expect_file('dir/', mode='?---rwsrwx')
34853505

34863506
with self.check_context(arc.open(), 'tar'):
34873507
self.expect_file('all_bits', mode='?rwxr-xr-x')
34883508
self.expect_file('perm_bits', mode='?rwxr-xr-x')
34893509
self.expect_file('exec_group_other', mode='?rw-r-xr-x')
34903510
self.expect_file('read_group_only', mode='?---r-----')
34913511
self.expect_file('no_bits', mode='?---------')
3492-
self.expect_file('dir/', type=tarfile.DIRTYPE, mode='?---r-xr-x')
3512+
self.expect_file('dir/', mode='?---r-xr-x')
34933513

34943514
with self.check_context(arc.open(), 'data'):
34953515
normal_dir_mode = stat.filemode(stat.S_IMODE(
@@ -3499,7 +3519,7 @@ def test_modes(self):
34993519
self.expect_file('exec_group_other', mode='?rw-r--r--')
35003520
self.expect_file('read_group_only', mode='?rw-r-----')
35013521
self.expect_file('no_bits', mode='?rw-------')
3502-
self.expect_file('dir/', type=tarfile.DIRTYPE, mode=normal_dir_mode)
3522+
self.expect_file('dir/', mode=normal_dir_mode)
35033523

35043524
def test_pipe(self):
35053525
# Test handling of a special file

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.