Use struct eventlog *evlog, not struct eventlog *details.
This commit is contained in:
@@ -120,9 +120,9 @@ struct eventlog {
|
|||||||
struct json_container;
|
struct json_container;
|
||||||
typedef bool (*eventlog_json_callback_t)(struct json_container *, void *);
|
typedef bool (*eventlog_json_callback_t)(struct json_container *, void *);
|
||||||
|
|
||||||
bool eventlog_accept(const struct eventlog *details, int flags, eventlog_json_callback_t info_cb, void *info);
|
bool eventlog_accept(const struct eventlog *evlog, int flags, eventlog_json_callback_t info_cb, void *info);
|
||||||
bool eventlog_alert(const struct eventlog *details, int flags, struct timespec *alert_time, const char *reason, const char *errstr);
|
bool eventlog_alert(const struct eventlog *evlog, int flags, struct timespec *alert_time, const char *reason, const char *errstr);
|
||||||
bool eventlog_reject(const struct eventlog *details, int flags, const char *reason, eventlog_json_callback_t info_cb, void *info);
|
bool eventlog_reject(const struct eventlog *evlog, int flags, const char *reason, eventlog_json_callback_t info_cb, void *info);
|
||||||
bool eventlog_store_json(struct json_container *json, const struct eventlog *evlog);
|
bool eventlog_store_json(struct json_container *json, const struct eventlog *evlog);
|
||||||
size_t eventlog_writeln(FILE *fp, char *line, size_t len, size_t maxlen);
|
size_t eventlog_writeln(FILE *fp, char *line, size_t len, size_t maxlen);
|
||||||
void eventlog_free(struct eventlog *evlog);
|
void eventlog_free(struct eventlog *evlog);
|
||||||
|
@@ -105,10 +105,10 @@ static struct eventlog_config evl_conf = {
|
|||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
new_logline(int flags, const char *message, const char *errstr,
|
new_logline(int flags, const char *message, const char *errstr,
|
||||||
const struct eventlog *details)
|
const struct eventlog *evlog)
|
||||||
{
|
{
|
||||||
char *line = NULL, *evstr = NULL;
|
char *line = NULL, *evstr = NULL;
|
||||||
const char *iolog_file = details->iolog_file;
|
const char *iolog_file = evlog->iolog_file;
|
||||||
const char *tty, *tsid = NULL;
|
const char *tty, *tsid = NULL;
|
||||||
char sessid[7];
|
char sessid[7];
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
@@ -143,7 +143,7 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Sudo-format logs use the short form of the ttyname. */
|
/* Sudo-format logs use the short form of the ttyname. */
|
||||||
if ((tty = details->ttyname) != NULL) {
|
if ((tty = evlog->ttyname) != NULL) {
|
||||||
if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
if (strncmp(tty, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
|
||||||
tty += sizeof(_PATH_DEV) - 1;
|
tty += sizeof(_PATH_DEV) - 1;
|
||||||
}
|
}
|
||||||
@@ -155,30 +155,30 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
len += strlen(message) + 3;
|
len += strlen(message) + 3;
|
||||||
if (errstr != NULL)
|
if (errstr != NULL)
|
||||||
len += strlen(errstr) + 3;
|
len += strlen(errstr) + 3;
|
||||||
if (details->submithost != NULL && !evl_conf.omit_hostname)
|
if (evlog->submithost != NULL && !evl_conf.omit_hostname)
|
||||||
len += sizeof(LL_HOST_STR) + 2 + strlen(details->submithost);
|
len += sizeof(LL_HOST_STR) + 2 + strlen(evlog->submithost);
|
||||||
if (tty != NULL)
|
if (tty != NULL)
|
||||||
len += sizeof(LL_TTY_STR) + 2 + strlen(tty);
|
len += sizeof(LL_TTY_STR) + 2 + strlen(tty);
|
||||||
if (details->runchroot != NULL)
|
if (evlog->runchroot != NULL)
|
||||||
len += sizeof(LL_CHROOT_STR) + 2 + strlen(details->runchroot);
|
len += sizeof(LL_CHROOT_STR) + 2 + strlen(evlog->runchroot);
|
||||||
if (details->runcwd != NULL)
|
if (evlog->runcwd != NULL)
|
||||||
len += sizeof(LL_CWD_STR) + 2 + strlen(details->runcwd);
|
len += sizeof(LL_CWD_STR) + 2 + strlen(evlog->runcwd);
|
||||||
if (details->runuser != NULL)
|
if (evlog->runuser != NULL)
|
||||||
len += sizeof(LL_USER_STR) + 2 + strlen(details->runuser);
|
len += sizeof(LL_USER_STR) + 2 + strlen(evlog->runuser);
|
||||||
if (details->rungroup != NULL)
|
if (evlog->rungroup != NULL)
|
||||||
len += sizeof(LL_GROUP_STR) + 2 + strlen(details->rungroup);
|
len += sizeof(LL_GROUP_STR) + 2 + strlen(evlog->rungroup);
|
||||||
if (tsid != NULL)
|
if (tsid != NULL)
|
||||||
len += sizeof(LL_TSID_STR) + 2 + strlen(tsid);
|
len += sizeof(LL_TSID_STR) + 2 + strlen(tsid);
|
||||||
if (details->env_add != NULL) {
|
if (evlog->env_add != NULL) {
|
||||||
size_t evlen = 0;
|
size_t evlen = 0;
|
||||||
char * const *ep;
|
char * const *ep;
|
||||||
|
|
||||||
for (ep = details->env_add; *ep != NULL; ep++)
|
for (ep = evlog->env_add; *ep != NULL; ep++)
|
||||||
evlen += strlen(*ep) + 1;
|
evlen += strlen(*ep) + 1;
|
||||||
if (evlen != 0) {
|
if (evlen != 0) {
|
||||||
if ((evstr = malloc(evlen)) == NULL)
|
if ((evstr = malloc(evlen)) == NULL)
|
||||||
goto oom;
|
goto oom;
|
||||||
ep = details->env_add;
|
ep = evlog->env_add;
|
||||||
if (strlcpy(evstr, *ep, evlen) >= evlen)
|
if (strlcpy(evstr, *ep, evlen) >= evlen)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
while (*++ep != NULL) {
|
while (*++ep != NULL) {
|
||||||
@@ -189,10 +189,10 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
len += sizeof(LL_ENV_STR) + 2 + evlen;
|
len += sizeof(LL_ENV_STR) + 2 + evlen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (details->command != NULL) {
|
if (evlog->command != NULL) {
|
||||||
len += sizeof(LL_CMND_STR) - 1 + strlen(details->command);
|
len += sizeof(LL_CMND_STR) - 1 + strlen(evlog->command);
|
||||||
for (i = 1; details->argv[i] != NULL; i++)
|
for (i = 1; evlog->argv[i] != NULL; i++)
|
||||||
len += strlen(details->argv[i]) + 1;
|
len += strlen(evlog->argv[i]) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -212,9 +212,9 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
if (details->submithost != NULL && !evl_conf.omit_hostname) {
|
if (evlog->submithost != NULL && !evl_conf.omit_hostname) {
|
||||||
if (strlcat(line, LL_HOST_STR, len) >= len ||
|
if (strlcat(line, LL_HOST_STR, len) >= len ||
|
||||||
strlcat(line, details->submithost, len) >= len ||
|
strlcat(line, evlog->submithost, len) >= len ||
|
||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
@@ -224,27 +224,27 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
if (details->runchroot != NULL) {
|
if (evlog->runchroot != NULL) {
|
||||||
if (strlcat(line, LL_CHROOT_STR, len) >= len ||
|
if (strlcat(line, LL_CHROOT_STR, len) >= len ||
|
||||||
strlcat(line, details->runchroot, len) >= len ||
|
strlcat(line, evlog->runchroot, len) >= len ||
|
||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
if (details->runcwd != NULL) {
|
if (evlog->runcwd != NULL) {
|
||||||
if (strlcat(line, LL_CWD_STR, len) >= len ||
|
if (strlcat(line, LL_CWD_STR, len) >= len ||
|
||||||
strlcat(line, details->runcwd, len) >= len ||
|
strlcat(line, evlog->runcwd, len) >= len ||
|
||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
if (details->runuser != NULL) {
|
if (evlog->runuser != NULL) {
|
||||||
if (strlcat(line, LL_USER_STR, len) >= len ||
|
if (strlcat(line, LL_USER_STR, len) >= len ||
|
||||||
strlcat(line, details->runuser, len) >= len ||
|
strlcat(line, evlog->runuser, len) >= len ||
|
||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
if (details->rungroup != NULL) {
|
if (evlog->rungroup != NULL) {
|
||||||
if (strlcat(line, LL_GROUP_STR, len) >= len ||
|
if (strlcat(line, LL_GROUP_STR, len) >= len ||
|
||||||
strlcat(line, details->rungroup, len) >= len ||
|
strlcat(line, evlog->rungroup, len) >= len ||
|
||||||
strlcat(line, " ; ", len) >= len)
|
strlcat(line, " ; ", len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
@@ -262,14 +262,14 @@ new_logline(int flags, const char *message, const char *errstr,
|
|||||||
free(evstr);
|
free(evstr);
|
||||||
evstr = NULL;
|
evstr = NULL;
|
||||||
}
|
}
|
||||||
if (details->command != NULL) {
|
if (evlog->command != NULL) {
|
||||||
if (strlcat(line, LL_CMND_STR, len) >= len)
|
if (strlcat(line, LL_CMND_STR, len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
if (strlcat(line, details->command, len) >= len)
|
if (strlcat(line, evlog->command, len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
for (i = 1; details->argv[i] != NULL; i++) {
|
for (i = 1; evlog->argv[i] != NULL; i++) {
|
||||||
if (strlcat(line, " ", len) >= len ||
|
if (strlcat(line, " ", len) >= len ||
|
||||||
strlcat(line, details->argv[i], len) >= len)
|
strlcat(line, evlog->argv[i], len) >= len)
|
||||||
goto toobig;
|
goto toobig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -755,7 +755,7 @@ default_json_cb(struct json_container *json, void *v)
|
|||||||
|
|
||||||
static char *
|
static char *
|
||||||
format_json(int event_type, const char *reason, const char *errstr,
|
format_json(int event_type, const char *reason, const char *errstr,
|
||||||
const struct eventlog *details, const struct timespec *event_time,
|
const struct eventlog *evlog, const struct timespec *event_time,
|
||||||
eventlog_json_callback_t info_cb, void *info, bool compact)
|
eventlog_json_callback_t info_cb, void *info, bool compact)
|
||||||
{
|
{
|
||||||
const char *type_str;
|
const char *type_str;
|
||||||
@@ -767,7 +767,7 @@ format_json(int event_type, const char *reason, const char *errstr,
|
|||||||
|
|
||||||
if (info_cb == NULL) {
|
if (info_cb == NULL) {
|
||||||
info_cb = default_json_cb;
|
info_cb = default_json_cb;
|
||||||
info = (void *)details;
|
info = (void *)evlog;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sudo_gettime_real(&now) == -1) {
|
if (sudo_gettime_real(&now) == -1) {
|
||||||
@@ -830,14 +830,14 @@ format_json(int event_type, const char *reason, const char *errstr,
|
|||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (details->iolog_path != NULL) {
|
if (evlog->iolog_path != NULL) {
|
||||||
json_value.type = JSON_STRING;
|
json_value.type = JSON_STRING;
|
||||||
json_value.u.string = details->iolog_path;
|
json_value.u.string = evlog->iolog_path;
|
||||||
if (!sudo_json_add_value(&json, "iolog_path", &json_value))
|
if (!sudo_json_add_value(&json, "iolog_path", &json_value))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write log details. */
|
/* Write log info. */
|
||||||
if (!info_cb(&json, info))
|
if (!info_cb(&json, info))
|
||||||
goto bad;
|
goto bad;
|
||||||
|
|
||||||
@@ -857,7 +857,7 @@ bad:
|
|||||||
* message into parts if it is longer than syslog_maxlen.
|
* message into parts if it is longer than syslog_maxlen.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
do_syslog_sudo(int pri, char *logline, const struct eventlog *details)
|
do_syslog_sudo(int pri, char *logline, const struct eventlog *evlog)
|
||||||
{
|
{
|
||||||
size_t len, maxlen;
|
size_t len, maxlen;
|
||||||
char *p, *tmp, save;
|
char *p, *tmp, save;
|
||||||
@@ -871,7 +871,7 @@ do_syslog_sudo(int pri, char *logline, const struct eventlog *details)
|
|||||||
*/
|
*/
|
||||||
fmt = _("%8s : %s");
|
fmt = _("%8s : %s");
|
||||||
maxlen = evl_conf.syslog_maxlen -
|
maxlen = evl_conf.syslog_maxlen -
|
||||||
(strlen(fmt) - 5 + strlen(details->submituser));
|
(strlen(fmt) - 5 + strlen(evlog->submituser));
|
||||||
for (p = logline; *p != '\0'; ) {
|
for (p = logline; *p != '\0'; ) {
|
||||||
len = strlen(p);
|
len = strlen(p);
|
||||||
if (len > maxlen) {
|
if (len > maxlen) {
|
||||||
@@ -887,7 +887,7 @@ do_syslog_sudo(int pri, char *logline, const struct eventlog *details)
|
|||||||
save = *tmp;
|
save = *tmp;
|
||||||
*tmp = '\0';
|
*tmp = '\0';
|
||||||
|
|
||||||
syslog(pri, fmt, details->submituser, p);
|
syslog(pri, fmt, evlog->submituser, p);
|
||||||
|
|
||||||
*tmp = save; /* restore saved character */
|
*tmp = save; /* restore saved character */
|
||||||
|
|
||||||
@@ -895,12 +895,12 @@ do_syslog_sudo(int pri, char *logline, const struct eventlog *details)
|
|||||||
for (p = tmp; *p == ' '; p++)
|
for (p = tmp; *p == ' '; p++)
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
syslog(pri, fmt, details->submituser, p);
|
syslog(pri, fmt, evlog->submituser, p);
|
||||||
p += len;
|
p += len;
|
||||||
}
|
}
|
||||||
fmt = _("%8s : (command continued) %s");
|
fmt = _("%8s : (command continued) %s");
|
||||||
maxlen = evl_conf.syslog_maxlen -
|
maxlen = evl_conf.syslog_maxlen -
|
||||||
(strlen(fmt) - 5 + strlen(details->submituser));
|
(strlen(fmt) - 5 + strlen(evlog->submituser));
|
||||||
}
|
}
|
||||||
evl_conf.close_log(EVLOG_SYSLOG, NULL);
|
evl_conf.close_log(EVLOG_SYSLOG, NULL);
|
||||||
|
|
||||||
@@ -909,7 +909,7 @@ do_syslog_sudo(int pri, char *logline, const struct eventlog *details)
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_syslog_json(int pri, int event_type, const char *reason,
|
do_syslog_json(int pri, int event_type, const char *reason,
|
||||||
const char *errstr, const struct eventlog *details,
|
const char *errstr, const struct eventlog *evlog,
|
||||||
const struct timespec *event_time,
|
const struct timespec *event_time,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
@@ -917,7 +917,7 @@ do_syslog_json(int pri, int event_type, const char *reason,
|
|||||||
debug_decl(do_syslog_json, SUDO_DEBUG_UTIL);
|
debug_decl(do_syslog_json, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
/* Format as a compact JSON message (no newlines) */
|
/* Format as a compact JSON message (no newlines) */
|
||||||
json_str = format_json(event_type, reason, errstr, details, event_time,
|
json_str = format_json(event_type, reason, errstr, evlog, event_time,
|
||||||
info_cb, info, true);
|
info_cb, info, true);
|
||||||
if (json_str == NULL)
|
if (json_str == NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
@@ -936,7 +936,7 @@ do_syslog_json(int pri, int event_type, const char *reason,
|
|||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
do_syslog(int event_type, int flags, const char *reason, const char *errstr,
|
do_syslog(int event_type, int flags, const char *reason, const char *errstr,
|
||||||
const struct eventlog *details, const struct timespec *event_time,
|
const struct eventlog *evlog, const struct timespec *event_time,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
char *logline = NULL;
|
char *logline = NULL;
|
||||||
@@ -946,12 +946,12 @@ do_syslog(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
|
|
||||||
/* Sudo format logs and mailed logs use the same log line format. */
|
/* Sudo format logs and mailed logs use the same log line format. */
|
||||||
if (evl_conf.format == EVLOG_SUDO || ISSET(flags, EVLOG_MAIL)) {
|
if (evl_conf.format == EVLOG_SUDO || ISSET(flags, EVLOG_MAIL)) {
|
||||||
logline = new_logline(flags, reason, errstr, details);
|
logline = new_logline(flags, reason, errstr, evlog);
|
||||||
if (logline == NULL)
|
if (logline == NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
if (ISSET(flags, EVLOG_MAIL)) {
|
if (ISSET(flags, EVLOG_MAIL)) {
|
||||||
if (!send_mail(details, "%s", logline)) {
|
if (!send_mail(evlog, "%s", logline)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"unable to mail log line");
|
"unable to mail log line");
|
||||||
}
|
}
|
||||||
@@ -986,10 +986,10 @@ do_syslog(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
|
|
||||||
switch (evl_conf.format) {
|
switch (evl_conf.format) {
|
||||||
case EVLOG_SUDO:
|
case EVLOG_SUDO:
|
||||||
ret = do_syslog_sudo(pri, logline, details);
|
ret = do_syslog_sudo(pri, logline, evlog);
|
||||||
break;
|
break;
|
||||||
case EVLOG_JSON:
|
case EVLOG_JSON:
|
||||||
ret = do_syslog_json(pri, event_type, reason, errstr, details,
|
ret = do_syslog_json(pri, event_type, reason, errstr, evlog,
|
||||||
event_time, info_cb, info);
|
event_time, info_cb, info);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1003,7 +1003,7 @@ do_syslog(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_logfile_sudo(const char *logline, const struct eventlog *details)
|
do_logfile_sudo(const char *logline, const struct eventlog *evlog)
|
||||||
{
|
{
|
||||||
const char *timefmt = evl_conf.time_fmt;
|
const char *timefmt = evl_conf.time_fmt;
|
||||||
const char *logfile = evl_conf.logpath;
|
const char *logfile = evl_conf.logpath;
|
||||||
@@ -1023,7 +1023,7 @@ do_logfile_sudo(const char *logline, const struct eventlog *details)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((timeptr = localtime(&details->submit_time.tv_sec)) != NULL) {
|
if ((timeptr = localtime(&evlog->submit_time.tv_sec)) != NULL) {
|
||||||
/* strftime() does not guarantee to NUL-terminate so we must check. */
|
/* strftime() does not guarantee to NUL-terminate so we must check. */
|
||||||
timebuf[sizeof(timebuf) - 1] = '\0';
|
timebuf[sizeof(timebuf) - 1] = '\0';
|
||||||
if (strftime(timebuf, sizeof(timebuf), timefmt, timeptr) != 0 &&
|
if (strftime(timebuf, sizeof(timebuf), timefmt, timeptr) != 0 &&
|
||||||
@@ -1032,7 +1032,7 @@ do_logfile_sudo(const char *logline, const struct eventlog *details)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = asprintf(&full_line, "%s : %s : %s",
|
len = asprintf(&full_line, "%s : %s : %s",
|
||||||
timestr ? timestr : "invalid date", details->submituser, logline);
|
timestr ? timestr : "invalid date", evlog->submituser, logline);
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
sudo_warnx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
|
||||||
goto done;
|
goto done;
|
||||||
@@ -1054,7 +1054,7 @@ done:
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_logfile_json(int event_type, const char *reason, const char *errstr,
|
do_logfile_json(int event_type, const char *reason, const char *errstr,
|
||||||
const struct eventlog *details, const struct timespec *event_time,
|
const struct eventlog *evlog, const struct timespec *event_time,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
const char *logfile = evl_conf.logpath;
|
const char *logfile = evl_conf.logpath;
|
||||||
@@ -1067,7 +1067,7 @@ do_logfile_json(int event_type, const char *reason, const char *errstr,
|
|||||||
if ((fp = evl_conf.open_log(EVLOG_FILE, logfile)) == NULL)
|
if ((fp = evl_conf.open_log(EVLOG_FILE, logfile)) == NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
json_str = format_json(event_type, reason, errstr, details, event_time,
|
json_str = format_json(event_type, reason, errstr, evlog, event_time,
|
||||||
info_cb, info, false);
|
info_cb, info, false);
|
||||||
if (json_str == NULL)
|
if (json_str == NULL)
|
||||||
goto done;
|
goto done;
|
||||||
@@ -1111,7 +1111,7 @@ done:
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
do_logfile(int event_type, int flags, const char *reason, const char *errstr,
|
do_logfile(int event_type, int flags, const char *reason, const char *errstr,
|
||||||
const struct eventlog *details, const struct timespec *event_time,
|
const struct eventlog *evlog, const struct timespec *event_time,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@@ -1120,12 +1120,12 @@ do_logfile(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
|
|
||||||
/* Sudo format logs and mailed logs use the same log line format. */
|
/* Sudo format logs and mailed logs use the same log line format. */
|
||||||
if (evl_conf.format == EVLOG_SUDO || ISSET(flags, EVLOG_MAIL)) {
|
if (evl_conf.format == EVLOG_SUDO || ISSET(flags, EVLOG_MAIL)) {
|
||||||
logline = new_logline(flags, reason, errstr, details);
|
logline = new_logline(flags, reason, errstr, evlog);
|
||||||
if (logline == NULL)
|
if (logline == NULL)
|
||||||
debug_return_bool(false);
|
debug_return_bool(false);
|
||||||
|
|
||||||
if (ISSET(flags, EVLOG_MAIL)) {
|
if (ISSET(flags, EVLOG_MAIL)) {
|
||||||
if (!send_mail(details, "%s", logline)) {
|
if (!send_mail(evlog, "%s", logline)) {
|
||||||
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
|
||||||
"unable to mail log line");
|
"unable to mail log line");
|
||||||
}
|
}
|
||||||
@@ -1138,10 +1138,10 @@ do_logfile(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
|
|
||||||
switch (evl_conf.format) {
|
switch (evl_conf.format) {
|
||||||
case EVLOG_SUDO:
|
case EVLOG_SUDO:
|
||||||
ret = do_logfile_sudo(logline ? logline : reason, details);
|
ret = do_logfile_sudo(logline ? logline : reason, evlog);
|
||||||
break;
|
break;
|
||||||
case EVLOG_JSON:
|
case EVLOG_JSON:
|
||||||
ret = do_logfile_json(event_type, reason, errstr, details,
|
ret = do_logfile_json(event_type, reason, errstr, evlog,
|
||||||
event_time, info_cb, info);
|
event_time, info_cb, info);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1155,7 +1155,7 @@ do_logfile(int event_type, int flags, const char *reason, const char *errstr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
eventlog_accept(const struct eventlog *details, int flags,
|
eventlog_accept(const struct eventlog *evlog, int flags,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
const int log_type = evl_conf.type;
|
const int log_type = evl_conf.type;
|
||||||
@@ -1166,14 +1166,14 @@ eventlog_accept(const struct eventlog *details, int flags,
|
|||||||
debug_return_bool(true);
|
debug_return_bool(true);
|
||||||
|
|
||||||
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
||||||
if (!do_syslog(EVLOG_ACCEPT, flags, NULL, NULL, details,
|
if (!do_syslog(EVLOG_ACCEPT, flags, NULL, NULL, evlog,
|
||||||
&details->submit_time, info_cb, info))
|
&evlog->submit_time, info_cb, info))
|
||||||
ret = false;
|
ret = false;
|
||||||
CLR(flags, EVLOG_MAIL);
|
CLR(flags, EVLOG_MAIL);
|
||||||
}
|
}
|
||||||
if (ISSET(log_type, EVLOG_FILE)) {
|
if (ISSET(log_type, EVLOG_FILE)) {
|
||||||
if (!do_logfile(EVLOG_ACCEPT, flags, NULL, NULL, details,
|
if (!do_logfile(EVLOG_ACCEPT, flags, NULL, NULL, evlog,
|
||||||
&details->submit_time, info_cb, info))
|
&evlog->submit_time, info_cb, info))
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1181,7 +1181,7 @@ eventlog_accept(const struct eventlog *details, int flags,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
eventlog_reject(const struct eventlog *details, int flags, const char *reason,
|
eventlog_reject(const struct eventlog *evlog, int flags, const char *reason,
|
||||||
eventlog_json_callback_t info_cb, void *info)
|
eventlog_json_callback_t info_cb, void *info)
|
||||||
{
|
{
|
||||||
const int log_type = evl_conf.type;
|
const int log_type = evl_conf.type;
|
||||||
@@ -1189,14 +1189,14 @@ eventlog_reject(const struct eventlog *details, int flags, const char *reason,
|
|||||||
debug_decl(log_reject, SUDO_DEBUG_UTIL);
|
debug_decl(log_reject, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
||||||
if (!do_syslog(EVLOG_REJECT, flags, reason, NULL, details,
|
if (!do_syslog(EVLOG_REJECT, flags, reason, NULL, evlog,
|
||||||
&details->submit_time, info_cb, info))
|
&evlog->submit_time, info_cb, info))
|
||||||
ret = false;
|
ret = false;
|
||||||
CLR(flags, EVLOG_MAIL);
|
CLR(flags, EVLOG_MAIL);
|
||||||
}
|
}
|
||||||
if (ISSET(log_type, EVLOG_FILE)) {
|
if (ISSET(log_type, EVLOG_FILE)) {
|
||||||
if (!do_logfile(EVLOG_REJECT, flags, reason, NULL, details,
|
if (!do_logfile(EVLOG_REJECT, flags, reason, NULL, evlog,
|
||||||
&details->submit_time, info_cb, info))
|
&evlog->submit_time, info_cb, info))
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1204,7 +1204,7 @@ eventlog_reject(const struct eventlog *details, int flags, const char *reason,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
eventlog_alert(const struct eventlog *details, int flags,
|
eventlog_alert(const struct eventlog *evlog, int flags,
|
||||||
struct timespec *alert_time, const char *reason, const char *errstr)
|
struct timespec *alert_time, const char *reason, const char *errstr)
|
||||||
{
|
{
|
||||||
const int log_type = evl_conf.type;
|
const int log_type = evl_conf.type;
|
||||||
@@ -1212,13 +1212,13 @@ eventlog_alert(const struct eventlog *details, int flags,
|
|||||||
debug_decl(log_alert, SUDO_DEBUG_UTIL);
|
debug_decl(log_alert, SUDO_DEBUG_UTIL);
|
||||||
|
|
||||||
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
if (ISSET(log_type, EVLOG_SYSLOG)) {
|
||||||
if (!do_syslog(EVLOG_ALERT, flags, reason, errstr, details, alert_time,
|
if (!do_syslog(EVLOG_ALERT, flags, reason, errstr, evlog, alert_time,
|
||||||
NULL, NULL))
|
NULL, NULL))
|
||||||
ret = false;
|
ret = false;
|
||||||
CLR(flags, EVLOG_MAIL);
|
CLR(flags, EVLOG_MAIL);
|
||||||
}
|
}
|
||||||
if (ISSET(log_type, EVLOG_FILE)) {
|
if (ISSET(log_type, EVLOG_FILE)) {
|
||||||
if (!do_logfile(EVLOG_ALERT, flags, reason, errstr, details, alert_time,
|
if (!do_logfile(EVLOG_ALERT, flags, reason, errstr, evlog, alert_time,
|
||||||
NULL, NULL))
|
NULL, NULL))
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user