From: Todd C. Miller Date: Tue, 19 Jun 2007 16:53:09 +0000 (+0000) Subject: Fix preserving of variables in env_keep. X-Git-Tag: SUDO_1_7_0~542 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=363a2f2593c30b127ba84dc69f7c0c06b3b35e6b;p=sudo Fix preserving of variables in env_keep. --- diff --git a/env.c b/env.c index e5ee1cbeb..7e295e056 100644 --- 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)