]> granicus.if.org Git - sudo/commitdiff
MacOS pam will retry conversation function if it fails so just treat
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 22 Nov 2008 18:17:44 +0000 (18:17 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 22 Nov 2008 18:17:44 +0000 (18:17 +0000)
^C as an empty password.

auth/pam.c

index 1f421a3729c3c0b4923bc7ab846a5d7db343c8a2..d6ba2df549d35f85716b235067970a19d35a55ff 100644 (file)
@@ -45,6 +45,7 @@
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
 #include <pwd.h>
+#include <errno.h>
 
 #ifdef HAVE_PAM_PAM_APPL_H
 # include <pam/pam_appl.h>
@@ -286,12 +287,17 @@ sudo_conv(num_msg, msg, response, appdata_ptr)
                    && (pm->msg[9] != ' ' || pm->msg[10] != '\0'))))
                    prompt = pm->msg;
 #endif
-               /* Read the password. */
+               /* Read the password unless interrupted. */
                pass = tgetpass(prompt, def_passwd_timeout * 60, flags);
                if (pass == NULL) {
                    /* We got ^C instead of a password; abort quickly. */
-                   gotintr = 1;
+                   if (errno == EINTR)
+                       gotintr = 1;
+#if defined(__darwin__) || defined(__APPLE__)
+                   pass = "";
+#else
                    goto err;
+#endif
                }
                pr->resp = estrdup(pass);
                zero_bytes(pass, strlen(pass));