From b9275b7eab1e7f287f9f0df25cbf0c80e2fb144c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 23 Nov 2023 09:08:04 -0500 Subject: [PATCH] Rename submit_time -> event_time in struct eventlog. --- include/sudo_eventlog.h | 2 +- lib/eventlog/eventlog.c | 10 +++++----- lib/eventlog/parse_json.c | 2 +- lib/iolog/iolog_legacy.c | 2 +- lib/iolog/iolog_loginfo.c | 6 +++--- logsrvd/iolog_writer.c | 4 ++-- logsrvd/logsrvd_local.c | 4 ++-- logsrvd/sendlog.c | 8 ++++---- plugins/sudoers/audit.c | 2 +- plugins/sudoers/iolog.c | 2 +- plugins/sudoers/logging.c | 4 ++-- .../sudoers/regress/iolog_plugin/check_iolog_plugin.c | 6 +++--- plugins/sudoers/sudoreplay.c | 6 +++--- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/include/sudo_eventlog.h b/include/sudo_eventlog.h index d19a095dd..8f5a40f69 100644 --- a/include/sudo_eventlog.h +++ b/include/sudo_eventlog.h @@ -114,7 +114,7 @@ struct eventlog { char **runargv; char **runenv; char **env_add; - struct timespec submit_time; + struct timespec event_time; struct timespec iolog_offset; struct timespec run_time; int exit_value; diff --git a/lib/eventlog/eventlog.c b/lib/eventlog/eventlog.c index ab2722772..668770d9e 100644 --- a/lib/eventlog/eventlog.c +++ b/lib/eventlog/eventlog.c @@ -620,7 +620,7 @@ oom: /* * Store the contents of struct eventlog as JSON. - * The submit_time and iolog_path members are not stored, they should + * The event_time and iolog_path members are not stored, they should * be stored and formatted by the caller. */ bool @@ -638,7 +638,7 @@ eventlog_store_json(struct json_container *jsonc, const struct eventlog *evlog) /* * The most important values are written first in case * the log record gets truncated. - * Note: submit_time and iolog_path are not stored here. + * Note: event_time and iolog_path are not stored here. */ json_value.type = JSON_STRING; @@ -1317,7 +1317,7 @@ eventlog_accept(const struct eventlog *evlog, int flags, bool ret = true; debug_decl(eventlog_accept, SUDO_DEBUG_UTIL); - args.event_time = &evlog->submit_time; + args.event_time = &evlog->event_time; args.json_info_cb = info_cb; args.json_info = info; @@ -1345,7 +1345,7 @@ eventlog_reject(const struct eventlog *evlog, int flags, const char *reason, debug_decl(eventlog_reject, SUDO_DEBUG_UTIL); args.reason = reason; - args.event_time = &evlog->submit_time; + args.event_time = &evlog->event_time; args.json_info_cb = info_cb; args.json_info = info; @@ -1444,7 +1444,7 @@ eventlog_exit(const struct eventlog *evlog, int flags) debug_decl(eventlog_exit, SUDO_DEBUG_UTIL); if (sudo_timespecisset(&evlog->run_time)) { - sudo_timespecadd(&evlog->submit_time, &evlog->run_time, &exit_time); + sudo_timespecadd(&evlog->event_time, &evlog->run_time, &exit_time); args.event_time = &exit_time; } diff --git a/lib/eventlog/parse_json.c b/lib/eventlog/parse_json.c index 9b5a1683a..6796e10f5 100644 --- a/lib/eventlog/parse_json.c +++ b/lib/eventlog/parse_json.c @@ -424,7 +424,7 @@ json_store_run_time(struct json_item *item, struct eventlog *evlog) static bool json_store_timestamp(struct json_item *item, struct eventlog *evlog) { - return json_store_timespec(item, &evlog->submit_time); + return json_store_timespec(item, &evlog->event_time); } static bool diff --git a/lib/iolog/iolog_legacy.c b/lib/iolog/iolog_legacy.c index 5ebe537d2..63ed627af 100644 --- a/lib/iolog/iolog_legacy.c +++ b/lib/iolog/iolog_legacy.c @@ -84,7 +84,7 @@ iolog_parse_loginfo_legacy(FILE *fp, const char *iolog_dir, goto done; } *ep = '\0'; - evlog->submit_time.tv_sec = + evlog->event_time.tv_sec = (time_t)sudo_strtonum(cp, 0, TIME_T_MAX, &errstr); if (errstr != NULL) { sudo_warn(U_("%s: time stamp %s: %s"), iolog_dir, cp, errstr); diff --git a/lib/iolog/iolog_loginfo.c b/lib/iolog/iolog_loginfo.c index 3527cceaa..c234684bf 100644 --- a/lib/iolog/iolog_loginfo.c +++ b/lib/iolog/iolog_loginfo.c @@ -123,7 +123,7 @@ iolog_write_info_file_legacy(int dfd, struct eventlog *evlog) } fprintf(fp, "%lld:%s:%s:%s:%s:%d:%d\n%s\n", - (long long)evlog->submit_time.tv_sec, + (long long)evlog->event_time.tv_sec, evlog->submituser ? evlog->submituser : "unknown", evlog->runuser ? evlog->runuser : RUNAS_DEFAULT, evlog->rungroup ? evlog->rungroup : "", @@ -168,12 +168,12 @@ iolog_write_info_file_json(int dfd, struct eventlog *evlog) goto oom; json_value.type = JSON_NUMBER; - json_value.u.number = evlog->submit_time.tv_sec; + json_value.u.number = evlog->event_time.tv_sec; if (!sudo_json_add_value(&jsonc, "seconds", &json_value)) goto oom; json_value.type = JSON_NUMBER; - json_value.u.number = evlog->submit_time.tv_nsec; + json_value.u.number = evlog->event_time.tv_nsec; if (!sudo_json_add_value(&jsonc, "nanoseconds", &json_value)) goto oom; diff --git a/logsrvd/iolog_writer.c b/logsrvd/iolog_writer.c index 940bd48b0..99ac0b592 100644 --- a/logsrvd/iolog_writer.c +++ b/logsrvd/iolog_writer.c @@ -150,8 +150,8 @@ evlog_new(TimeSpec *submit_time, InfoMessage **info_msgs, size_t infolen, /* Submit time. */ if (submit_time != NULL) { - evlog->submit_time.tv_sec = (time_t)submit_time->tv_sec; - evlog->submit_time.tv_nsec = (long)submit_time->tv_nsec; + evlog->event_time.tv_sec = (time_t)submit_time->tv_sec; + evlog->event_time.tv_nsec = (long)submit_time->tv_nsec; } /* Default values */ diff --git a/logsrvd/logsrvd_local.c b/logsrvd/logsrvd_local.c index 8096d97dd..024ae7cfa 100644 --- a/logsrvd/logsrvd_local.c +++ b/logsrvd/logsrvd_local.c @@ -220,7 +220,7 @@ store_accept_local(AcceptMessage *msg, uint8_t *buf, size_t len, evlog->iolog_file = evlog->iolog_path + (closure->evlog->iolog_file - closure->evlog->iolog_path); } - sudo_timespecsub(&evlog->submit_time, &closure->evlog->submit_time, + sudo_timespecsub(&evlog->event_time, &closure->evlog->event_time, &evlog->iolog_offset); } @@ -283,7 +283,7 @@ store_reject_local(RejectMessage *msg, uint8_t *buf, size_t len, evlog->iolog_file = evlog->iolog_path + (closure->evlog->iolog_file - closure->evlog->iolog_path); } - sudo_timespecsub(&evlog->submit_time, &closure->evlog->submit_time, + sudo_timespecsub(&evlog->event_time, &closure->evlog->event_time, &evlog->iolog_offset); } diff --git a/logsrvd/sendlog.c b/logsrvd/sendlog.c index 0ebc2ad2e..063880190 100644 --- a/logsrvd/sendlog.c +++ b/logsrvd/sendlog.c @@ -691,8 +691,8 @@ fmt_reject_message(struct client_closure *closure) } /* Sudo I/O logs only store start time in seconds. */ - tv.tv_sec = (int64_t)closure->evlog->submit_time.tv_sec; - tv.tv_nsec = (int32_t)closure->evlog->submit_time.tv_nsec; + tv.tv_sec = (int64_t)closure->evlog->event_time.tv_sec; + tv.tv_nsec = (int32_t)closure->evlog->event_time.tv_nsec; reject_msg.submit_time = &tv; /* Why the command was rejected. */ @@ -750,8 +750,8 @@ fmt_accept_message(struct client_closure *closure) } /* Sudo I/O logs only store start time in seconds. */ - tv.tv_sec = (int64_t)closure->evlog->submit_time.tv_sec; - tv.tv_nsec = (int32_t)closure->evlog->submit_time.tv_nsec; + tv.tv_sec = (int64_t)closure->evlog->event_time.tv_sec; + tv.tv_nsec = (int32_t)closure->evlog->event_time.tv_nsec; accept_msg.submit_time = &tv; /* Client will send IoBuffer messages. */ diff --git a/plugins/sudoers/audit.c b/plugins/sudoers/audit.c index 3cccdcc98..da45c92b2 100644 --- a/plugins/sudoers/audit.c +++ b/plugins/sudoers/audit.c @@ -447,7 +447,7 @@ sudoers_audit_error(const char *plugin_name, unsigned int plugin_type, } audit_to_eventlog(ctx, &evlog, command_info, ctx->runas.argv, NULL, NULL); - if (!eventlog_alert(&evlog, 0, &evlog.submit_time, message, NULL)) + if (!eventlog_alert(&evlog, 0, &evlog.event_time, message, NULL)) ret = false; if (!log_server_alert(ctx, &evlog, message, NULL)) diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 08c6e3175..fa9d89640 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -314,7 +314,7 @@ iolog_deserialize_info(struct log_details *details, char * const user_info[], evlog->columns = 80; evlog->runuid = ROOT_UID; evlog->rungid = 0; - sudo_gettime_real(&evlog->submit_time); + sudo_gettime_real(&evlog->event_time); for (cur = user_info; *cur != NULL; cur++) { switch (**cur) { diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index 31587b2a6..ea9643ceb 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -741,7 +741,7 @@ vlog_warning(const struct sudoers_context *ctx, unsigned int flags, } sudoers_to_eventlog(ctx, &evlog, ctx->runas.cmnd, ctx->runas.argv, NULL, ctx->uuid_str); - if (!eventlog_alert(&evlog, evl_flags, &evlog.submit_time, message, errstr)) + if (!eventlog_alert(&evlog, evl_flags, &evlog.event_time, message, errstr)) ret = false; if (!log_server_alert(ctx, &evlog, message, errstr)) ret = false; @@ -1005,7 +1005,7 @@ sudoers_to_eventlog(const struct sudoers_context *ctx, struct eventlog *evlog, evlog->env_add = (char **)ctx->user.env_add; evlog->runenv = (char **)runenv; evlog->submitenv = (char **)ctx->user.envp; - if (sudo_gettime_real(&evlog->submit_time) == -1) { + if (sudo_gettime_real(&evlog->event_time) == -1) { sudo_warn("%s", U_("unable to get time of day")); } evlog->lines = ctx->user.lines; diff --git a/plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c b/plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c index 991c30ce7..fb0ac67a5 100644 --- a/plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c +++ b/plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c @@ -144,9 +144,9 @@ validate_iolog_info(const char *log_dir, bool legacy) return false; } - if (evlog->submit_time.tv_sec < now - 10 || evlog->submit_time.tv_sec > now + 10) { - sudo_warnx("bad submit_time: want %lld got %lld", (long long)now, - (long long)evlog->submit_time.tv_sec); + if (evlog->event_time.tv_sec < now - 10 || evlog->event_time.tv_sec > now + 10) { + sudo_warnx("bad event_time: want %lld got %lld", (long long)now, + (long long)evlog->event_time.tv_sec); return false; } diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index 8d1e43ace..c5b3abc63 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -1411,10 +1411,10 @@ match_expr(struct search_node_list *head, struct eventlog *evlog, bool last_matc free(tofree); break; case ST_FROMDATE: - res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, >=); + res = sudo_timespeccmp(&evlog->event_time, &sn->u.tstamp, >=); break; case ST_TODATE: - res = sudo_timespeccmp(&evlog->submit_time, &sn->u.tstamp, <=); + res = sudo_timespeccmp(&evlog->event_time, &sn->u.tstamp, <=); break; default: sudo_fatalx(U_("unknown search type %d"), sn->type); @@ -1450,7 +1450,7 @@ list_session(struct sudo_lbuf *lbuf, char *log_dir, regex_t *re, if (!STAILQ_EMPTY(&search_expr) && !match_expr(&search_expr, evlog, true)) goto done; - timestr = get_timestr(evlog->submit_time.tv_sec, 1); + timestr = get_timestr(evlog->event_time.tv_sec, 1); sudo_lbuf_append_esc(lbuf, LBUF_ESC_CNTRL, "%s : %s : ", timestr ? timestr : "invalid date", evlog->submituser);