Skip to content

src/{chfn,chsh,passwd}.c: Allow bad names (regression fix)#1671

Merged
ikerexxe merged 4 commits into
shadow-maint:masterfrom
alejandro-colomar:reg_badname
Jul 17, 2026
Merged

src/{chfn,chsh,passwd}.c: Allow bad names (regression fix)#1671
ikerexxe merged 4 commits into
shadow-maint:masterfrom
alejandro-colomar:reg_badname

Conversation

@alejandro-colomar

@alejandro-colomar alejandro-colomar commented Jul 12, 2026

Copy link
Copy Markdown
Collaborator
    These programs don't add new users.  Because they handle existing users,
    they should handle them with whatever names they already have, including
    bad names.
    
    A recent commit that added some username syntax validation blindly
    removed support for bad names in these programs.  Fix that regression.

Also, pass the badname flag as a function parameter instead of an extern variable. This makes it easier to analyze which programs allow badnames and which don't.

Also, remove an inconsistent (and seemingly accidental) allowance of badnames in group names in newusers(8).

Fixes: 326889c (2024-10-22; "Fix coverity unbound buffer issues")
Fixes: a2cd3e9 (2019-10-04; "chkname.c, pwck.c, useradd.c, usermod.c, newusers.c: Allow names that do not conform to standards")
Cc: @MarcinDigitic , @edneville

... instead of an extern variable.  This makes it easier to analyze
which programs allow badnames and which don't.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
These programs don't add new users.  Because they handle existing users,
they should handle them with whatever names they already have, including
bad names.

A recent commit that added some username syntax validation blindly
removed support for bad names in these programs.  Fix that regression.

Fixes: 326889c (2024-10-22; "Fix coverity unbound buffer issues")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Other programs handling groups don't allow this.
I believe this was only accidentally allowed.

Fixes: a2cd3e9 (2019-10-04; "chkname.c, pwck.c, useradd.c, usermod.c, newusers.c: Allow names that do not conform to standards")
Cc: ed <ed@s5h.net>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
We don't allow badnames in group names.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar alejandro-colomar changed the title src/{chfn,chsh,passwd}.c: Allow bad names src/{chfn,chsh,passwd}.c: Allow bad names (regression fix) Jul 12, 2026

@ikerexxe ikerexxe left a comment

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.

The changes look great, but I think we can make a couple of quick changes to improve the review. If you could squash commits 1 and 4, it would really help tidy up the commit history and make the final diff much easier to read.
Also, to keep our pattern consistent and avoid introducing a new global variable, I'd highly suggest expanding the existing option_flags struct to include the badnames boolean instead. That way, we can just pass it down wherever it's needed and keep our state centralized.

Comment thread src/passwd.c
@alejandro-colomar

alejandro-colomar commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

The changes look great, but I think we can make a couple of quick changes to improve the review.

If you could squash commits 1 and 4, it would really help tidy up the commit history and make the final diff much easier to read.

One problem with that is that it would squash a breaking change with a refactor. I prefer having it separate, so that the diff for the breaking change is minimal.

Also, to keep our pattern consistent and avoid introducing a new global variable, I'd highly suggest expanding the existing option_flags struct to include the badnames boolean instead. That way, we can just pass it down wherever it's needed and keep our state centralized.

I'd like to refactor that separately. I also want to unify the struct option_flags and put it in a header file. I prefer doing that in a separate PR, though.

@ikerexxe

Copy link
Copy Markdown
Collaborator

One problem with that is that it would squash a breaking change with a refactor. I prefer having it separate, so that the diff for the breaking change is minimal.

I see your point here. This was just a preference, so let's keep it as it is

I'd like to refactor that separately. I also want to unify the struct option_flags and put it in a header file. I prefer doing that in a separate PR, though.

I’m really looking forward to seeing this change. At first, I considered doing it this way, but I felt that there were utilities that wouldn’t use all the options, so I ruled it out. I also considered using getters and setters for the values, but that’s very OOP

@ikerexxe ikerexxe left a comment

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.

LGTM! So, let's merge it

@ikerexxe
ikerexxe merged commit f37beab into shadow-maint:master Jul 17, 2026
14 of 16 checks passed
@alejandro-colomar
alejandro-colomar deleted the reg_badname branch July 17, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants