Skip to content

Commit 22b3206

Browse files
committed
Fix the date written used by the exit record in sudo-format log files
The change to always get the current time when building a struct evlog in sudoers broke the data and time written for exit records. This only affected file-based logs, not syslog. GitHub issue #405.
1 parent f47c880 commit 22b3206

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/eventlog/eventlog.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,7 @@ eventlog_exit(const struct eventlog *evlog, int flags)
14531453
bool ret = true;
14541454
debug_decl(eventlog_exit, SUDO_DEBUG_UTIL);
14551455

1456+
/* We expect evlog->event_time to be the command start time. */
14561457
if (sudo_timespecisset(&evlog->run_time)) {
14571458
sudo_timespecadd(&evlog->event_time, &evlog->run_time, &exit_time);
14581459
args.event_time = &exit_time;

logsrvd/logsrvd_local.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ store_exit_local(ExitMessage *msg, uint8_t *buf, size_t len,
423423
"command exited with %d", msg->exit_value);
424424
}
425425
if (logsrvd_conf_log_exit()) {
426-
if (!eventlog_exit(closure->evlog, flags)) {
426+
if (!eventlog_exit(evlog, flags)) {
427427
closure->errstr = _("error logging exit event");
428428
debug_return_bool(false);
429429
}

plugins/sudoers/logging.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,11 @@ log_exit_status(const struct sudoers_context *ctx, int status)
655655
if (!def_log_exit_status)
656656
SET(evl_flags, EVLOG_MAIL_ONLY);
657657
}
658+
/*
659+
* eventlog_exit() expects event_time to be the command start time,
660+
* not the current time as set by sudoers_to_eventlog().
661+
*/
662+
sudo_timespecsub(&evlog.event_time, &run_time, &evlog.event_time);
658663
evlog.run_time = run_time;
659664
evlog.exit_value = exit_value;
660665
evlog.signal_name = signal_name;

0 commit comments

Comments
 (0)