Rename cwd -> submitcwd to match man page.

This commit is contained in:
Todd C. Miller
2019-11-05 15:18:07 -07:00
parent 98ce89ee80
commit 73031bbb55
2 changed files with 49 additions and 32 deletions

View File

@@ -181,20 +181,6 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
}
continue;
}
if (strcmp(key, "cwd") == 0) {
if (has_strval(info)) {
if ((details->cwd = strdup(info->strval)) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
} else {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"cwd specified but not a string");
}
continue;
}
break;
case 'l':
if (strcmp(key, "lines") == 0) {
@@ -253,9 +239,9 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
}
break;
case 's':
if (strcmp(key, "submithost") == 0) {
if (strcmp(key, "submitcwd") == 0) {
if (has_strval(info)) {
if ((details->submithost = strdup(info->strval)) == NULL) {
if ((details->cwd = strdup(info->strval)) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
@@ -263,7 +249,7 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
}
} else {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"submithost specified but not a string");
"submitcwd specified but not a string");
}
continue;
}
@@ -281,6 +267,20 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
}
continue;
}
if (strcmp(key, "submithost") == 0) {
if (has_strval(info)) {
if ((details->submithost = strdup(info->strval)) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
} else {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"submithost specified but not a string");
}
continue;
}
if (strcmp(key, "submituser") == 0) {
if (has_strval(info)) {
if ((details->submituser = strdup(info->strval)) == NULL) {
@@ -315,16 +315,6 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
}
}
/* TODO: make submitgroup required */
if (details->submitgroup == NULL) {
if ((details->submitgroup = strdup("unknown")) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
}
/* Check for required settings */
if (details->submituser == NULL) {
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
@@ -347,6 +337,33 @@ iolog_details_fill(struct iolog_details *details, TimeSpec *submit_time,
goto done;
}
/* Other settings that must exist for event logging. */
if (details->cwd == NULL) {
if ((details->cwd = strdup("unknown")) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
}
if (details->submitgroup == NULL) {
/* TODO: make submitgroup required */
if ((details->submitgroup = strdup("unknown")) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
}
if (details->ttyname == NULL) {
if ((details->ttyname = strdup("unknown")) == NULL) {
sudo_debug_printf(
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO,
"strdup");
goto done;
}
}
ret = true;
done:

View File

@@ -347,11 +347,6 @@ fmt_accept_message(struct client_closure *closure)
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL;
n++;
accept_msg.info_msgs[n]->key = "cwd";
accept_msg.info_msgs[n]->strval = log_info->cwd;
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL;
n++;
accept_msg.info_msgs[n]->key = "lines";
accept_msg.info_msgs[n]->numval = log_info->lines;
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_NUMVAL;
@@ -374,6 +369,11 @@ fmt_accept_message(struct client_closure *closure)
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL;
n++;
accept_msg.info_msgs[n]->key = "submitcwd";
accept_msg.info_msgs[n]->strval = log_info->cwd;
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL;
n++;
accept_msg.info_msgs[n]->key = "submithost";
accept_msg.info_msgs[n]->strval = hostname;
accept_msg.info_msgs[n]->value_case = INFO_MESSAGE__VALUE_STRVAL;