]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/{chfn,chsh,passwd}.c: Allow bad names
authorAlejandro Colomar <alx@kernel.org>
Sun, 12 Jul 2026 14:40:07 +0000 (16:40 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 17 Jul 2026 07:33:21 +0000 (09:33 +0200)
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 <alx@kernel.org>
src/chfn.c
src/chsh.c
src/passwd.c

index 966919bc6992754f849920c85ac7d161961e98a7..6be7b2bd9baf38df1dfec269989c4e2dc7134c8a 100644 (file)
@@ -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);
                }
index 0e3a6923f81300e339cc64e4c3f922bbe0039968..53ef783a1630c6068c11ee1646cf73736da73aa1 100644 (file)
@@ -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);
                }
index 83b45f63c4aa6f2a6a77eba5b40f377882fadf68..2a46975183565345ce85b9377aef56bc715ea9ac 100644 (file)
@@ -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);
                }