chore: add test for setgid bit inheritance in mkdir -p (#10412)

This commit is contained in:
0xferrous
2026-01-22 04:49:02 -08:00
committed by GitHub
parent 75b9ad4a32
commit 08789257f6
+27
View File
@@ -908,6 +908,33 @@ fn test_mkdir_parent_mode_with_explicit_mode() {
);
}
/// Test that nested directories inherit the setgid bit with mkdir -p.
#[test]
#[cfg(target_os = "linux")]
fn test_mkdir_parent_inherits_setgid() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir("parent");
at.set_mode("parent", 0o2755);
ucmd.arg("-p")
.arg("parent/child/grandchild")
.succeeds()
.no_stderr()
.no_stdout();
// All descendants should inherit the setgid bit (0o2000)
assert_eq!(at.metadata("parent").permissions().mode() & 0o2000, 0o2000);
assert_eq!(
at.metadata("parent/child").permissions().mode() & 0o2000,
0o2000
);
assert_eq!(
at.metadata("parent/child/grandchild").permissions().mode() & 0o2000,
0o2000
);
}
#[test]
fn test_mkdir_concurrent_creation() {
// Test concurrent mkdir -p operations: 10 iterations, 8 threads, 40 levels nesting