]> git.ipfire.org Git - thirdparty/shadow.git/commit
useradd: don't mask user_id variable in check_uid_range master
authorSerge Hallyn <serge@hallyn.com>
Tue, 21 Jul 2026 19:41:09 +0000 (14:41 -0500)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Tue, 21 Jul 2026 21:37:04 +0000 (23:37 +0200)
commitda3d7afa63375604a74cfd5af9062e7e4010e674
tree42bc407bdc2de4af204a5c1a8facd15d153ee57b
parent15383e00faab81ff0e1bb6cc117bbf6fbbefc128
useradd: don't mask user_id variable in check_uid_range

While it's not "wrong" right now, it could be confusing, and cause
trouble later.

I'm not a fan of global variables in the first place, but restructuring
venerable code like this tends to be asking for trouble.

Also rename rflg as sys_user.  And fix its type, as it is a bool, not
int.

Also a note on commit 764e56e9ec: useradd: fix subuid allocation,
which is in a PR comment.  Putting it here so it'll be in the git
tree itself:

> For posterity: this was apparently always broken, but the opposite way. The
> user_id part of the check was always true if !user_id, and user_id was always
> 0, so that was ignored. Alex fixed that accidentally by switching to if
> (user_id == 0) return false, in 8508d61.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Reported-by: Alejandro Colomar <alx@kernel.org>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
src/useradd.c