Skip to content

Commit 726b646

Browse files
committed
struct eventlog: rename argv/env to runargv/runenv.
This matches the JSON logs.
1 parent c7a61a9 commit 726b646

13 files changed

Lines changed: 67 additions & 65 deletions

File tree

include/sudo_eventlog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ struct eventlog {
110110
char *submituser;
111111
char *submitgroup;
112112
char *ttyname;
113-
char **argv;
113+
char **runargv;
114+
char **runenv;
114115
char **env_add;
115-
char **envp;
116116
struct timespec submit_time;
117117
struct timespec iolog_offset;
118118
struct timespec run_time;

lib/eventlog/eventlog.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,24 @@ new_logline(int event_type, int flags, struct eventlog_args *args,
191191
}
192192
sudo_lbuf_append(lbuf, " ; ");
193193
}
194-
if (evlog->command != NULL && evlog->argv != NULL) {
194+
if (evlog->command != NULL && evlog->runargv != NULL) {
195195
/* Command plus argv. */
196196
sudo_lbuf_append_esc(lbuf, LBUF_ESC_CNTRL|LBUF_ESC_BLANK,
197197
"COMMAND=%s", evlog->command);
198-
if (evlog->argv[0] != NULL) {
199-
for (i = 1; evlog->argv[i] != NULL; i++) {
198+
if (evlog->runargv[0] != NULL) {
199+
for (i = 1; evlog->runargv[i] != NULL; i++) {
200200
sudo_lbuf_append(lbuf, " ");
201-
if (strchr(evlog->argv[i], ' ') != NULL) {
201+
if (strchr(evlog->runargv[i], ' ') != NULL) {
202202
/* Wrap args containing spaces in single quotes. */
203203
sudo_lbuf_append(lbuf, "'");
204204
sudo_lbuf_append_esc(lbuf, LBUF_ESC_CNTRL|LBUF_ESC_QUOTE,
205-
"%s", evlog->argv[i]);
205+
"%s", evlog->runargv[i]);
206206
sudo_lbuf_append(lbuf, "'");
207207
} else {
208208
/* Escape quotes here too for consistency. */
209209
sudo_lbuf_append_esc(lbuf,
210210
LBUF_ESC_CNTRL|LBUF_ESC_BLANK|LBUF_ESC_QUOTE,
211-
"%s", evlog->argv[i]);
211+
"%s", evlog->runargv[i]);
212212
}
213213
}
214214
}
@@ -733,10 +733,10 @@ eventlog_store_json(struct json_container *jsonc, const struct eventlog *evlog)
733733
if (!sudo_json_add_value(jsonc, "lines", &json_value))
734734
goto oom;
735735

736-
if (evlog->argv != NULL) {
736+
if (evlog->runargv != NULL) {
737737
if (!sudo_json_open_array(jsonc, "runargv"))
738738
goto oom;
739-
for (i = 0; (cp = evlog->argv[i]) != NULL; i++) {
739+
for (i = 0; (cp = evlog->runargv[i]) != NULL; i++) {
740740
json_value.type = JSON_STRING;
741741
json_value.u.string = cp;
742742
if (!sudo_json_add_value(jsonc, NULL, &json_value))
@@ -746,10 +746,10 @@ eventlog_store_json(struct json_container *jsonc, const struct eventlog *evlog)
746746
goto oom;
747747
}
748748

749-
if (evlog->envp != NULL) {
749+
if (evlog->runenv != NULL) {
750750
if (!sudo_json_open_array(jsonc, "runenv"))
751751
goto oom;
752-
for (i = 0; (cp = evlog->envp[i]) != NULL; i++) {
752+
for (i = 0; (cp = evlog->runenv[i]) != NULL; i++) {
753753
json_value.type = JSON_STRING;
754754
json_value.u.string = cp;
755755
if (!sudo_json_add_value(jsonc, NULL, &json_value))

lib/eventlog/eventlog_free.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ eventlog_free(struct eventlog *evlog)
5959
free(evlog->submituser);
6060
free(evlog->submitgroup);
6161
free(evlog->ttyname);
62-
if (evlog->argv != NULL) {
63-
for (i = 0; evlog->argv[i] != NULL; i++)
64-
free(evlog->argv[i]);
65-
free(evlog->argv);
62+
if (evlog->runargv != NULL) {
63+
for (i = 0; evlog->runargv[i] != NULL; i++)
64+
free(evlog->runargv[i]);
65+
free(evlog->runargv);
6666
}
67-
if (evlog->envp != NULL) {
68-
for (i = 0; evlog->envp[i] != NULL; i++)
69-
free(evlog->envp[i]);
70-
free(evlog->envp);
67+
if (evlog->runenv != NULL) {
68+
for (i = 0; evlog->runenv[i] != NULL; i++)
69+
free(evlog->runenv[i]);
70+
free(evlog->runenv);
7171
}
7272
if (evlog->env_add != NULL) {
7373
for (i = 0; evlog->env_add[i] != NULL; i++)

lib/eventlog/parse_json.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ json_store_runargv(struct json_item *item, struct eventlog *evlog)
201201
size_t i;
202202
debug_decl(json_store_runargv, SUDO_DEBUG_UTIL);
203203

204-
if (evlog->argv != NULL) {
205-
for (i = 0; evlog->argv[i] != NULL; i++)
206-
free(evlog->argv[i]);
207-
free(evlog->argv);
204+
if (evlog->runargv != NULL) {
205+
for (i = 0; evlog->runargv[i] != NULL; i++)
206+
free(evlog->runargv[i]);
207+
free(evlog->runargv);
208208
}
209-
evlog->argv = json_array_to_strvec(&item->u.child);
209+
evlog->runargv = json_array_to_strvec(&item->u.child);
210210

211-
debug_return_bool(evlog->argv != NULL);
211+
debug_return_bool(evlog->runargv != NULL);
212212
}
213213

214214
static bool
@@ -217,14 +217,14 @@ json_store_runenv(struct json_item *item, struct eventlog *evlog)
217217
size_t i;
218218
debug_decl(json_store_runenv, SUDO_DEBUG_UTIL);
219219

220-
if (evlog->envp != NULL) {
221-
for (i = 0; evlog->envp[i] != NULL; i++)
222-
free(evlog->envp[i]);
223-
free(evlog->envp);
220+
if (evlog->runenv != NULL) {
221+
for (i = 0; evlog->runenv[i] != NULL; i++)
222+
free(evlog->runenv[i]);
223+
free(evlog->runenv);
224224
}
225-
evlog->envp = json_array_to_strvec(&item->u.child);
225+
evlog->runenv = json_array_to_strvec(&item->u.child);
226226

227-
debug_return_bool(evlog->envp != NULL);
227+
debug_return_bool(evlog->runenv != NULL);
228228
}
229229

230230
static bool

lib/iolog/iolog_loginfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ iolog_write_info_file_legacy(int dfd, struct eventlog *evlog)
131131
evlog->lines, evlog->columns,
132132
evlog->cwd ? evlog->cwd : "unknown");
133133
fputs(evlog->command ? evlog->command : "unknown", fp);
134-
for (av = evlog->argv + 1; *av != NULL; av++) {
134+
for (av = evlog->runargv + 1; *av != NULL; av++) {
135135
fputc(' ', fp);
136136
fputs(*av, fp);
137137
}

logsrvd/iolog_writer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ evlog_new(TimeSpec *submit_time, InfoMessage **info_msgs, size_t infolen,
205205
case 'r':
206206
if (strcmp(key, "runargv") == 0) {
207207
if (type_matches(info, source, INFO_MESSAGE__VALUE_STRLISTVAL)) {
208-
evlog->argv = strlist_copy(info->u.strlistval);
209-
if (evlog->argv == NULL)
208+
evlog->runargv = strlist_copy(info->u.strlistval);
209+
if (evlog->runargv == NULL)
210210
goto bad;
211211
}
212212
continue;
@@ -233,8 +233,8 @@ evlog_new(TimeSpec *submit_time, InfoMessage **info_msgs, size_t infolen,
233233
}
234234
if (strcmp(key, "runenv") == 0) {
235235
if (type_matches(info, source, INFO_MESSAGE__VALUE_STRLISTVAL)) {
236-
evlog->envp = strlist_copy(info->u.strlistval);
237-
if (evlog->envp == NULL)
236+
evlog->runenv = strlist_copy(info->u.strlistval);
237+
if (evlog->runenv == NULL)
238238
goto bad;
239239
}
240240
continue;

logsrvd/sendlog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ fmt_runargv(const struct eventlog *evlog)
507507
debug_decl(fmt_runargv, SUDO_DEBUG_UTIL);
508508

509509
/* We may have runargv from the log.json file. */
510-
if (evlog->argv != NULL && evlog->argv[0] != NULL) {
511-
/* Convert evlog->argv into a StringList. */
512-
runargv = vec_to_stringlist(evlog->argv);
510+
if (evlog->runargv != NULL && evlog->runargv[0] != NULL) {
511+
/* Convert evlog->runargv into a StringList. */
512+
runargv = vec_to_stringlist(evlog->runargv);
513513
if (runargv != NULL) {
514514
/* Make sure command doesn't include arguments. */
515515
char *cp = strchr(evlog->command, ' ');
@@ -533,10 +533,10 @@ fmt_runenv(const struct eventlog *evlog)
533533
debug_decl(fmt_runenv, SUDO_DEBUG_UTIL);
534534

535535
/* Only present in log.json. */
536-
if (evlog->envp == NULL || evlog->envp[0] == NULL)
536+
if (evlog->runenv == NULL || evlog->runenv[0] == NULL)
537537
debug_return_ptr(NULL);
538538

539-
debug_return_ptr(vec_to_stringlist(evlog->envp));
539+
debug_return_ptr(vec_to_stringlist(evlog->runenv));
540540
}
541541

542542
static InfoMessage **

plugins/sudoers/iolog.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ free_iolog_details(void)
197197

198198
if (iolog_details.evlog != NULL) {
199199
/* We only make a shallow copy of argv and envp. */
200-
free(iolog_details.evlog->argv);
201-
iolog_details.evlog->argv = NULL;
202-
free(iolog_details.evlog->envp);
203-
iolog_details.evlog->envp = NULL;
200+
free(iolog_details.evlog->runargv);
201+
iolog_details.evlog->runargv = NULL;
202+
free(iolog_details.evlog->runenv);
203+
iolog_details.evlog->runenv = NULL;
204204
eventlog_free(iolog_details.evlog);
205205
}
206206
str_list_free(iolog_details.log_servers);
@@ -601,13 +601,13 @@ iolog_deserialize_info(struct log_details *details, char * const user_info[],
601601
}
602602

603603
if (argv != NULL) {
604-
evlog->argv = copy_vector_shallow(argv);
605-
if (evlog->argv == NULL)
604+
evlog->runargv = copy_vector_shallow(argv);
605+
if (evlog->runargv == NULL)
606606
goto oom;
607607
}
608608
if (user_env != NULL) {
609-
evlog->envp = copy_vector_shallow(user_env);
610-
if (evlog->envp == NULL)
609+
evlog->runenv = copy_vector_shallow(user_env);
610+
if (evlog->runenv == NULL)
611611
goto oom;
612612
}
613613

plugins/sudoers/log_client.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,20 +823,20 @@ fmt_info_messages(struct client_closure *closure, struct eventlog *evlog,
823823
debug_decl(fmt_info_messages, SUDOERS_DEBUG_UTIL);
824824

825825
/* Convert NULL-terminated vectors to StringList. */
826-
if (evlog->argv != NULL) {
826+
if (evlog->runargv != NULL) {
827827
if ((runargv = malloc(sizeof(*runargv))) == NULL)
828828
goto bad;
829829
info_message__string_list__init(runargv);
830-
runargv->strings = evlog->argv;
830+
runargv->strings = evlog->runargv;
831831
while (runargv->strings[runargv->n_strings] != NULL)
832832
runargv->n_strings++;
833833
}
834834

835-
if (evlog->envp != NULL) {
835+
if (evlog->runenv != NULL) {
836836
if ((runenv = malloc(sizeof(*runenv))) == NULL)
837837
goto bad;
838838
info_message__string_list__init(runenv);
839-
runenv->strings = evlog->envp;
839+
runenv->strings = evlog->runenv;
840840
while (runenv->strings[runenv->n_strings] != NULL)
841841
runenv->n_strings++;
842842
}

plugins/sudoers/logging.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,9 +1001,9 @@ sudoers_to_eventlog(const struct sudoers_context *ctx, struct eventlog *evlog,
10011001
if (grp != NULL)
10021002
evlog->submitgroup = grp->gr_name;
10031003
evlog->ttyname = ctx->user.ttypath;
1004-
evlog->argv = (char **)argv;
1004+
evlog->runargv = (char **)argv;
10051005
evlog->env_add = (char **)ctx->user.env_add;
1006-
evlog->envp = (char **)envp;
1006+
evlog->runenv = (char **)envp;
10071007
evlog->submit_time = ctx->submit_time;
10081008
evlog->lines = ctx->user.lines;
10091009
evlog->columns = ctx->user.cols;

0 commit comments

Comments
 (0)