From: Todd C. Miller Date: Fri, 19 Nov 2004 17:24:20 +0000 (+0000) Subject: Add local error/warning functions like err/warn but that call an additional X-Git-Tag: SUDO_1_7_0~803 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a414762c4e9ae854b53ded4c90e199b52659275b;p=sudo Add local error/warning functions like err/warn but that call an additional cleanup routine in the error case. This means we no longer need to compile a special version of alloc.o for visudo. --- diff --git a/auth/fwtk.c b/auth/fwtk.c index 3e5f3c9bf..0ecc48d6d 100644 --- a/auth/fwtk.c +++ b/auth/fwtk.c @@ -41,11 +41,6 @@ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_ERR_H -# include -#else -# include "emul/err.h" -#endif /* HAVE_ERR_H */ #include #include @@ -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)); diff --git a/auth/rfc1938.c b/auth/rfc1938.c index 8df5de128..ddf13f017 100644 --- a/auth/rfc1938.c +++ b/auth/rfc1938.c @@ -42,11 +42,6 @@ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_ERR_H -# include -#else -# include "emul/err.h" -#endif /* HAVE_ERR_H */ #include #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); diff --git a/auth/securid.c b/auth/securid.c index 8158bfbcc..fe88a698a 100644 --- a/auth/securid.c +++ b/auth/securid.c @@ -44,11 +44,6 @@ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_ERR_H -# include -#else -# include "emul/err.h" -#endif /* HAVE_ERR_H */ #include #include @@ -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); } } diff --git a/auth/securid5.c b/auth/securid5.c index 8935c4118..f5cd7aefc 100644 --- a/auth/securid5.c +++ b/auth/securid5.c @@ -45,11 +45,6 @@ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ -#ifdef HAVE_ERR_H -# include -#else -# include "emul/err.h" -#endif /* HAVE_ERR_H */ #include /* 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: