Prepend "list " to the command logged when "sudo -l command" is

used to make it clear that the command was listed, not run.
This commit is contained in:
Todd C. Miller
2011-01-24 15:39:09 -05:00
parent 1f5c1dda14
commit 51515c6c01

View File

@@ -630,7 +630,10 @@ new_logline(const char *message, int serrno)
len += sizeof(LL_ENV_STR) + 2 + evlen; len += sizeof(LL_ENV_STR) + 2 + evlen;
} }
if (user_cmnd != NULL) { if (user_cmnd != NULL) {
/* Note: we log "sudo -l command arg ..." as "list command arg ..." */
len += sizeof(LL_CMND_STR) - 1 + strlen(user_cmnd); len += sizeof(LL_CMND_STR) - 1 + strlen(user_cmnd);
if (ISSET(sudo_mode, MODE_CHECK))
len += sizeof("list ") - 1;
if (user_args != NULL) if (user_args != NULL)
len += strlen(user_args) + 1; len += strlen(user_args) + 1;
} }
@@ -685,8 +688,11 @@ new_logline(const char *message, int serrno)
efree(evstr); efree(evstr);
} }
if (user_cmnd != NULL) { if (user_cmnd != NULL) {
if (strlcat(line, LL_CMND_STR, len) >= len || if (strlcat(line, LL_CMND_STR, len) >= len)
strlcat(line, user_cmnd, len) >= len) goto toobig;
if (ISSET(sudo_mode, MODE_CHECK) && strlcat(line, "list ", len) >= len)
goto toobig;
if (strlcat(line, user_cmnd, len) >= len)
goto toobig; goto toobig;
if (user_args != NULL) { if (user_args != NULL) {
if (strlcat(line, " ", len) >= len || if (strlcat(line, " ", len) >= len ||