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