@@ -3513,23 +3513,43 @@ def test_modes(self):
3513
3513
arc .add ('exec_group_other' ,mode = '?rw-rwxrwx' )
3514
3514
arc .add ('read_group_only' ,mode = '?---r-----' )
3515
3515
arc .add ('no_bits' ,mode = '?---------' )
3516
- arc .add ('dir/' ,mode = '?---rwsrwt' ,type = tarfile .DIRTYPE )
3516
+ arc .add ('dir/' ,mode = '?---rwsrwt' )
3517
+
3518
+ # On some systems, setting the sticky bit is a no-op.
3519
+ # Check if that's the case.
3520
+ tmp_filename = os .path .join (TEMPDIR ,"tmp.file" )
3521
+ with open (tmp_filename ,'w' ):
3522
+ pass
3523
+ os .chmod (tmp_filename ,os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3524
+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3525
+ os .unlink (tmp_filename )
3526
+
3527
+ os .mkdir (tmp_filename )
3528
+ os .chmod (tmp_filename ,os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3529
+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3530
+ os .rmdir (tmp_filename )
3517
3531
3518
3532
with self .check_context (arc .open (),'fully_trusted' ):
3519
- self .expect_file ('all_bits' ,mode = '?rwsrwsrwt' )
3533
+ if have_sticky_files :
3534
+ self .expect_file ('all_bits' ,mode = '?rwsrwsrwt' )
3535
+ else :
3536
+ self .expect_file ('all_bits' ,mode = '?rwsrwsrwx' )
3520
3537
self .expect_file ('perm_bits' ,mode = '?rwxrwxrwx' )
3521
3538
self .expect_file ('exec_group_other' ,mode = '?rw-rwxrwx' )
3522
3539
self .expect_file ('read_group_only' ,mode = '?---r-----' )
3523
3540
self .expect_file ('no_bits' ,mode = '?---------' )
3524
- self .expect_file ('dir' ,type = tarfile .DIRTYPE ,mode = '?---rwsrwt' )
3541
+ if have_sticky_dirs :
3542
+ self .expect_file ('dir/' ,mode = '?---rwsrwt' )
3543
+ else :
3544
+ self .expect_file ('dir/' ,mode = '?---rwsrwx' )
3525
3545
3526
3546
with self .check_context (arc .open (),'tar' ):
3527
3547
self .expect_file ('all_bits' ,mode = '?rwxr-xr-x' )
3528
3548
self .expect_file ('perm_bits' ,mode = '?rwxr-xr-x' )
3529
3549
self .expect_file ('exec_group_other' ,mode = '?rw-r-xr-x' )
3530
3550
self .expect_file ('read_group_only' ,mode = '?---r-----' )
3531
3551
self .expect_file ('no_bits' ,mode = '?---------' )
3532
- self .expect_file ('dir/' ,type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3552
+ self .expect_file ('dir/' ,mode = '?---r-xr-x' )
3533
3553
3534
3554
with self .check_context (arc .open (),'data' ):
3535
3555
normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3539,7 +3559,7 @@ def test_modes(self):
3539
3559
self .expect_file ('exec_group_other' ,mode = '?rw-r--r--' )
3540
3560
self .expect_file ('read_group_only' ,mode = '?rw-r-----' )
3541
3561
self .expect_file ('no_bits' ,mode = '?rw-------' )
3542
- self .expect_file ('dir/' ,type = tarfile . DIRTYPE , mode = normal_dir_mode )
3562
+ self .expect_file ('dir/' ,mode = normal_dir_mode )
3543
3563
3544
3564
def test_pipe (self ):
3545
3565
# Test handling of a special file