Imported Upstream version 1.7.4p6
[debian/sudo] / auth / fwtk.c
index 4e365fc6456bf1742eea223e28f9a97434be0f28..fba99e8095e993ca5f9bfdce771e9071909f5b3b 100644 (file)
@@ -1,5 +1,6 @@
 /*
- * Copyright (c) 1999-2005 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1999-2005, 2008, 2010
+ *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
 #endif /* STDC_HEADERS */
 #ifdef HAVE_STRING_H
 # include <string.h>
-#else
-# ifdef HAVE_STRINGS_H
-#  include <strings.h>
-# endif
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
 #endif /* HAVE_STRING_H */
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif /* HAVE_UNISTD_H */
-#ifdef HAVE_ERR_H
-# include <err.h>
-#else
-# include "emul/err.h"
-#endif /* HAVE_ERR_H */
 #include <pwd.h>
 
 #include <auth.h>
 #include "sudo.h"
 #include "sudo_auth.h"
 
-#ifndef lint
-__unused static const char rcsid[] = "$Sudo: fwtk.c,v 1.23.2.2 2007/06/12 01:28:42 millert Exp $";
-#endif /* lint */
-
 int
 fwtk_init(pw, promptp, auth)
     struct passwd *pw;
@@ -68,22 +59,22 @@ fwtk_init(pw, promptp, auth)
     char resp[128];                    /* Response from the server */
 
     if ((confp = cfg_read("sudo")) == (Cfg *)-1) {
-       warnx("cannot read fwtk config");
+       warningx("cannot read fwtk config");
        return(AUTH_FATAL);
     }
 
     if (auth_open(confp)) {
-       warnx("cannot connect to authentication server");
+       warningx("cannot connect to authentication server");
        return(AUTH_FATAL);
     }
 
     /* Get welcome message from auth server */
     if (auth_recv(resp, sizeof(resp))) {
-       warnx("lost connection to authentication server");
+       warningx("lost connection to authentication server");
        return(AUTH_FATAL);
     }
     if (strncmp(resp, "Authsrv ready", 13) != 0) {
-       warnx("authentication server error:\n%s", resp);
+       warningx("authentication server error:\n%s", resp);
        return(AUTH_FATAL);
     }
 
@@ -100,13 +91,12 @@ fwtk_verify(pw, prompt, auth)
     char buf[SUDO_PASS_MAX + 12];      /* General prupose buffer */
     char resp[128];                    /* Response from the server */
     int error;
-    extern int nil_pw;
 
     /* Send username to authentication server. */
     (void) snprintf(buf, sizeof(buf), "authorize %s 'sudo'", pw->pw_name);
 restart:
     if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
-       warnx("lost connection to authentication server");
+       warningx("lost connection to authentication server");
        return(AUTH_FATAL);
     }
 
@@ -128,19 +118,17 @@ restart:
        strlcpy(buf, "response dummy", sizeof(buf));
        goto restart;
     } else {
-       warnx("%s", resp);
+       warningx("%s", resp);
        return(AUTH_FATAL);
     }
     if (!pass) {                       /* ^C or error */
-       nil_pw = 1;
-       return(AUTH_FAILURE);
-    } else if (*pass == '\0')          /* empty password */
-       nil_pw = 1;
+       return(AUTH_INTR);
+    }
 
     /* Send the user's response to the server */
     (void) snprintf(buf, sizeof(buf), "response '%s'", pass);
     if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
-       warnx("lost connection to authentication server");
+       warningx("lost connection to authentication server");
        error = AUTH_FATAL;
        goto done;
     }
@@ -152,7 +140,7 @@ restart:
 
     /* Main loop prints "Permission Denied" or insult. */
     if (strcmp(resp, "Permission Denied.") != 0)
-       warnx("%s", resp);
+       warningx("%s", resp);
     error = AUTH_FAILURE;
 done:
     zero_bytes(pass, strlen(pass));