]> granicus.if.org Git - sudo/commitdiff
strip exported bash functions from the environment.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 11 Nov 2004 16:20:59 +0000 (16:20 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 11 Nov 2004 16:20:59 +0000 (16:20 +0000)
env.c

diff --git a/env.c b/env.c
index 9a0b4a20421cf8e287c0fb27cd38055f0fa8356e..7f4389f35b7648f73735a8d210c73654089caaad 100644 (file)
--- a/env.c
+++ b/env.c
@@ -323,6 +323,13 @@ rebuild_env(envp, sudo_mode, noexec)
        /* 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_env_keep; cur; cur = cur->next) {
                len = strlen(cur->value);
                /* Deal with '*' wildcard */
@@ -405,6 +412,12 @@ rebuild_env(envp, sudo_mode, noexec)
        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_env_delete; cur && okvar; cur = cur->next) {
                len = strlen(cur->value);