@@ -3635,23 +3635,43 @@ def test_modes(self):
36353635 arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
36363636 arc .add ('read_group_only' , mode = '?---r-----' )
36373637 arc .add ('no_bits' , mode = '?---------' )
3638- arc .add ('dir/' , mode = '?---rwsrwt' , type = tarfile .DIRTYPE )
3638+ arc .add ('dir/' , mode = '?---rwsrwt' )
3639+
3640+ # On some systems, setting the sticky bit is a no-op.
3641+ # Check if that's the case.
3642+ tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3643+ with open (tmp_filename , 'w' ):
3644+ pass
3645+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3646+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3647+ os .unlink (tmp_filename )
3648+
3649+ os .mkdir (tmp_filename )
3650+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3651+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3652+ os .rmdir (tmp_filename )
36393653
36403654 with self .check_context (arc .open (), 'fully_trusted' ):
3641- self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3655+ if have_sticky_files :
3656+ self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3657+ else :
3658+ self .expect_file ('all_bits' , mode = '?rwsrwsrwx' )
36423659 self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
36433660 self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
36443661 self .expect_file ('read_group_only' , mode = '?---r-----' )
36453662 self .expect_file ('no_bits' , mode = '?---------' )
3646- self .expect_file ('dir' , type = tarfile .DIRTYPE , mode = '?---rwsrwt' )
3663+ if have_sticky_dirs :
3664+ self .expect_file ('dir/' , mode = '?---rwsrwt' )
3665+ else :
3666+ self .expect_file ('dir/' , mode = '?---rwsrwx' )
36473667
36483668 with self .check_context (arc .open (), 'tar' ):
36493669 self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
36503670 self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
36513671 self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
36523672 self .expect_file ('read_group_only' , mode = '?---r-----' )
36533673 self .expect_file ('no_bits' , mode = '?---------' )
3654- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3674+ self .expect_file ('dir/' , mode = '?---r-xr-x' )
36553675
36563676 with self .check_context (arc .open (), 'data' ):
36573677 normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3661,7 +3681,7 @@ def test_modes(self):
36613681 self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
36623682 self .expect_file ('read_group_only' , mode = '?rw-r-----' )
36633683 self .expect_file ('no_bits' , mode = '?rw-------' )
3664- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = normal_dir_mode )
3684+ self .expect_file ('dir/' , mode = normal_dir_mode )
36653685
36663686 def test_pipe (self ):
36673687 # Test handling of a special file
0 commit comments