Skip to content

Commit

Permalink
Rename submit_time -> event_time in struct eventlog.
Browse files Browse the repository at this point in the history
  • Loading branch information
millert committed Nov 23, 2023
1 parent 0e53d5f commit b9275b7
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion include/sudo_eventlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions lib/eventlog/eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ json_add_timestamp(struct json_container *jsonc, const char *name,

/*
* 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
Expand All @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/eventlog/parse_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/iolog/iolog_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions lib/iolog/iolog_loginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 : "",
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions logsrvd/iolog_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions logsrvd/logsrvd_local.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand Down
8 changes: 4 additions & 4 deletions logsrvd/sendlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion plugins/sudoers/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion plugins/sudoers/iolog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/sudoers/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions plugins/sudoers/regress/iolog_plugin/check_iolog_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/sudoers/sudoreplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit b9275b7

Please sign in to comment.