Fix several issues in the behavior of `chroot`, mostly around setting
group IDs. This commit ensures that supplemental groups provided by
`--groups` are properly handled with respect to the groups implied by
`--userspec`. This commit also ensures that we fall back to numeric
parsing when attempting to lookup user and group IDs from their names.
Change the type of `Options.groups` to be `Option<Vec<String>>` so that
the absence of the `--groups` option is meaningfully distinguished from
an empty list of groups. This is important because `chroot --groups=''`
is used specifically to disable supplementary group lookup.
Improve the parsing of the `--groups` parameter to `chroot` so that it
handles more error cases and better matches the behavior of GNU
`chroot`. For example, multiple adjacent commas are allowed:
--groups=a,,,b
but spaces between commas are not allowed:
--groups="a, , ,b"
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.
This change resolves issues with exponent calculation and usage,
ensuring more accurate formatting:
- Exponent for negative values can differ from 0
- Switching to decimal mode now follows the P > X ≥ −4 rule
* Added error handling to ensure '=' after -u returns 125 as '=' is not allowed
* Added tests for disallow = on short options
* Added error handling to ensure '=' after -u returns 125 as '=' is not allowed
* Added tests for disallow = on short options
* Disallow only short unset option from having '=' as its starting character
* Remove needless tests and update function name for clarity
Fix a subtraction underflow that occurred on `head --bytes=-N` when the
input had fewer than `N` bytes. Before this commit,
printf "a" | head -c -2
would panic. After this commit, it terminates successfully with no
output as expected.