1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) Heiko Schlittermann 2016
7 * See the file NOTICE for conditions of use and distribution.
12 /* The cleanup_environment() function is used during the startup phase
13 of the Exim process, right after reading the configurations main
14 part, before any expansions take place. It retains the environment
15 variables we trust (via the keep_environment option) and allows to
16 set additional variables (via add_environment).
18 Returns: TRUE if successful
25 if (!keep_environment || *keep_environment == '\0')
27 else if (Ustrcmp(keep_environment, "*") != 0)
30 if (environ) for (p = USS environ; *p; /* see below */)
32 uschar *name = string_copyn(*p, US Ustrchr(*p, '=') - *p);
34 if (OK != match_isinlist(name, CUSS &keep_environment,
35 0, NULL, NULL, MCL_NOEXPAND, FALSE, NULL))
36 if (unsetenv(CS name) < 0) return FALSE;
48 const uschar* envlist = add_environment;
49 while ((p = string_nextinlist(&envlist, &sep, NULL, 0)))