X-Git-Url: https://git.exim.org/users/jgh/exim.git/blobdiff_plain/de78e2d59e3924238648b8fb363a1412fa9e499d..bc3c7bb7d4aba3e563434e5627fe1f2176aa18c0:/src/src/exim.c diff --git a/src/src/exim.c b/src/src/exim.c index 28617a510..d6f2d4aac 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -1760,7 +1760,6 @@ regex_whitelisted_macro = for (i = 0; i < REGEX_VARS; i++) regex_vars[i] = NULL; - /* If the program is called as "mailq" treat it as equivalent to "exim -bp"; this seems to be a generally accepted convention, since one finds symbolic links called "mailq" in standard OS configurations. */ @@ -3744,8 +3743,19 @@ if (running_in_test_harness) smtputf8_advertise_hosts = NULL; is a failure. It leaves the configuration file open so that the subsequent configuration data for delivery can be read if needed. */ +/* To be safe: change the working directory to /. */ +if (Uchdir("/") < 0) + { + perror("exim: chdir `/': "); + exit(EXIT_FAILURE); + } + readconf_main(); +if (cleanup_environment() == FALSE) + log_write(0, LOG_PANIC_DIE, "Can't cleanup environment"); + + /* If an action on specific messages is requested, or if a daemon or queue runner is being started, we need to know if Exim was called by an admin user. This is the case if the real user is root or exim, or if the real group is @@ -3900,20 +3910,23 @@ if (log_oneline) temporary files are created; Exim doesn't use these (apart from when delivering to MBX mailboxes), but called libraries such as DBM libraries may require them. If TMPDIR is found in the environment, reset it to the value defined in the -TMPDIR macro, if this macro is defined. */ +EXIM_TMPDIR macro, if this macro is defined. For backward compatibility this +macro may be called TMPDIR in old "Local/Makefile"s. It's converted to +EXIM_TMPDIR by the build scripts. +*/ -#ifdef TMPDIR +#ifdef EXIM_TMPDIR { uschar **p; - for (p = USS environ; *p != NULL; p++) + if (environ) for (p = USS environ; *p != NULL; p++) { if (Ustrncmp(*p, "TMPDIR=", 7) == 0 && - Ustrcmp(*p+7, TMPDIR) != 0) + Ustrcmp(*p+7, EXIM_TMPDIR) != 0) { - uschar *newp = malloc(Ustrlen(TMPDIR) + 8); - sprintf(CS newp, "TMPDIR=%s", TMPDIR); + uschar *newp = malloc(Ustrlen(EXIM_TMPDIR) + 8); + sprintf(CS newp, "TMPDIR=%s", EXIM_TMPDIR); *p = newp; - DEBUG(D_any) debug_printf("reset TMPDIR=%s in environment\n", TMPDIR); + DEBUG(D_any) debug_printf("reset TMPDIR=%s in environment\n", EXIM_TMPDIR); } } } @@ -3945,10 +3958,10 @@ else uschar **new; uschar **newp; int count = 0; - while (*p++ != NULL) count++; + if (environ) while (*p++ != NULL) count++; if (envtz == NULL) count++; newp = new = malloc(sizeof(uschar *) * (count + 1)); - for (p = USS environ; *p != NULL; p++) + if (environ) for (p = USS environ; *p != NULL; p++) { if (Ustrncmp(*p, "TZ=", 3) == 0) continue; *newp++ = *p; @@ -4538,7 +4551,8 @@ if (list_options) (Ustrcmp(argv[i], "router") == 0 || Ustrcmp(argv[i], "transport") == 0 || Ustrcmp(argv[i], "authenticator") == 0 || - Ustrcmp(argv[i], "macro") == 0)) + Ustrcmp(argv[i], "macro") == 0 || + Ustrcmp(argv[i], "environment") == 0)) { readconf_print(argv[i+1], argv[i], flag_n); i++; @@ -4556,6 +4570,12 @@ if (list_config) } +/* Initialise subsystems as required */ +#ifndef DISABLE_DKIM +dkim_exim_init(); +#endif + + /* Handle a request to deliver one or more messages that are already on the queue. Values of msg_action other than MSG_DELIVER and MSG_LOAD are dealt with above. MSG_LOAD is handled with -be (which is the only time it applies) below.