Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc1c1e5b

Browse files
authored
Merge branch 'main' into fix-issue-107689
2 parents9c3a723 +40e52c9 commitc1c1e5b

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

‎Lib/test/test_tarfile.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3808,34 +3808,43 @@ def test_modes(self):
38083808
arc.add('read_group_only',mode='?---r-----')
38093809
arc.add('no_bits',mode='?---------')
38103810
arc.add('dir/',mode='?---rwsrwt')
3811+
arc.add('dir_all_bits/',mode='?rwsrwsrwt')
38113812

3812-
# On some systems, setting the sticky bit is a no-op.
3813-
# Check if that's the case.
3813+
# On some systems, setting the uid, gid, and/or sticky bit is a no-ops.
3814+
# Check which bits we can set, so we can compare tarfile machinery to
3815+
# a simple chmod.
38143816
tmp_filename=os.path.join(TEMPDIR,"tmp.file")
38153817
withopen(tmp_filename,'w'):
38163818
pass
3817-
os.chmod(tmp_filename,os.stat(tmp_filename).st_mode|stat.S_ISVTX)
3818-
have_sticky_files= (os.stat(tmp_filename).st_mode&stat.S_ISVTX)
3819+
new_mode= (os.stat(tmp_filename).st_mode
3820+
|stat.S_ISVTX|stat.S_ISGID|stat.S_ISUID)
3821+
os.chmod(tmp_filename,new_mode)
3822+
got_mode=os.stat(tmp_filename).st_mode
3823+
_t_file='t'if (got_mode&stat.S_ISVTX)else'x'
3824+
_suid_file='s'if (got_mode&stat.S_ISUID)else'x'
3825+
_sgid_file='s'if (got_mode&stat.S_ISGID)else'x'
38193826
os.unlink(tmp_filename)
38203827

38213828
os.mkdir(tmp_filename)
3822-
os.chmod(tmp_filename,os.stat(tmp_filename).st_mode|stat.S_ISVTX)
3823-
have_sticky_dirs= (os.stat(tmp_filename).st_mode&stat.S_ISVTX)
3829+
new_mode= (os.stat(tmp_filename).st_mode
3830+
|stat.S_ISVTX|stat.S_ISGID|stat.S_ISUID)
3831+
os.chmod(tmp_filename,new_mode)
3832+
got_mode=os.stat(tmp_filename).st_mode
3833+
_t_dir='t'if (got_mode&stat.S_ISVTX)else'x'
3834+
_suid_dir='s'if (got_mode&stat.S_ISUID)else'x'
3835+
_sgid_dir='s'if (got_mode&stat.S_ISGID)else'x'
38243836
os.rmdir(tmp_filename)
38253837

38263838
withself.check_context(arc.open(),'fully_trusted'):
3827-
ifhave_sticky_files:
3828-
self.expect_file('all_bits',mode='?rwsrwsrwt')
3829-
else:
3830-
self.expect_file('all_bits',mode='?rwsrwsrwx')
3839+
self.expect_file('all_bits',
3840+
mode=f'?rw{_suid_file}rw{_sgid_file}rw{_t_file}')
38313841
self.expect_file('perm_bits',mode='?rwxrwxrwx')
38323842
self.expect_file('exec_group_other',mode='?rw-rwxrwx')
38333843
self.expect_file('read_group_only',mode='?---r-----')
38343844
self.expect_file('no_bits',mode='?---------')
3835-
ifhave_sticky_dirs:
3836-
self.expect_file('dir/',mode='?---rwsrwt')
3837-
else:
3838-
self.expect_file('dir/',mode='?---rwsrwx')
3845+
self.expect_file('dir/',mode=f'?---rw{_sgid_dir}rw{_t_dir}')
3846+
self.expect_file('dir_all_bits/',
3847+
mode=f'?rw{_suid_dir}rw{_sgid_dir}rw{_t_dir}')
38393848

38403849
withself.check_context(arc.open(),'tar'):
38413850
self.expect_file('all_bits',mode='?rwxr-xr-x')
@@ -3844,6 +3853,7 @@ def test_modes(self):
38443853
self.expect_file('read_group_only',mode='?---r-----')
38453854
self.expect_file('no_bits',mode='?---------')
38463855
self.expect_file('dir/',mode='?---r-xr-x')
3856+
self.expect_file('dir_all_bits/',mode='?rwxr-xr-x')
38473857

38483858
withself.check_context(arc.open(),'data'):
38493859
normal_dir_mode=stat.filemode(stat.S_IMODE(
@@ -3854,6 +3864,7 @@ def test_modes(self):
38543864
self.expect_file('read_group_only',mode='?rw-r-----')
38553865
self.expect_file('no_bits',mode='?rw-------')
38563866
self.expect_file('dir/',mode=normal_dir_mode)
3867+
self.expect_file('dir_all_bits/',mode=normal_dir_mode)
38573868

38583869
deftest_pipe(self):
38593870
# Test handling of a special file

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp