mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 03:57:44 +00:00
Merge pull request #7015 from sylvestre/chroot-user
chroot: handle the error when invalid user
This commit is contained in:
commit
a3b7a08238
3 changed files with 28 additions and 1 deletions
|
@ -64,6 +64,28 @@ fn test_invalid_user_spec() {
|
|||
assert!(result.stderr_str().starts_with("chroot: invalid userspec"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_user() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
let at = &ts.fixtures;
|
||||
|
||||
let dir = "CHROOT_DIR";
|
||||
at.mkdir(dir);
|
||||
if let Ok(result) = run_ucmd_as_root(&ts, &[dir, "whoami"]) {
|
||||
result.success().no_stderr().stdout_is("root");
|
||||
} else {
|
||||
print!("Test skipped; requires root user");
|
||||
}
|
||||
|
||||
if let Ok(result) = run_ucmd_as_root(&ts, &["--user=nobody:+65535", dir, "pwd"]) {
|
||||
result
|
||||
.failure()
|
||||
.stderr_contains("no such user: nobody:+65535");
|
||||
} else {
|
||||
print!("Test skipped; requires root user");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(target_os = "android"))]
|
||||
fn test_preference_of_userspec() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue