Imported Upstream version 1.7.0
[debian/sudo] / auth / fwtk.c
index 4e365fc6456bf1742eea223e28f9a97434be0f28..d09b132d7fa81d15db2679de33dc74ce2b33d9b5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999-2005 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1999-2005, 2008 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
 #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>
@@ -55,7 +50,7 @@
 #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 $";
+__unused static const char rcsid[] = "$Sudo: fwtk.c,v 1.29 2008/11/09 14:13:13 millert Exp $";
 #endif /* lint */
 
 int
@@ -68,22 +63,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 +95,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 +122,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 +144,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));