From: Todd C. Miller Date: Thu, 26 May 2011 16:52:59 +0000 (-0400) Subject: Set def_preserve_groups before searching for the command when the -P X-Git-Tag: SUDO_1_8_2~106^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=67e8e5653472032977751e4bb179ce45561ba6ea;p=sudo Set def_preserve_groups before searching for the command when the -P flag is specified. --- diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 45dc2fe4d..b7130aa63 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -345,6 +345,10 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], NewArgv[0] = estrdup(runas_pw->pw_shell); } + /* If given the -P option, set the "preserve_groups" flag. */ + if (ISSET(sudo_mode, MODE_PRESERVE_GROUPS)) + def_preserve_groups = TRUE; + /* Find command in path */ cmnd_status = set_cmnd(sudo_mode); if (cmnd_status == -1) { @@ -406,10 +410,6 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], pw_delref(pw); } - /* If given the -P option, set the "preserve_groups" flag. */ - if (ISSET(sudo_mode, MODE_PRESERVE_GROUPS)) - def_preserve_groups = TRUE; - /* If no command line args and "shell_noargs" is not set, error out. */ if (ISSET(sudo_mode, MODE_IMPLIED_SHELL) && !def_shell_noargs) { rval = -2; /* usage error */