From: Todd C. Miller Date: Tue, 7 Sep 2010 21:00:32 +0000 (-0400) Subject: Set NewArgv[0] to the name of the pseudo-command we are running. X-Git-Tag: SUDO_1_7_5~171 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5d6812ab311a10828d42af34a498a9930d9a2ace;p=sudo Set NewArgv[0] to the name of the pseudo-command we are running. Fixes a problem with "sudo -l" when auditing is enabled and the user is not allowed to run any commands on the host. Adapted from a patch from Daniel Kopecek. --HG-- branch : 1.7 --- diff --git a/sudo.c b/sudo.c index 151532f17..0d314882f 100644 --- a/sudo.c +++ b/sudo.c @@ -698,14 +698,10 @@ init_vars(envp) set_perms(PERM_ROOT); /* - * If we were given the '-e', '-i' or '-s' options we need to redo - * NewArgv and NewArgc. + * If in shell or edit mode, or if running a pseudo-command + * such as "list", we need to redo NewArgv and NewArgc. */ - if (ISSET(sudo_mode, MODE_EDIT)) { - NewArgv--; - NewArgc++; - NewArgv[0] = "sudoedit"; - } else if (ISSET(sudo_mode, MODE_SHELL)) { + if (ISSET(sudo_mode, MODE_SHELL)) { char **av; /* Allocate an extra slot for execve() failure (ENOEXEC). */ @@ -747,6 +743,10 @@ init_vars(envp) } av[++NewArgc] = NULL; NewArgv = av; + } else if (ISSET(sudo_mode, MODE_EDIT) || NewArgc == 0) { + NewArgv--; + NewArgc++; + NewArgv[0] = user_cmnd; } }