Bugzilla – Bug 223
cannot use env_delete with env_reset
Last modified: 2007-06-19 12:29:22 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;
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_*"