@@ -3560,23 +3560,43 @@ def test_modes(self):
3560
3560
arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
3561
3561
arc .add ('read_group_only' , mode = '?---r-----' )
3562
3562
arc .add ('no_bits' , mode = '?---------' )
3563
- arc .add ('dir/' , mode = '?---rwsrwt' , type = tarfile .DIRTYPE )
3563
+ arc .add ('dir/' , mode = '?---rwsrwt' )
3564
+
3565
+ # On some systems, setting the sticky bit is a no-op.
3566
+ # Check if that's the case.
3567
+ tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3568
+ with open (tmp_filename , 'w' ):
3569
+ pass
3570
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3571
+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3572
+ os .unlink (tmp_filename )
3573
+
3574
+ os .mkdir (tmp_filename )
3575
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3576
+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3577
+ os .rmdir (tmp_filename )
3564
3578
3565
3579
with self .check_context (arc .open (), 'fully_trusted' ):
3566
- self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3580
+ if have_sticky_files :
3581
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3582
+ else :
3583
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwx' )
3567
3584
self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
3568
3585
self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
3569
3586
self .expect_file ('read_group_only' , mode = '?---r-----' )
3570
3587
self .expect_file ('no_bits' , mode = '?---------' )
3571
- self .expect_file ('dir' , type = tarfile .DIRTYPE , mode = '?---rwsrwt' )
3588
+ if have_sticky_dirs :
3589
+ self .expect_file ('dir/' , mode = '?---rwsrwt' )
3590
+ else :
3591
+ self .expect_file ('dir/' , mode = '?---rwsrwx' )
3572
3592
3573
3593
with self .check_context (arc .open (), 'tar' ):
3574
3594
self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
3575
3595
self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
3576
3596
self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
3577
3597
self .expect_file ('read_group_only' , mode = '?---r-----' )
3578
3598
self .expect_file ('no_bits' , mode = '?---------' )
3579
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3599
+ self .expect_file ('dir/' , mode = '?---r-xr-x' )
3580
3600
3581
3601
with self .check_context (arc .open (), 'data' ):
3582
3602
normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3586,7 +3606,7 @@ def test_modes(self):
3586
3606
self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
3587
3607
self .expect_file ('read_group_only' , mode = '?rw-r-----' )
3588
3608
self .expect_file ('no_bits' , mode = '?rw-------' )
3589
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = normal_dir_mode )
3609
+ self .expect_file ('dir/' , mode = normal_dir_mode )
3590
3610
3591
3611
def test_pipe (self ):
3592
3612
# Test handling of a special file
0 commit comments