@@ -3635,23 +3635,43 @@ def test_modes(self):
3635
3635
arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
3636
3636
arc .add ('read_group_only' , mode = '?---r-----' )
3637
3637
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 )
3639
3653
3640
3654
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' )
3642
3659
self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
3643
3660
self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
3644
3661
self .expect_file ('read_group_only' , mode = '?---r-----' )
3645
3662
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' )
3647
3667
3648
3668
with self .check_context (arc .open (), 'tar' ):
3649
3669
self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
3650
3670
self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
3651
3671
self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
3652
3672
self .expect_file ('read_group_only' , mode = '?---r-----' )
3653
3673
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' )
3655
3675
3656
3676
with self .check_context (arc .open (), 'data' ):
3657
3677
normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3661,7 +3681,7 @@ def test_modes(self):
3661
3681
self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
3662
3682
self .expect_file ('read_group_only' , mode = '?rw-r-----' )
3663
3683
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 )
3665
3685
3666
3686
def test_pipe (self ):
3667
3687
# Test handling of a special file
0 commit comments