]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/useradd.c: E_BAD_NAME: Use a different error code for bad login names
authorAlejandro Colomar <alx@kernel.org>
Thu, 5 Dec 2024 16:38:54 +0000 (17:38 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 9 Feb 2025 04:08:06 +0000 (22:08 -0600)
Wrappers like adduser(8) want to do their own stuff if the login name is
bad.  For that, they need to be able to differentiate such an error.

Closes: <https://github.com/shadow-maint/shadow/issues/1103>
Suggested-by: Chris Hofstaedtler <zeha@debian.org>
Cc: Marc 'Zugschlus' Haber <mh+githubvisible@zugschlus.de>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/useradd.c

index 562ba44fc824af1ffce9ccd3d1a1505a15853556..e271b30e1d233beccf0a1aa8591ffab8ca76b497 100644 (file)
@@ -201,6 +201,7 @@ static bool home_added = false;
 #define E_SUB_UID_UPDATE 16    /* can't update the subordinate uid file */
 #define E_SUB_GID_UPDATE 18    /* can't update the subordinate gid file */
 #endif                         /* ENABLE_SUBIDS */
+#define E_BAD_NAME     19      /* Bad login name */
 
 #define DGROUP                 "GROUP"
 #define DGROUPS                        "GROUPS"
@@ -1549,7 +1550,7 @@ static void process_flags (int argc, char **argv)
                                      user_name, AUDIT_NO_ID,
                                      SHADOW_AUDIT_FAILURE);
 #endif
-                       exit (E_BAD_ARG);
+                       exit (E_BAD_NAME);
                }
                if (!dflg) {
                        char  *uh;