Bug 223 - cannot use env_delete with env_reset
cannot use env_delete with env_reset
Status: RESOLVED WONTFIX
Product: Sudo
Classification: Unclassified
Component: Sudo
1.6.8
PC Linux
: low enhancement
Assigned To: Todd C. Miller
http://bugs.debian.org/392321
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-10-11 11:44 MDT by Bdale Garbee
Modified: 2007-06-19 12:29 MDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bdale Garbee 2006-10-11 11:44:42 MDT
Reported by Arnaud Giersch against my Debian package of sudo:

When env_reset is in use, env_delete is currently not honored.  It is
not possible to delete additional environment variables.  For example,
I want to use env_reset but I do not want to keep the locale-related
variables LANG, LANGUAGE, and LC_*.

The patch below causes to the deletion of the variables listed in
env_deleted, even when env_reset is in use.

--- sudo-1.6.8p12.debian/env.c  2006-10-11 10:31:27.000000000 +0200
+++ sudo-1.6.8p12/env.c 2006-10-11 10:30:28.000000000 +0200
@@ -377,6 +377,21 @@
                || !strncmp (*ep, "LC_", 3))
              keepit = 1;
 
+           /* Skip anything listed in env_delete. */
+           for (cur = def_env_delete; cur && keepit; cur = cur->next) {
+               len = strlen(cur->value);
+               /* Deal with '*' wildcard */
+               if (cur->value[len - 1] == '*') {
+                   len--;
+                   iswild = 1;
+               } else
+                   iswild = 0;
+               if (strncmp(cur->value, *ep, len) == 0 &&
+                   (iswild || (*ep)[len] == '=')) {
+                   keepit = 0;
+               }
+           }
+
            /* For SUDO_PS1 -> PS1 conversion. */
            if (strncmp(*ep, "SUDO_PS1=", 8) == 0)
                ps1 = *ep + 5;
Comment 1 Todd C. Miller 2007-06-19 12:29:22 MDT
There's really no need for this in sudo 1.6.9 and higher where you would simply remove things from the env_keep or env_check lists instead.  E.g., for the locale stuff you would do this in 1.6.9 and higher.

Defaults env_check -= "LANG LANGUAGE LINGUAS LC_*"