* Default table of variables to preserve in the environment.
*/
static const char *initial_keepenv_table[] = {
+ "LC_*",
+ "LANG",
+ "LANGUAGE",
"KRB5CCNAME",
"DISPLAY",
"PATH",
didvar = 0;
memset(&env, 0, sizeof(env));
if (def_env_reset) {
- int keepit;
+ int keepit = -1;
/* Pull in vars we want to keep from the old environment. */
for (ep = envp; *ep; ep++) {
continue;
}
- for (cur = def_env_keep; cur; cur = cur->next) {
+ /* Check certain variables for '%' and '/' characters. */
+ for (cur = def_env_check; cur; cur = cur->next) {
len = strlen(cur->value);
/* Deal with '*' wildcard */
if (cur->value[len - 1] == '*') {
iswild = FALSE;
if (strncmp(cur->value, *ep, len) == 0 &&
(iswild || (*ep)[len] == '=')) {
- keepit = TRUE;
+ keepit = !strpbrk(*ep, "/%");
break;
}
}
+ if (keepit == -1) {
+ for (cur = def_env_keep; cur; cur = cur->next) {
+ len = strlen(cur->value);
+ /* Deal with '*' wildcard */
+ if (cur->value[len - 1] == '*') {
+ len--;
+ iswild = TRUE;
+ } else
+ iswild = FALSE;
+ if (strncmp(cur->value, *ep, len) == 0 &&
+ (iswild || (*ep)[len] == '=')) {
+ keepit = TRUE;
+ break;
+ }
+ }
+ }
+
/* For SUDO_PS1 -> PS1 conversion. */
if (strncmp(*ep, "SUDO_PS1=", 8) == 0)
ps1 = *ep + 5;