]> granicus.if.org Git - sudo/commitdiff
Add local error/warning functions like err/warn but that call an additional
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 19 Nov 2004 17:24:20 +0000 (17:24 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 19 Nov 2004 17:24:20 +0000 (17:24 +0000)
cleanup routine in the error case.  This means we no longer need to compile
a special version of alloc.o for visudo.

auth/fwtk.c
auth/rfc1938.c
auth/securid.c
auth/securid5.c

index 3e5f3c9bf8acc12da0818eb0e55ab7bd0cced4b1..0ecc48d6d80b31e6cd21f12832e58e89fc81a228 100644 (file)
 #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>
@@ -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);
     }
 
@@ -106,7 +101,7 @@ fwtk_verify(pw, prompt, auth)
     (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,7 +123,7 @@ restart:
        strlcpy(buf, "response dummy", sizeof(buf));
        goto restart;
     } else {
-       warnx("%s", resp);
+       warningx("%s", resp);
        return(AUTH_FATAL);
     }
     if (!pass) {                       /* ^C or error */
@@ -140,7 +135,7 @@ restart:
     /* 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 +147,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));
index 8df5de12805c675030e4020eb726caae34e65f5e..ddf13f0174be00b69959aaf1db8a47eb8c3c24ff 100644 (file)
 #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>
 
 #if defined(HAVE_SKEY)
@@ -113,7 +108,7 @@ rfc1938_setup(pw, promptp, auth)
      */
     if (rfc1938challenge(&rfc1938, pw->pw_name, challenge, sizeof(challenge))) {
        if (IS_ONEANDONLY(auth)) {
-           warnx("you do not exist in the %s database", auth->name);
+           warningx("you do not exist in the %s database", auth->name);
            return(AUTH_FATAL);
        } else {
            return(AUTH_FAILURE);
index 8158bfbcc923e4571f73198e7412ce02f42832a6..fe88a698aeba3731f6d44fe199df1faa0ed434e0 100644 (file)
 #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 <sdi_athd.h>
@@ -94,7 +89,7 @@ securid_setup(pw, promptp, auth)
        strlcpy(sd->username, pw->pw_name, 32);
        return(AUTH_SUCCESS);
     } else {
-       warnx("unable to contact the SecurID server");
+       warningx("unable to contact the SecurID server");
        return(AUTH_FATAL);
     }
 }
index 8935c4118b64de7912ca630a9724bb467f8b281a..f5cd7aefcf25d064f6c564a83dbfe19b12c2bc5e 100644 (file)
 #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>
 
 /* Needed for SecurID v5.0 Authentication on UNIX */
@@ -90,7 +85,7 @@ securid_init(pw, promptp, auth)
     if (AceInitialize() != SD_FALSE)
        return(AUTH_SUCCESS);
 
-    warnx("failed to initialise the ACE API library");
+    warningx("failed to initialise the ACE API library");
     return(AUTH_FATAL);
 }
 
@@ -118,7 +113,7 @@ securid_setup(pw, promptp, auth)
 
     /* Re-initialize SecurID every time. */
     if (SD_Init(sd) != ACM_OK) {
-       warnx("unable to contact the SecurID server");
+       warningx("unable to contact the SecurID server");
        return(AUTH_FATAL);
     }
 
@@ -127,19 +122,19 @@ securid_setup(pw, promptp, auth)
 
     switch (retval) {
         case ACE_UNDEFINED_USERNAME:
-               warnx("invalid username length for SecurID");
+               warningx("invalid username length for SecurID");
                return(AUTH_FATAL);
 
        case ACE_ERR_INVALID_HANDLE:
-               warnx("invalid Authentication Handle for SecurID");
+               warningx("invalid Authentication Handle for SecurID");
                return(AUTH_FATAL);
 
        case ACM_ACCESS_DENIED:
-               warnx("SecurID communication failed");
+               warningx("SecurID communication failed");
                return(AUTH_FATAL);
 
        case ACM_OK:
-               warnx("User ID locked for SecurID Authentication");
+               warningx("User ID locked for SecurID Authentication");
                return(AUTH_SUCCESS);
        }
 }
@@ -171,17 +166,17 @@ securid_verify(pw, pass, auth)
     /* Have ACE verify password */
     switch (SD_Check(*sd, pass, pw->pw_name)) {
        case ACE_UNDEFINED_PASSCODE:
-               warnx("invalid passcode length for SecurID");
+               warningx("invalid passcode length for SecurID");
                rval = AUTH_FATAL;
                break;
 
        case ACE_UNDEFINED_USERNAME:
-               warnx("invalid username length for SecurID");
+               warningx("invalid username length for SecurID");
                rval = AUTH_FATAL;
                break;
 
        case ACE_ERR_INVALID_HANDLE:
-               warnx("invalid Authentication Handle for SecurID");
+               warningx("invalid Authentication Handle for SecurID");
                rval = AUTH_FATAL;
 
        case ACM_ACCESS_DENIED: