@@ -3635,23 +3635,43 @@ def test_modes(self):
36353635arc .add ('exec_group_other' ,mode = '?rw-rwxrwx' )
36363636arc .add ('read_group_only' ,mode = '?---r-----' )
36373637arc .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
36403654with 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' )
36423659self .expect_file ('perm_bits' ,mode = '?rwxrwxrwx' )
36433660self .expect_file ('exec_group_other' ,mode = '?rw-rwxrwx' )
36443661self .expect_file ('read_group_only' ,mode = '?---r-----' )
36453662self .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
36483668with self .check_context (arc .open (),'tar' ):
36493669self .expect_file ('all_bits' ,mode = '?rwxr-xr-x' )
36503670self .expect_file ('perm_bits' ,mode = '?rwxr-xr-x' )
36513671self .expect_file ('exec_group_other' ,mode = '?rw-r-xr-x' )
36523672self .expect_file ('read_group_only' ,mode = '?---r-----' )
36533673self .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
36563676with self .check_context (arc .open (),'data' ):
36573677normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3661,7 +3681,7 @@ def test_modes(self):
36613681self .expect_file ('exec_group_other' ,mode = '?rw-r--r--' )
36623682self .expect_file ('read_group_only' ,mode = '?rw-r-----' )
36633683self .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
36663686def test_pipe (self ):
36673687# Test handling of a special file