]> granicus.if.org Git - sudo/commitdiff
Use error() instead of log_fatal()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 28 Mar 2012 17:47:49 +0000 (13:47 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 28 Mar 2012 17:47:49 +0000 (13:47 -0400)
plugins/sudoers/bsm_audit.c

index f30eab433e9b129f958076ee316cae442a8cb2d1..bec1cba98242dd6d6e7d05568e803113b5d0adca 100644 (file)
@@ -31,6 +31,7 @@
 #include <unistd.h>
 
 #include "gettext.h"
+#include "error.h"
 #include "sudo_debug.h"
 #include "bsm_audit.h"
 
@@ -44,8 +45,6 @@
 # define AUDIT_NOT_CONFIGURED  ENOSYS
 #endif
 
-void log_fatal(int flags, const char *fmt, ...) __attribute__((__noreturn__));
-
 static int
 audit_sudo_selected(int sf)
 {
@@ -58,10 +57,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;
@@ -88,7 +87,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)
                debug_return;
@@ -99,9 +98,9 @@ bsm_audit_success(char **exec_args)
        if (!audit_sudo_selected(0))
                debug_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);
@@ -110,24 +109,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"));
        debug_return;
 }
 
@@ -151,43 +150,43 @@ 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)
                        debug_return;
-               log_fatal(0, _("Could not determine audit condition"));
+               error(1, _("Could not determine audit condition"));
        }
        if (au_cond == AUC_NOAUDIT)
                debug_return;
        if (!audit_sudo_selected(1))
                debug_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"));
        debug_return;
 }