File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -908,6 +908,32 @@ fn test_mkdir_parent_mode_with_explicit_mode() {
908908 ) ;
909909}
910910
911+ /// Test that nested directories inherit the setgid bit with mkdir -p.
912+ #[ test]
913+ #[ cfg( not( windows) ) ]
914+ fn test_mkdir_parent_inherits_setgid ( ) {
915+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
916+
917+ at. mkdir ( "parent" ) ;
918+ at. set_mode ( "parent" , 0o2755 ) ;
919+
920+ ucmd. arg ( "-p" )
921+ . arg ( "parent/child/grandchild" )
922+ . succeeds ( )
923+ . no_stderr ( )
924+ . no_stdout ( ) ;
925+
926+ // All descendants should inherit the setgid bit (0o2000)
927+ let parent_mode = at. metadata ( "parent" ) . permissions ( ) . mode ( ) as mode_t ;
928+ assert_eq ! ( parent_mode & 0o2000 , 0o2000 ) ;
929+
930+ let child_mode = at. metadata ( "parent/child" ) . permissions ( ) . mode ( ) as mode_t ;
931+ assert_eq ! ( child_mode & 0o2000 , 0o2000 ) ;
932+
933+ let grandchild_mode = at. metadata ( "parent/child/grandchild" ) . permissions ( ) . mode ( ) as mode_t ;
934+ assert_eq ! ( grandchild_mode & 0o2000 , 0o2000 ) ;
935+ }
936+
911937#[ test]
912938fn test_mkdir_concurrent_creation ( ) {
913939 // Test concurrent mkdir -p operations: 10 iterations, 8 threads, 40 levels nesting
You can’t perform that action at this time.
0 commit comments