Skip to content

chroot: fix parsing of --userspec argument #7043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

jfinkels
Copy link
Collaborator

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.

@jfinkels jfinkels force-pushed the chroot-parse-userspec branch from e23f998 to 0f0a242 Compare December 31, 2024 17:18
@jfinkels jfinkels marked this pull request as draft December 31, 2024 17:29
@jfinkels
Copy link
Collaborator Author

I need to update the tests to only run chroot as root.

@jfinkels jfinkels force-pushed the chroot-parse-userspec branch from c05eac7 to afa61c8 Compare December 31, 2024 20:49
@jfinkels jfinkels marked this pull request as ready for review December 31, 2024 20:49
Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)

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 uutils#7040.
@sylvestre sylvestre force-pushed the chroot-parse-userspec branch from afa61c8 to 5bd5cdb Compare January 2, 2025 09:26
Copy link

github-actions bot commented Jan 2, 2025

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)

@sylvestre
Copy link
Contributor

I guess you are aware of the remaining issue:


2025-01-02T09:52:18.0207067Z FAIL: tests/chroot/chroot-credentials
2025-01-02T09:52:18.0207289Z =====================================
2025-01-02T09:52:18.0207436Z 
2025-01-02T09:52:18.0207542Z chroot --userspec=$NON_ROOT_UID: / true || fail=1
2025-01-02T09:52:18.0207874Z   chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP / whoami
2025-01-02T09:52:18.0208220Z   chroot --userspec=$NON_ROOT_USERNAME:$NON_ROOT_GROUP \
2025-01-02T09:52:18.0208488Z chroot: invalid group
2025-01-02T09:52:18.0208672Z chroot: invalid group
2025-01-02T09:52:18.0208843Z chroot: invalid group
2025-01-02T09:52:18.0209021Z chroot: invalid group
2025-01-02T09:52:18.0209197Z chroot: invalid group
2025-01-02T09:52:18.0209367Z chroot: invalid group
2025-01-02T09:52:18.0209703Z chroot: invalid group
2025-01-02T09:52:18.0209999Z error: the argument '--groups <GROUP1,GROUP2...>' cannot be used multiple times
2025-01-02T09:52:18.0210271Z 
2025-01-02T09:52:18.0210381Z Usage: chroot [OPTION]... NEWROOT [COMMAND [ARG]...]
2025-01-02T09:52:18.0210580Z 
2025-01-02T09:52:18.0210664Z For more information, try '--help'.
2025-01-02T09:52:18.0210888Z id: '+12342': no such user
2025-01-02T09:52:18.0211075Z chroot: invalid group
2025-01-02T09:52:18.0211254Z chroot: invalid user
2025-01-02T09:52:18.0211598Z FAIL tests/chroot/chroot-credentials.sh (exit status: 1)

@sylvestre sylvestre merged commit ede8e15 into uutils:main Jan 2, 2025
65 checks passed
@jfinkels
Copy link
Collaborator Author

jfinkels commented Jan 2, 2025

I guess you are aware of the remaining issue: ...

Yes, there are still a lot of problems with chroot. I'll try to catalog some of them in new issues.

Edit: fixed typo: csplit -> chroot

@jfinkels jfinkels deleted the chroot-parse-userspec branch January 2, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

chroot: fails to parse valid userspec of the form uid: or :gid
2 participants