From: Alejandro Colomar Date: Sun, 12 Jul 2026 14:40:07 +0000 (+0200) Subject: src/{chfn,chsh,passwd}.c: Allow bad names X-Git-Tag: 4.20.0-rc3~35 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=141bf183b56b26755a1b94ba7dcea3fa2dabbde7;p=thirdparty%2Fshadow.git src/{chfn,chsh,passwd}.c: Allow bad names 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: 326889ca81bb (2024-10-22; "Fix coverity unbound buffer issues") Signed-off-by: Alejandro Colomar --- diff --git a/src/chfn.c b/src/chfn.c index 966919bc6..6be7b2bd9 100644 --- a/src/chfn.c +++ b/src/chfn.c @@ -604,7 +604,7 @@ int main (int argc, char **argv) * name, or the name getlogin() returns. */ if (optind < argc) { - if (!is_valid_user_name(argv[optind], false)) { + if (!is_valid_user_name(argv[optind], true)) { fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); fail_exit (E_NOPERM, process_selinux); } diff --git a/src/chsh.c b/src/chsh.c index 0e3a6923f..53ef783a1 100644 --- a/src/chsh.c +++ b/src/chsh.c @@ -493,7 +493,7 @@ int main (int argc, char **argv) * name, or the name getlogin() returns. */ if (optind < argc) { - if (!is_valid_user_name(argv[optind], false)) { + if (!is_valid_user_name(argv[optind], true)) { fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); fail_exit (1, process_selinux); } diff --git a/src/passwd.c b/src/passwd.c index 83b45f63c..2a4697518 100644 --- a/src/passwd.c +++ b/src/passwd.c @@ -946,7 +946,7 @@ main(int argc, char **argv) } myname = xstrdup (pw->pw_name); if (optind < argc) { - if (!is_valid_user_name(argv[optind], false) && !is_valid_upn(argv[optind], false)) { + if (!is_valid_user_name(argv[optind], true) && !is_valid_upn(argv[optind], true)) { fprintf (stderr, _("%s: Provided user name is not a valid name\n"), Prog); fail_exit (E_NOPERM, process_selinux); }