mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
chroot: move logic so it can be triggered by tests
* move the command building logic before the `chroot` syscall so it will be reachable by tests that don't have root permissions.
This commit is contained in:
parent
8db8d8ac4e
commit
8c0b7d1314
1 changed files with 7 additions and 3 deletions
|
@ -77,11 +77,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
|
||||||
_ => commands,
|
_ => commands,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
assert!(!command.is_empty());
|
||||||
|
let chroot_command = command[0];
|
||||||
|
let chroot_args = &command[1..];
|
||||||
|
|
||||||
|
// NOTE: Tests can only trigger code beyond this point if they're invoked with root permissions
|
||||||
set_context(newroot, &matches);
|
set_context(newroot, &matches);
|
||||||
|
|
||||||
assert!(!command.is_empty());
|
let pstatus = Command::new(chroot_command)
|
||||||
let pstatus = Command::new(command[0])
|
.args(chroot_args)
|
||||||
.args(&command[1..])
|
|
||||||
.status()
|
.status()
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
// TODO: Exit status:
|
// TODO: Exit status:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue