@@ -3473,23 +3473,43 @@ def test_modes(self):
3473
3473
arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
3474
3474
arc .add ('read_group_only' , mode = '?---r-----' )
3475
3475
arc .add ('no_bits' , mode = '?---------' )
3476
- arc .add ('dir/' , mode = '?---rwsrwt' , type = tarfile .DIRTYPE )
3476
+ arc .add ('dir/' , mode = '?---rwsrwt' )
3477
+
3478
+ # On some systems, setting the sticky bit is a no-op.
3479
+ # Check if that's the case.
3480
+ tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3481
+ with open (tmp_filename , 'w' ):
3482
+ pass
3483
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3484
+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3485
+ os .unlink (tmp_filename )
3486
+
3487
+ os .mkdir (tmp_filename )
3488
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3489
+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3490
+ os .rmdir (tmp_filename )
3477
3491
3478
3492
with self .check_context (arc .open (), 'fully_trusted' ):
3479
- self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3493
+ if have_sticky_files :
3494
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3495
+ else :
3496
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwx' )
3480
3497
self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
3481
3498
self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
3482
3499
self .expect_file ('read_group_only' , mode = '?---r-----' )
3483
3500
self .expect_file ('no_bits' , mode = '?---------' )
3484
- self .expect_file ('dir' , type = tarfile .DIRTYPE , mode = '?---rwsrwt' )
3501
+ if have_sticky_dirs :
3502
+ self .expect_file ('dir/' , mode = '?---rwsrwt' )
3503
+ else :
3504
+ self .expect_file ('dir/' , mode = '?---rwsrwx' )
3485
3505
3486
3506
with self .check_context (arc .open (), 'tar' ):
3487
3507
self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
3488
3508
self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
3489
3509
self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
3490
3510
self .expect_file ('read_group_only' , mode = '?---r-----' )
3491
3511
self .expect_file ('no_bits' , mode = '?---------' )
3492
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3512
+ self .expect_file ('dir/' , mode = '?---r-xr-x' )
3493
3513
3494
3514
with self .check_context (arc .open (), 'data' ):
3495
3515
normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3499,7 +3519,7 @@ def test_modes(self):
3499
3519
self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
3500
3520
self .expect_file ('read_group_only' , mode = '?rw-r-----' )
3501
3521
self .expect_file ('no_bits' , mode = '?rw-------' )
3502
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = normal_dir_mode )
3522
+ self .expect_file ('dir/' , mode = normal_dir_mode )
3503
3523
3504
3524
def test_pipe (self ):
3505
3525
# Test handling of a special file
0 commit comments