Skip to content

Commit 70cc905

Browse files
authored
Merge pull request #7123 from AnirbanHalder654322/chroot_stuff
chroot: make group option self overwriting
2 parents b9765a7 + 924d408 commit 70cc905

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/uu/chroot/src/chroot.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ pub fn uu_app() -> Command {
254254
.arg(
255255
Arg::new(options::GROUPS)
256256
.long(options::GROUPS)
257+
.overrides_with(options::GROUPS)
257258
.help("Comma-separated list of groups to switch to")
258259
.value_name("GROUP1,GROUP2..."),
259260
)

tests/by-util/test_chroot.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ fn test_no_such_directory() {
5353
.code_is(125);
5454
}
5555

56+
#[test]
57+
fn test_multiple_group_args() {
58+
let ts = TestScenario::new(util_name!());
59+
let at = &ts.fixtures;
60+
at.mkdir("id");
61+
62+
if let Ok(result) = run_ucmd_as_root(
63+
&ts,
64+
&["--groups='invalid ignored'", "--groups=''", "/", "id", "-G"],
65+
) {
66+
result.success().stdout_is("0");
67+
} else {
68+
print!("Test skipped; requires root user");
69+
}
70+
}
71+
5672
#[test]
5773
fn test_invalid_user_spec() {
5874
let ts = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)