From: Jeremy Harris Date: Mon, 23 May 2016 16:21:29 +0000 (+0100) Subject: fix queue_name tracking across exec X-Git-Tag: exim-4_88_RC1~84^2~6 X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e37f8a84f5374b0d03676a65018b00e972ed47c6;p=exim.git fix queue_name tracking across exec --- diff --git a/src/src/child.c b/src/src/child.c index 36d192e9a..7f5b90929 100644 --- a/src/src/child.c +++ b/src/src/child.c @@ -72,9 +72,9 @@ child_exec_exim(int exec_type, BOOL kill_v, int *pcount, BOOL minimal, { int first_special = -1; int n = 0; -int extra = (pcount != NULL)? *pcount : 0; +int extra = pcount ? *pcount : 0; uschar **argv = - store_get((extra + acount + MAX_CLMACROS + 16) * sizeof(char *)); + store_get((extra + acount + MAX_CLMACROS + 18) * sizeof(char *)); /* In all case, the list starts out with the path, any macros, and a changed config file. */ @@ -113,6 +113,11 @@ if (!minimal) if (synchronous_delivery) argv[n++] = US"-odi"; if (connection_max_messages >= 0) argv[n++] = string_sprintf("-oB%d", connection_max_messages); + if (*queue_name) + { + argv[n++] = US"-MCG"; + argv[n++] = queue_name; + } } /* Now add in any others that are in the call. Remember which they were, diff --git a/src/src/daemon.c b/src/src/daemon.c index 3634ad448..a778c489d 100644 --- a/src/src/daemon.c +++ b/src/src/daemon.c @@ -651,8 +651,8 @@ if (pid == 0) if (geteuid() != root_uid && !deliver_drop_privilege) { signal(SIGALRM, SIG_DFL); - (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, FALSE, 2, US"-Mc", - message_id); + (void)child_exec_exim(CEE_EXEC_PANIC, FALSE, NULL, FALSE, + 2, US"-Mc", message_id); /* Control does not return here. */ } @@ -1615,12 +1615,11 @@ else if (daemon_listen) int i, j; int smtp_ports = 0; int smtps_ports = 0; - ip_address_item *ipa; - uschar *p = big_buffer; - uschar *qinfo = (queue_interval > 0)? - string_sprintf("-q%s", readconf_printtime(queue_interval)) - : - US"no queue runs"; + ip_address_item * ipa; + uschar * p = big_buffer; + uschar * qinfo = queue_interval > 0 + ? string_sprintf("-q%s", readconf_printtime(queue_interval)) + : US"no queue runs"; /* Build a list of listening addresses in big_buffer, but limit it to 10 items. The style is for backwards compatibility. @@ -1631,30 +1630,30 @@ else if (daemon_listen) for (j = 0; j < 2; j++) { - for (i = 0, ipa = addresses; i < 10 && ipa != NULL; i++, ipa = ipa->next) + for (i = 0, ipa = addresses; i < 10 && ipa; i++, ipa = ipa->next) { /* First time round, look for SMTP ports; second time round, look for SMTPS ports. For the first one of each, insert leading text. */ if (host_is_tls_on_connect_port(ipa->port) == (j > 0)) { - if (j == 0) - { - if (smtp_ports++ == 0) + if (j == 0) + { + if (smtp_ports++ == 0) { memcpy(p, "SMTP on", 8); p += 7; } - } - else - { - if (smtps_ports++ == 0) + } + else + { + if (smtps_ports++ == 0) { (void)sprintf(CS p, "%sSMTPS on", - (smtp_ports == 0)? "":" and for "); - while (*p != 0) p++; + smtp_ports == 0 ? "" : " and for "); + while (*p) p++; } - } + } /* Now the information about the port (and sometimes interface) */ @@ -1679,7 +1678,7 @@ else if (daemon_listen) } } - if (ipa != NULL) + if (ipa) { memcpy(p, " ...", 5); p += 4; @@ -1835,24 +1834,22 @@ for (;;) if (deliver_force_thaw) *p++ = 'f'; if (queue_run_local) *p++ = 'l'; *p = 0; - if (queue_name) - extra[0] = string_sprintf("%sG%s", opt, queue_name); - else - extra[0] = opt; + extra[0] = queue_name + ? string_sprintf("%sG%s", opt, queue_name) : opt; /* If -R or -S were on the original command line, ensure they get passed on. */ - if (deliver_selectstring != NULL) + if (deliver_selectstring) { - extra[extracount++] = deliver_selectstring_regex? US"-Rr" : US"-R"; + extra[extracount++] = deliver_selectstring_regex ? US"-Rr" : US"-R"; extra[extracount++] = deliver_selectstring; } - if (deliver_selectstring_sender != NULL) + if (deliver_selectstring_sender) { - extra[extracount++] = deliver_selectstring_sender_regex? - US"-Sr" : US"-S"; + extra[extracount++] = deliver_selectstring_sender_regex + ? US"-Sr" : US"-S"; extra[extracount++] = deliver_selectstring_sender; } diff --git a/src/src/exim.c b/src/src/exim.c index ea0d0b790..f2ec04f04 100644 --- a/src/src/exim.c +++ b/src/src/exim.c @@ -2723,7 +2723,7 @@ for (i = 1; i < argc; i++) break; } - /* -MCG: set the queue name, to a non-default value + /* -MCG: set the queue name, to a non-default value */ else if (Ustrcmp(argrest, "CG") == 0) { @@ -5726,8 +5726,8 @@ while (more) if (geteuid() != root_uid && !deliver_drop_privilege && !unprivileged) { - (void)child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, 2, US"-Mc", - message_id); + (void)child_exec_exim(CEE_EXEC_EXIT, FALSE, NULL, FALSE, + 2, US"-Mc", message_id); /* Control does not return here. */ } diff --git a/src/src/smtp_in.c b/src/src/smtp_in.c index 1398e620b..565f4b32e 100644 --- a/src/src/smtp_in.c +++ b/src/src/smtp_in.c @@ -4947,8 +4947,10 @@ while (done <= 0) break; } etrn_command = US"exim -R"; - argv = CUSS child_exec_exim(CEE_RETURN_ARGV, TRUE, NULL, TRUE, 2, US"-R", - smtp_cmd_data); + argv = CUSS child_exec_exim(CEE_RETURN_ARGV, TRUE, NULL, TRUE, + *queue_name ? 4 : 2, + US"-R", smtp_cmd_data, + US"-MCG", queue_name); } /* If we are host-testing, don't actually do anything. */ diff --git a/src/src/transport.c b/src/src/transport.c index af453b04a..e1e6dcebf 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -1923,12 +1923,6 @@ if ((pid = fork()) == 0) argv = CUSS child_exec_exim(CEE_RETURN_ARGV, TRUE, &i, FALSE, 0); - if (*queue_name) - { - argv[i++] = US"-MCG"; - argv[i++] = queue_name; - } - if (smtp_use_dsn) argv[i++] = US"-MCD"; if (smtp_authenticated) argv[i++] = US"-MCA";