Repository navigation
Take upstream's account names, report a missing spool or home in userdel -r - #393
Merged
Merged
Conversation
The shared check for a new name allowed only a letter or `_` first, no trailing dot, and 32 characters, so `usermod -l 0abc` was exit 3 where upstream renames the account. Probing Ubuntu 26.04's useradd, usermod -l, groupadd, groupmod -n and newusers shows they all apply the rule pwck and grpck already follow here, plus a refused leading `-`: a name may start with a digit or a dot and end with a dot; what is refused is a name that reads as a number (`123`, `0x1a`, `0o7`), `.`, `..`, and anything outside the portable set. A user name runs to 255 characters, a group name to 32. validate_username is replaced by is_valid_user_name and is_valid_group_name on top of is_valid_account_name, and each tool now prints upstream's message for a refused name. newusers checks the group it creates for a line against the group rule, which upstream does and which matters now that a user name can be longer than a group name. groupmod -n takes a value starting with `-` as the name, as usermod -l does, so `groupmod -n -x` is exit 3 rather than a usage error. Fixes #391
`userdel -r` was silent when the user's mail spool or home directory did not exist. Ubuntu 26.04's userdel prints `LOGIN mail spool (PATH) not found` and `LOGIN home directory (PATH) not found` on standard error, mail spool first, and still exits 0; an empty home field is reported as `()`. Do the same, handling the spool before the home as upstream does. Fixes #392
Collaborator
|
thanks for working on this! |
This was referenced Nov 3, 2026
Merged
Collaborator
Author
|
Sorry, this was merged before CI and before your review. That was my mistake, and I've stopped using auto-merge here. Following your comment:
On the 32-character question, against Ubuntu 26.04's
Upstream is inconsistent there, and our build gives the same result for each tool, at both 32 and 33 characters. The details are in #395. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two parity fixes, each probed against Ubuntu 26.04's
passwd1:4.17.4-2ubuntu3 inubuntu:26.04.Account names (#391)
The shared check for a new name wanted a letter or
_first, no trailing dot and at most 32 characters, sousermod -l 0abcwas exit 3. A batch probe ofuseradd,usermod -l,groupadd,groupmod -nandnewusersover 40 names shows all five apply the rulepwckandgrpckalready follow here, plus a refused leading-:0abc,1e5,.abc,a.,...,123$,0xg,1.5123,0,00,0x1a,0o7(reads as an ID)-x,.,..,$,a$b,a@b,éSo a leading digit is fine, and an all-numeric name stays refused everywhere:
123is taken for a UID.shadow-core:validate_usernameis replaced byis_valid_user_name(255) andis_valid_group_name(32), built onis_valid_account_name.pwckandgrpckshare the two length constants.useradd19,usermod3,groupadd3 ('X' is not a valid group name),groupmod3,newusers1 (the fault, thenline N: can't create user).newuserschecks the group it creates for a line against the group rule, as upstream does. This matters now that a user name can be longer than a group name.groupmod -n -xtakes-xas the name, asusermod -lalready does, so it is exit 3 and not a usage error.chfnandchshonly look up an existing account. They do not judge names:chsh/chfnon0abcsucceed upstream.userdel -r (#392)
Upstream prints
LOGIN mail spool (PATH) not foundandLOGIN home directory (PATH) not foundon stderr, mail spool first, and exits 0. For an empty home field it prints().userdel -rnow does the same and handles the spool before the home.Tests
Each commit adds tests that fail on main: 5 per-tool integration tests for #391, plus probe tables in
validate.rs, and one for #392 covering both missing, either one missing, and an empty home field.cargo test --workspace(1060 passed), clippy-D warnings(default,pam, all features) andcargo fmt --checkare clean in the debian image. Man pages and CHANGELOG are updated.Fixes #391
Fixes #392