mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
chore: add test for setgid bit inheritance in mkdir -p (#10412)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user