@@ -3260,23 +3260,43 @@ def test_modes(self):
32603260 arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
32613261 arc .add ('read_group_only' , mode = '?---r-----' )
32623262 arc .add ('no_bits' , mode = '?---------' )
3263- arc .add ('dir/' , mode = '?---rwsrwt' , type = tarfile .DIRTYPE )
3263+ arc .add ('dir/' , mode = '?---rwsrwt' )
3264+
3265+ # On some systems, setting the sticky bit is a no-op.
3266+ # Check if that's the case.
3267+ tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3268+ with open (tmp_filename , 'w' ):
3269+ pass
3270+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3271+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3272+ os .unlink (tmp_filename )
3273+
3274+ os .mkdir (tmp_filename )
3275+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3276+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3277+ os .rmdir (tmp_filename )
32643278
32653279 with self .check_context (arc .open (), 'fully_trusted' ):
3266- self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3280+ if have_sticky_files :
3281+ self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3282+ else :
3283+ self .expect_file ('all_bits' , mode = '?rwsrwsrwx' )
32673284 self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
32683285 self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
32693286 self .expect_file ('read_group_only' , mode = '?---r-----' )
32703287 self .expect_file ('no_bits' , mode = '?---------' )
3271- self .expect_file ('dir' , type = tarfile .DIRTYPE , mode = '?---rwsrwt' )
3288+ if have_sticky_dirs :
3289+ self .expect_file ('dir/' , mode = '?---rwsrwt' )
3290+ else :
3291+ self .expect_file ('dir/' , mode = '?---rwsrwx' )
32723292
32733293 with self .check_context (arc .open (), 'tar' ):
32743294 self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
32753295 self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
32763296 self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
32773297 self .expect_file ('read_group_only' , mode = '?---r-----' )
32783298 self .expect_file ('no_bits' , mode = '?---------' )
3279- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3299+ self .expect_file ('dir/' , mode = '?---r-xr-x' )
32803300
32813301 with self .check_context (arc .open (), 'data' ):
32823302 normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3286,7 +3306,7 @@ def test_modes(self):
32863306 self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
32873307 self .expect_file ('read_group_only' , mode = '?rw-r-----' )
32883308 self .expect_file ('no_bits' , mode = '?rw-------' )
3289- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = normal_dir_mode )
3309+ self .expect_file ('dir/' , mode = normal_dir_mode )
32903310
32913311 def test_pipe (self ):
32923312 # Test handling of a special file
0 commit comments