Skip to content

useradd: exit 19 for an invalid user name - #341

Merged
sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:fix/340-useradd-invalid-name-exit-19
Oct 22, 2026
Merged

sylvestre merged 2 commits into
uutils:mainfrom
jayhemnani9910:fix/340-useradd-invalid-name-exit-19

Conversation

@jayhemnani9910

@jayhemnani9910 jayhemnani9910 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #340

A name rejected by validate_username now maps to a new UseraddError::BadName, exit 19, as listed in useradd(8). Other tools keep their codes: groupadd(8) has no 19 and GNU groupadd exits 3 there too.

Tests: test_invalid_name_exits_19 (root-only, like the other --root tests) checks bad:name and 1234 exit 19 and leave passwd unchanged; it fails before (exit 3) and passes after. cargo test --workspace as root in an Ubuntu 26.04 container: 940 passed (939 on main, plus the new one). fmt and clippy clean; pam configurations not run locally. Against GNU shadow 4.17.4 in the same container, the exit codes now match for bad:name, 1234, -r 'x y'.

AI tools assisted with this contribution.

useradd(8) lists exit 19 for an invalid user or group name; useradd exited 3.
Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Self::UsernameInUse(_) => 9,
Self::CannotUpdateGroup(_) => 10,
Self::CannotCreateHome(_) => 12,
Self::BadName(_) => 19,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a BAD_NAME: i32 = 19 to exit_codes and to test_error_codes, like the others?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5038265, BAD_NAME: i32 = 19 is in exit_codes and checked in test_error_codes.

Copilot AI balanced review requested due to automatic review settings October 22, 2026 13:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sylvestre
sylvestre merged commit bf79b9c into uutils:main Oct 22, 2026
13 checks passed
@sylvestre

Copy link
Copy Markdown
Collaborator

Thanks for your PR

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.

useradd: invalid user name exits 3 instead of 19

3 participants