Commit Graph
35 Commits
Author SHA1 Message Date
04e258f171 chroot: fix gid being set by uid with --userspec #10307 (#10465)
* chroot: fix gid being set by uid with --userspec

* chroot: check using sync user that has uid != gid

* chroot: correct Error response on failure case

* chroot: fix test

* chroot: test failure output

---------

Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
2026-02-12 02:54:14 -08:00
mattsuandGitHub 57d3fce29e chroot: use execvp directly instead of process::Command (#9013)
* chroot: exec command with Command::exec and map errors

* test(chroot): add error handling and UID/GID retention tests

* chore(cspell): add noexec to jargon wordlist
2025-12-26 23:59:06 +01:00
Sylvestre Ledru a0179ea239 uutests: adjust the tests to use them 2025-03-28 21:40:31 +01:00
Sylvestre Ledru a85539f530 Run cargo fmt on the tree 2025-03-24 21:33:12 +01:00
Sylvestre Ledru 18cb7dcf9e Use the new function fails_with_code
Done with
```
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.no_stdout\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2)\n\1.no_stdout();/gs' *rs
$ sed -i -e "s|.fails()(.*).code_is(|.fails_with_code(|g" *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)[ \t]*\n[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\2);/gs' *rs
$ perl -0777 -i -pe 's/([ \t]+)\.fails\(\)(.*?)[ \t]+\.code_is\(([0-9]+)\);/\1.fails_with_code(\3)\2;/gs' *rs
...
```
2025-03-01 17:26:20 +01:00
Anirban Halder 924d40867c chroot: make group option self overwriting 2025-01-12 01:08:38 +05:30
Daniel Hofstetter e5e589afd5 chroot: remove short option "-G" 2025-01-02 13:35:19 +01:00
Jeffrey FinkelsteinandSylvestre Ledru 5bd5cdb7c1 chroot: fix parsing of --userspec argument
Fix the parsing of the `--userspec=USER:GROUP` argument so that the
both the user and the group are optional, and update the error message
to match that of GNU `chroot`. This commit also removes the incorrect
`clap` arguments for `--user` and `--group`. In `chroot --user=USER`,
the `--user` is an abbreviation of `--userspec`, and in `chroot
--group=GROUP`, the `--group` is an abbreviation of `--groups`.

Closes #7040.
2025-01-02 10:26:13 +01:00
Sylvestre Ledru 7d628c65d3 chroot: handle the error when invalid user
Currently fails with:
```
2024-12-28T14:55:18.9330231Z thread 'main' panicked at src/uu/chroot/src/chroot.rs:284:46:
2024-12-28T14:55:18.9330718Z called `Result::unwrap()` on an `Err` value: Custom { kind: NotFound, error: "Not found: nobody:+65535" }
2024-12-28T14:55:18.9331305Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
2024-12-28 22:29:27 +01:00
Daniel HofstetterandBen Wiederhake 29e5d0b42b clippy: fix redundant_clone lint warnings in tests 2024-04-21 01:26:50 +02:00
Sylvestre Ledru 764ea34c37 dd/chroot: improve the skip message (not root) 2023-12-28 00:44:19 +01:00
Sylvestre Ledru bfca6bf70f Add license headers on all files 2023-08-21 10:49:27 +02:00
Miles Liu 2bcdae124c chroot: fix unused import on Android 2023-03-22 12:02:01 +08:00
Daniel Hofstetter 6988eb7ec6 tests: expand wildcard imports 2023-03-20 15:32:35 +01:00
Daniel Hofstetter 3eeb5dda30 tests: adapt to clap's modified error messages 2023-03-09 10:06:20 +01:00
Thayne McCombs 17f9507e17 Add tests for non-utf8 2023-02-21 22:58:39 -07:00
Daniel Hofstetter f6b646e4e5 clippy: fix warnings introduced with Rust 1.67.0 2023-01-27 17:37:56 +01:00
Joining7943 1fadeb43b2 tests/util: Do not trim stderr in CmdResult::stderr_is. Add method stderr_trimmed_is.
Fix tests assert whitespace instead of trimming it. Disable some tests in `test_tr` because `tr`
produces too many newlines.
2023-01-22 14:56:19 +01:00
Sylvestre Ledru d768b19f2b chroot: improve support of --skip-chdir
Should unbreak tests/misc/chroot-fail.sh
2022-10-10 14:07:45 +02:00
Sylvestre Ledru 3cda177d34 Disable test_preference_of_userspec on android 2022-10-04 17:17:01 +02:00
Sylvestre Ledru 69b52b4a1b chroot: add a new test to verify that 'chroot / ls -al' works 2022-09-21 19:47:01 +02:00
Sylvestre Ledru 2e26e1d2bd chroot: implement --skip-chdir 2022-09-21 19:46:58 +02:00
Sylvestre Ledru 3654efe8e7 chroot: add more tests 2022-09-21 14:53:50 +02:00
Terts Diepraam 51bd8a2ba8 chroot: set exit codes to 125, 126 or 127 for errors from chroot itself 2022-09-11 12:02:54 +02:00
Terts Diepraam 9177cb7b24 all: add tests for usage error exit code 2022-09-10 20:59:42 +02:00