]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/pwauth.c: Replace getpass(3) by agetpass()
authorAlejandro Colomar <alx@kernel.org>
Fri, 1 Sep 2023 23:58:05 +0000 (01:58 +0200)
committerSerge Hallyn <serge@hallyn.com>
Mon, 4 Sep 2023 13:57:18 +0000 (08:57 -0500)
Closes: <https://github.com/shadow-maint/shadow/issues/797>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/pwauth.c

index 965cb141209efb14749f7052a27c99433c966d30..023f254169de51b8ed84881f1d998bceea2aae6c 100644 (file)
 #include <stdio.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include "prototypes.h"
+
+#include "agetpass.h"
 #include "defines.h"
 #include "memzero.h"
+#include "prototypes.h"
 #include "pwauth.h"
 #include "getdef.h"
+
 #ifdef SKEY
 #include <skey.h>
 #endif
+
+
 #ifdef __linux__               /* standard password prompt by default */
 static const char *PROMPT = gettext_noop ("Password: ");
 #else
@@ -137,7 +142,7 @@ int pw_auth (const char *cipher,
 #endif
 
                snprintf (prompt, sizeof prompt, cp, user);
-               clear = getpass (prompt);
+               clear = agetpass(prompt);
                input = (clear == NULL) ? "" : clear;
        }
 
@@ -164,7 +169,8 @@ int pw_auth (const char *cipher,
         * -- AR 8/22/1999
         */
        if ((0 != retval) && ('\0' == input[0]) && use_skey) {
-               clear = getpass (prompt);
+               erase_pass(clear);
+               clear = agetpass(prompt);
                input = (clear == NULL) ? "" : clear;
        }
 
@@ -179,10 +185,8 @@ int pw_auth (const char *cipher,
                }
        }
 #endif
+       erase_pass(clear);
 
-       if (NULL != clear) {
-               strzero (clear);
-       }
        return retval;
 }
 #else                          /* !USE_PAM */