--- sudo-1.6.7p5/env.c.orig 2003-05-06 04:32:22 +0000 +++ sudo-1.6.7p5/env.c 2005-06-21 16:12:48 +0000 @@ -99,6 +99,7 @@ */ static const char *initial_badenv_table[] = { "IFS", + "CDPATH", "LOCALDOMAIN", "RES_OPTIONS", "HOSTALIASES", @@ -296,6 +297,13 @@ rebuild_env(sudo_mode, envp) /* Pull in vars we want to keep from the old environment. */ for (ep = envp; *ep; ep++) { keepit = 0; + + /* Skip variables with values beginning with () (bash functions) */ + if ((cp = strchr(*ep, '=')) != NULL) { + if (strncmp(cp, "=() ", 3) == 0) + continue; + } + for (cur = def_list(I_ENV_KEEP); cur; cur = cur->next) { len = strlen(cur->value); /* Deal with '*' wildcard */ @@ -370,6 +378,12 @@ rebuild_env(sudo_mode, envp) for (ep = envp; *ep; ep++) { okvar = 1; + /* Skip variables with values beginning with () (bash functions) */ + if ((cp = strchr(*ep, '=')) != NULL) { + if (strncmp(cp, "=() ", 3) == 0) + continue; + } + /* Skip anything listed in env_delete. */ for (cur = def_list(I_ENV_DELETE); cur && okvar; cur = cur->next) { len = strlen(cur->value);