From: Todd C. Miller Date: Fri, 30 Mar 2012 18:26:49 +0000 (-0400) Subject: Use error() instead of log_fatal() X-Git-Tag: SUDO_1_7_9p1~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f91c8908fc63f1a40f462686de744d6f67a2786b;p=sudo Use error() instead of log_fatal() --HG-- branch : 1.7 --- diff --git a/bsm_audit.c b/bsm_audit.c index 24a3f64b7..4aebe0316 100644 --- a/bsm_audit.c +++ b/bsm_audit.c @@ -30,6 +30,7 @@ #include #include +#include "error.h" #include "bsm_audit.h" /* @@ -42,8 +43,6 @@ # define AUDIT_NOT_CONFIGURED ENOSYS #endif -void log_fatal(int flags, const char *fmt, ...) __attribute__((__noreturn__)); - static int audit_sudo_selected(int sf) { @@ -55,10 +54,10 @@ audit_sudo_selected(int sf) if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) < 0) { if (errno == ENOSYS) { if (getaudit(&ainfo) < 0) - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); mask = &ainfo.ai_mask; } else - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); } else mask = &ainfo_addr.ai_mask; sorf = (sf == 0) ? AU_PRS_SUCCESS : AU_PRS_FAILURE; @@ -84,7 +83,7 @@ bsm_audit_success(char **exec_args) if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) { if (errno == AUDIT_NOT_CONFIGURED) return; - log_fatal(0, "Could not determine audit condition"); + error(1, "Could not determine audit condition"); } if (au_cond == AUC_NOAUDIT) return; @@ -95,9 +94,9 @@ bsm_audit_success(char **exec_args) if (!audit_sudo_selected(0)) return; if (getauid(&auid) < 0) - log_fatal(0, "getauid failed"); + error(1, "getauid failed"); if ((aufd = au_open()) == -1) - log_fatal(0, "au_open: failed"); + error(1, "au_open: failed"); if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) == 0) { tok = au_to_subject_ex(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo_addr.ai_termid); @@ -106,24 +105,24 @@ bsm_audit_success(char **exec_args) * NB: We should probably watch out for ERANGE here. */ if (getaudit(&ainfo) < 0) - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); tok = au_to_subject(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo.ai_termid); } else - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); if (tok == NULL) - log_fatal(0, "au_to_subject: failed"); + error(1, "au_to_subject: failed"); au_write(aufd, tok); tok = au_to_exec_args(exec_args); if (tok == NULL) - log_fatal(0, "au_to_exec_args: failed"); + error(1, "au_to_exec_args: failed"); au_write(aufd, tok); tok = au_to_return32(0, 0); if (tok == NULL) - log_fatal(0, "au_to_return32: failed"); + error(1, "au_to_return32: failed"); au_write(aufd, tok); if (au_close(aufd, 1, AUE_sudo) == -1) - log_fatal(0, "unable to commit audit record"); + error(1, "unable to commit audit record"); } void @@ -145,42 +144,42 @@ bsm_audit_failure(char **exec_args, char const *const fmt, va_list ap) if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) { if (errno == AUDIT_NOT_CONFIGURED) return; - log_fatal(0, "Could not determine audit condition"); + error(1, "Could not determine audit condition"); } if (au_cond == AUC_NOAUDIT) return; if (!audit_sudo_selected(1)) return; if (getauid(&auid) < 0) - log_fatal(0, "getauid: failed"); + error(1, "getauid: failed"); if ((aufd = au_open()) == -1) - log_fatal(0, "au_open: failed"); + error(1, "au_open: failed"); if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) == 0) { tok = au_to_subject_ex(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo_addr.ai_termid); } else if (errno == ENOSYS) { if (getaudit(&ainfo) < 0) - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); tok = au_to_subject(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo.ai_termid); } else - log_fatal(0, "getaudit: failed"); + error(1, "getaudit: failed"); if (tok == NULL) - log_fatal(0, "au_to_subject: failed"); + error(1, "au_to_subject: failed"); au_write(aufd, tok); tok = au_to_exec_args(exec_args); if (tok == NULL) - log_fatal(0, "au_to_exec_args: failed"); + error(1, "au_to_exec_args: failed"); au_write(aufd, tok); (void) vsnprintf(text, sizeof(text), fmt, ap); tok = au_to_text(text); if (tok == NULL) - log_fatal(0, "au_to_text: failed"); + error(1, "au_to_text: failed"); au_write(aufd, tok); tok = au_to_return32(EPERM, 1); if (tok == NULL) - log_fatal(0, "au_to_return32: failed"); + error(1, "au_to_return32: failed"); au_write(aufd, tok); if (au_close(aufd, 1, AUE_sudo) == -1) - log_fatal(0, "unable to commit audit record"); + error(1, "unable to commit audit record"); }