]> granicus.if.org Git - sudo/commitdiff
Set def_preserve_groups before searching for the command when the -P
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 26 May 2011 16:52:59 +0000 (12:52 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 26 May 2011 16:52:59 +0000 (12:52 -0400)
flag is specified.

plugins/sudoers/sudoers.c

index 45dc2fe4d79912b8ed9afc002fca976e76d8e21c..b7130aa63406efe50283093adaba6c36ff31e89f 100644 (file)
@@ -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 */