File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -908,6 +908,33 @@ 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( target_os = "linux" ) ]
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+ assert_eq ! ( at. metadata( "parent" ) . permissions( ) . mode( ) & 0o2000 , 0o2000 ) ;
928+ assert_eq ! (
929+ at. metadata( "parent/child" ) . permissions( ) . mode( ) & 0o2000 ,
930+ 0o2000
931+ ) ;
932+ assert_eq ! (
933+ at. metadata( "parent/child/grandchild" ) . permissions( ) . mode( ) & 0o2000 ,
934+ 0o2000
935+ ) ;
936+ }
937+
911938#[ test]
912939fn test_mkdir_concurrent_creation ( ) {
913940 // Test concurrent mkdir -p operations: 10 iterations, 8 threads, 40 levels nesting
You can’t perform that action at this time.
0 commit comments