Repository navigation
useradd: honor -U when USERGROUPS_ENAB is no, reject -U with -g - #345
Conversation
USERGROUPS_ENAB only sets the default. With it set to no, -U was ignored and the user got the default group. -U with -g was accepted and quietly created a new group instead of using the one given; GNU rejects the pair.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
| #[test] | ||
| fn test_clap_user_group_conflicts_with_gid() { | ||
| let result = uu_app().try_get_matches_from(["useradd", "-U", "-g", "100", "user"]); | ||
| assert!(result.is_err()); |
There was a problem hiding this comment.
could you please check err().kind() == ErrorKind::ArgumentConflict instead of just is_err()?
There was a problem hiding this comment.
Done in 2545a28, it now asserts ErrorKind::ArgumentConflict.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for your PR |
Fixes #343
An explicit
-Unow always creates the user group;USERGROUPS_ENABonly decides when neither-Unor-Nis given.-Uconflicts with-gin clap, the same way it already conflicts with-N, so the pair exits 2 like GNU. The message is clap's (the argument '--user-group' cannot be used with '--gid <GROUP>'), as for-U -Ntoday.Tests: a clap test for
-U -g, and a root test where-UwithUSERGROUPS_ENAB nocreates the group. Both fail before, pass after.cargo test --workspacerun as root in an Ubuntu 26.04 container: 945 passed (943 on main, plus the two new).cargo fmt --checkandcargo clippy --workspace --all-targets -- -D warningsare clean; thepamconfigurations were not run locally. Against GNU shadow 4.17.4 in the same container,USERGROUPS_ENAByes/no with no flag,-U,-N,-g usersand-U -g usersgive the same files and exit codes.AI tools assisted with this contribution.