]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
passwd: document exit code when PAM has errored
authorSerge Hallyn <serge@hallyn.com>
Sat, 22 Mar 2025 12:54:27 +0000 (07:54 -0500)
committerAlejandro Colomar <alx@kernel.org>
Mon, 24 Mar 2025 11:03:28 +0000 (12:03 +0100)
closes #1219

When pam returns an error, we were exiting with exit code 10,
which was hardcoded and not documented.  Create a name for it,
and document it in the manpage.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Reported-by: Marc Haber <githubvisible@zugschlus.de>
Reviewed-by: Alejandro Colomar <alx@kernel.org>
lib/pam_pass.c
man/passwd.1.xml
src/passwd.c

index ff491739574b0b193cf1b3ec23752656e15efbb2..0e3ec4c03b9fa802503abc05e277074a825a1808 100644 (file)
@@ -40,7 +40,7 @@ void do_pam_passwd (const char *user, bool silent, bool change_expired)
        if (ret != PAM_SUCCESS) {
                fprintf (shadow_logfd,
                         _("passwd: pam_start() failed, error %d\n"), ret);
-               exit (10);      /* XXX */
+               exit (E_PAM_ERR);
        }
 
        ret = pam_chauthtok (pamh, flags);
@@ -48,7 +48,7 @@ void do_pam_passwd (const char *user, bool silent, bool change_expired)
                fprintf (shadow_logfd, _("passwd: %s\n"), pam_strerror (pamh, ret));
                fputs (_("passwd: password unchanged\n"), shadow_logfd);
                pam_end (pamh, ret);
-               exit (10);      /* XXX */
+               exit (E_PAM_ERR);
        }
 
        fputs (_("passwd: password updated successfully\n"), shadow_logfd);
index c1540990f393e58889657bcc6a3090b311b7dc01..a407f10b7e034864b0eaa38dec21fa49b9be4a8e 100644 (file)
            <para>invalid argument to option</para>
          </listitem>
        </varlistentry>
+       <varlistentry>
+         <term><replaceable>10</replaceable></term>
+         <listitem>
+           <para>an error was returned by <refentrytitle>pam</refentrytitle><manvolnum>3</manvolnum></para>
+         </listitem>
+       </varlistentry>
       </variablelist>
     </para>
   </refsect1>
index cc79960a54026aae1855818aa3294e4a084a0539..c545550fdf4ab160deeead9a2aa547081b9da86d 100644 (file)
@@ -51,6 +51,7 @@
 #define E_MISSING      4       /* unexpected failure, passwd file missing */
 #define E_PWDBUSY      5       /* passwd file busy, try again later */
 #define E_BAD_ARG      6       /* invalid argument to option */
+#define E_PAM_ERR      10      /* PAM returned an error */
 /*
  * Global variables
  */