Fix NO_ROOT_MAILER, broken by the eventlog refactor in sudo 1.9.4.

init_eventlog_config() is called immediately after initializing the
Defaults settings, which is before struct sudo_user is setup.  This
adds a call to eventlog_set_mailuid() if NO_ROOT_MAILER is defined
after the invoking user is determined.  Reported by Roman Fiedler.
This commit is contained in:
Todd C. Miller
2021-01-29 05:42:34 -07:00
parent da5c6c6c45
commit e5ad88488d
2 changed files with 5 additions and 6 deletions

View File

@@ -786,11 +786,6 @@ void
init_eventlog_config(void) init_eventlog_config(void)
{ {
int logtype = 0; int logtype = 0;
#ifdef NO_ROOT_MAILER
uid_t mailuid = user_uid;
#else
uid_t mailuid = ROOT_UID;
#endif
debug_decl(init_eventlog_config, SUDOERS_DEBUG_LOGGING); debug_decl(init_eventlog_config, SUDOERS_DEBUG_LOGGING);
if (def_syslog) if (def_syslog)
@@ -805,7 +800,7 @@ init_eventlog_config(void)
eventlog_set_syslog_alertpri(def_syslog_badpri); eventlog_set_syslog_alertpri(def_syslog_badpri);
eventlog_set_syslog_maxlen(def_syslog_maxlen); eventlog_set_syslog_maxlen(def_syslog_maxlen);
eventlog_set_file_maxlen(def_loglinelen); eventlog_set_file_maxlen(def_loglinelen);
eventlog_set_mailuid(mailuid); eventlog_set_mailuid(ROOT_UID);
eventlog_set_omit_hostname(!def_log_host); eventlog_set_omit_hostname(!def_log_host);
eventlog_set_logpath(def_logfile); eventlog_set_logpath(def_logfile);
eventlog_set_time_fmt(def_log_year ? "%h %e %T %Y" : "%h %e %T"); eventlog_set_time_fmt(def_log_year ? "%h %e %T %Y" : "%h %e %T");

View File

@@ -518,6 +518,10 @@ sudoers_policy_deserialize_info(void *v)
/* Some systems support fexecve() which we use for digest matches. */ /* Some systems support fexecve() which we use for digest matches. */
cmnd_fd = -1; cmnd_fd = -1;
#ifdef NO_ROOT_MAILER
eventlog_set_mailuid(user_uid);
#endif
/* Dump settings and user info (XXX - plugin args) */ /* Dump settings and user info (XXX - plugin args) */
for (cur = info->settings; *cur != NULL; cur++) for (cur = info->settings; *cur != NULL; cur++)
sudo_debug_printf(SUDO_DEBUG_INFO, "settings: %s", *cur); sudo_debug_printf(SUDO_DEBUG_INFO, "settings: %s", *cur);