]> granicus.if.org Git - sudo/commitdiff
Add support for '*' in env_keep when not resetting the environment
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 12 Nov 2001 04:51:57 +0000 (04:51 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 12 Nov 2001 04:51:57 +0000 (04:51 +0000)
(ie: the normal case).

env.c

diff --git a/env.c b/env.c
index 5c020457a6e33975defbb441f6dabe95748f0230..0027a4ccea11c1bd0a3129a1b07e3ff8823b2dc7 100644 (file)
--- a/env.c
+++ b/env.c
@@ -399,7 +399,14 @@ rebuild_env(sudo_mode, envp)
            if (env_keep) {
                for (ek = env_keep; *ek; ek++) {
                    eklen = strlen(*ek);
-                   if (strncmp(*ek, *ep, eklen) == 0 && (*ep)[eklen] == '=') {
+                   /* Deal with '*' wildcard */
+                   if ((*ek)[eklen - 1] == '*') {
+                       eklen--;
+                       iswild = 1;
+                   } else
+                       iswild = 0;
+                   if (strncmp(*ek, *ep, eklen) == 0 &&
+                       (iswild || (*ep)[eklen] == '=')) {
                        okvar = 1;
                        break;
                    }