Fix preserving of variables in env_keep.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 19 Jun 2007 16:53:09 +0000 (16:53 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 19 Jun 2007 16:53:09 +0000 (16:53 +0000)
env.c

diff --git a/env.c b/env.c
index e5ee1cbeb3b446e8af38f1c9801e2095ef5c44d4..7e295e056d4fa9783f6cafdfa8ab60bf00ce7530 100644 (file)
--- a/env.c
+++ b/env.c
@@ -310,11 +310,9 @@ rebuild_env(envp, sudo_mode, noexec)
     didvar = 0;
     memset(&env, 0, sizeof(env));
     if (def_env_reset) {
-       int keepit = -1;
-
        /* Pull in vars we want to keep from the old environment. */
        for (ep = envp; *ep; ep++) {
-           keepit = FALSE;
+           int keepit = -1;
 
            /* Skip variables with values beginning with () (bash functions) */
            if ((cp = strchr(*ep, '=')) != NULL) {
@@ -354,6 +352,8 @@ rebuild_env(envp, sudo_mode, noexec)
                    }
                }
            }
+           if (keepit == -1)
+               keepit = FALSE;
 
            /* For SUDO_PS1 -> PS1 conversion. */
            if (strncmp(*ep, "SUDO_PS1=", 8) == 0)