From 35d26ae34fac9f9463f295379a3e6d1ffec9e248 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 27 Jul 2011 12:11:33 -0400 Subject: [PATCH] Don't try to audit failure if the runas user does not exist. We don't have the user's command at this point so there is nothing to audit. Add a NULL check in audit_success() and audit_failure() just to be on the safe side. --- plugins/sudoers/audit.c | 8 +++++++- plugins/sudoers/sudoers.c | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/sudoers/audit.c b/plugins/sudoers/audit.c index 2cb113083..c3d35a279 100644 --- a/plugins/sudoers/audit.c +++ b/plugins/sudoers/audit.c @@ -41,6 +41,9 @@ void audit_success(char *exec_args[]) { + if (exec_args == NULL) + return; + #ifdef HAVE_BSM_AUDIT bsm_audit_success(exec_args); #endif @@ -50,10 +53,13 @@ audit_success(char *exec_args[]) } void -audit_failure(char **exec_args, char const *const fmt, ...) +audit_failure(char *exec_args[], char const *const fmt, ...) { va_list ap; + if (exec_args == NULL) + return; + va_start(ap, fmt); #ifdef HAVE_BSM_AUDIT bsm_audit_failure(exec_args, fmt, ap); diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index db897d5f2..2cc3d8bab 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -1066,10 +1066,8 @@ set_runaspw(char *user) if ((runas_pw = sudo_getpwuid(atoi(user + 1))) == NULL) runas_pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0); } else { - if ((runas_pw = sudo_getpwnam(user)) == NULL) { - audit_failure(NewArgv, _("unknown user: %s"), user); + if ((runas_pw = sudo_getpwnam(user)) == NULL) log_error(NO_MAIL|MSG_ONLY, _("unknown user: %s"), user); - } } } -- 2.40.0