@@ -3288,23 +3288,43 @@ def test_modes(self):
3288
3288
arc .add ('exec_group_other' , mode = '?rw-rwxrwx' )
3289
3289
arc .add ('read_group_only' , mode = '?---r-----' )
3290
3290
arc .add ('no_bits' , mode = '?---------' )
3291
- arc .add ('dir/' , mode = '?---rwsrwt' , type = tarfile .DIRTYPE )
3291
+ arc .add ('dir/' , mode = '?---rwsrwt' )
3292
+
3293
+ # On some systems, setting the sticky bit is a no-op.
3294
+ # Check if that's the case.
3295
+ tmp_filename = os .path .join (TEMPDIR , "tmp.file" )
3296
+ with open (tmp_filename , 'w' ):
3297
+ pass
3298
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3299
+ have_sticky_files = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3300
+ os .unlink (tmp_filename )
3301
+
3302
+ os .mkdir (tmp_filename )
3303
+ os .chmod (tmp_filename , os .stat (tmp_filename ).st_mode | stat .S_ISVTX )
3304
+ have_sticky_dirs = (os .stat (tmp_filename ).st_mode & stat .S_ISVTX )
3305
+ os .rmdir (tmp_filename )
3292
3306
3293
3307
with self .check_context (arc .open (), 'fully_trusted' ):
3294
- self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3308
+ if have_sticky_files :
3309
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwt' )
3310
+ else :
3311
+ self .expect_file ('all_bits' , mode = '?rwsrwsrwx' )
3295
3312
self .expect_file ('perm_bits' , mode = '?rwxrwxrwx' )
3296
3313
self .expect_file ('exec_group_other' , mode = '?rw-rwxrwx' )
3297
3314
self .expect_file ('read_group_only' , mode = '?---r-----' )
3298
3315
self .expect_file ('no_bits' , mode = '?---------' )
3299
- self .expect_file ('dir' , type = tarfile .DIRTYPE , mode = '?---rwsrwt' )
3316
+ if have_sticky_dirs :
3317
+ self .expect_file ('dir/' , mode = '?---rwsrwt' )
3318
+ else :
3319
+ self .expect_file ('dir/' , mode = '?---rwsrwx' )
3300
3320
3301
3321
with self .check_context (arc .open (), 'tar' ):
3302
3322
self .expect_file ('all_bits' , mode = '?rwxr-xr-x' )
3303
3323
self .expect_file ('perm_bits' , mode = '?rwxr-xr-x' )
3304
3324
self .expect_file ('exec_group_other' , mode = '?rw-r-xr-x' )
3305
3325
self .expect_file ('read_group_only' , mode = '?---r-----' )
3306
3326
self .expect_file ('no_bits' , mode = '?---------' )
3307
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = '?---r-xr-x' )
3327
+ self .expect_file ('dir/' , mode = '?---r-xr-x' )
3308
3328
3309
3329
with self .check_context (arc .open (), 'data' ):
3310
3330
normal_dir_mode = stat .filemode (stat .S_IMODE (
@@ -3314,7 +3334,7 @@ def test_modes(self):
3314
3334
self .expect_file ('exec_group_other' , mode = '?rw-r--r--' )
3315
3335
self .expect_file ('read_group_only' , mode = '?rw-r-----' )
3316
3336
self .expect_file ('no_bits' , mode = '?rw-------' )
3317
- self .expect_file ('dir/' , type = tarfile . DIRTYPE , mode = normal_dir_mode )
3337
+ self .expect_file ('dir/' , mode = normal_dir_mode )
3318
3338
3319
3339
def test_pipe (self ):
3320
3340
# Test handling of a special file
0 commit comments