* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) The Exim Maintainers 2020 - 2022 */
+/* Copyright (c) The Exim Maintainers 2020 - 2024 */
/* Copyright (c) University of Cambridge 1995 - 2018 */
/* See the file NOTICE for conditions of use and distribution. */
/* SPDX-License-Identifier: GPL-2.0-or-later */
int transport_count; /* returned transport count value */
BOOL done; /* no more data needed */
uschar *msg; /* error message */
- uschar *return_path; /* return_path for these addresses */
+ const uschar *return_path; /* return_path for these addresses */
} pardata;
/* Values for the process_recipients variable */
static struct pollfd *parpoll;
static int return_count;
static uschar *frozen_info = US"";
-static uschar *used_return_path = NULL;
+static const uschar * used_return_path = NULL;
*/
address_item *
-deliver_make_addr(uschar *address, BOOL copy)
+deliver_make_addr(const uschar * address, BOOL copy)
{
address_item * addr = store_get(sizeof(address_item), GET_UNTAINTED);
*addr = address_defaults;
*/
static BOOL
-same_strings(uschar *one, uschar *two)
+same_strings(const uschar * one, const uschar * two)
{
if (one == two) return TRUE; /* Includes the case where both NULL */
if (!one || !two) return FALSE;
{
while (addr->parent)
{
- address_item *aa;
+ address_item * aa;
addr = addr->parent;
if (--addr->child_count > 0) return; /* Incomplete parent */
if (LOGGING(outgoing_port))
g = string_fmt_append(g, ":%d", h->port);
-if (continue_sequence > 1) /*XXX this is wrong for a dropped proxyconn. Would have to pass back from transport */
+if (testflag(addr, af_cont_conn))
g = string_catn(g, US"*", 1);
#ifdef SUPPORT_SOCKS
*/
uschar *
-event_raise(uschar * action, const uschar * event, uschar * ev_data, int * errnop)
+event_raise(const uschar * action, const uschar * event, const uschar * ev_data,
+ int * errnop)
{
-uschar * s;
+const uschar * s;
if (action)
{
DEBUG(D_deliver)
event_name = event;
event_data = ev_data;
- if (!(s = expand_string(action)) && *expand_string_message)
+ if (!(s = expand_cstring(action)) && *expand_string_message)
log_write(0, LOG_MAIN|LOG_PANIC,
"failed to expand event_action %s in %s: %s\n",
event, transport_name ? transport_name : US"main", expand_string_message);
event_name = event_data = NULL;
/* If the expansion returns anything but an empty string, flag for
- the caller to modify his normal processing
+ the caller to modify his normal processing. Copy the string to
+ de-const it.
*/
if (s && *s)
{
debug_printf("Event(%s): event_action returned \"%s\"\n", event, s);
if (errnop)
*errnop = ERRNO_EVENT;
- return s;
+ return string_copy(s);
}
}
return NULL;
msg_event_raise(const uschar * event, const address_item * addr)
{
const uschar * save_domain = deliver_domain;
-uschar * save_local = deliver_localpart;
+const uschar * save_local = deliver_localpart;
const uschar * save_host = deliver_host;
const uschar * save_address = deliver_host_address;
+uschar * save_rn = router_name, * save_tn = transport_name;
const int save_port = deliver_host_port;
router_name = addr->router ? addr->router->name : NULL;
deliver_host = save_host;
deliver_localpart = save_local;
deliver_domain = save_domain;
-router_name = transport_name = NULL;
+router_name = save_rn;
+transport_name = save_tn;
}
#endif /*DISABLE_EVENT*/
* Generate local part for logging *
*************************************************/
-static uschar *
-string_get_lpart_sub(const address_item * addr, uschar * s)
+static const uschar *
+string_get_lpart_sub(const address_item * addr, const uschar * s)
{
#ifdef SUPPORT_I18N
if (testflag(addr, af_utf8_downcvt))
{
- uschar * t = string_localpart_utf8_to_alabel(s, NULL);
+ const uschar * t = string_localpart_utf8_to_alabel(s, NULL);
return t ? t : s; /* t is NULL on a failed conversion */
}
#endif
static gstring *
string_get_localpart(address_item * addr, gstring * yield)
{
-uschar * s;
+const uschar * s;
if (testflag(addr, af_include_affixes) && (s = addr->prefix))
yield = string_cat(yield, string_get_lpart_sub(addr, s));
g = string_catn(g, US" K", 2);
}
+#ifndef DISABLE_DKIM
+ if (addr->dkim_used && LOGGING(dkim_verbose))
+ {
+ g = string_catn(g, US" DKIM=", 6);
+ g = string_cat(g, addr->dkim_used);
+ }
+#endif
+
/* confirmation message (SMTP (host_used) and LMTP (driver_name)) */
if ( LOGGING(smtp_confirmation)
/* string_cat() always leaves room for the terminator. Release the
store we used to build the line after writing it. */
-log_write(0, flags, "%s", string_from_gstring(g));
+log_write(0, flags, "%Y", g);
#ifndef DISABLE_EVENT
if (!msg) msg_event_raise(US"msg:delivery", addr);
if (addr->message)
g = string_append(g, 2, US": ", addr->message);
- {
- const uschar * s = string_from_gstring(g);
-
- /* Log the deferment in the message log, but don't clutter it
- up with retry-time defers after the first delivery attempt. */
+/* Log the deferment in the message log, but don't clutter it
+up with retry-time defers after the first delivery attempt. */
- if (f.deliver_firsttime || addr->basic_errno > ERRNO_RETRY_BASE)
- deliver_msglog("%s %s\n", now, s);
+if (f.deliver_firsttime || addr->basic_errno > ERRNO_RETRY_BASE)
+ deliver_msglog("%s %.*s\n", now, g->ptr, g->s);
- /* Write the main log and reset the store.
- For errors of the type "retry time not reached" (also remotes skipped
- on queue run), logging is controlled by L_retry_defer. Note that this kind
- of error number is negative, and all the retry ones are less than any
- others. */
+/* Write the main log and reset the store.
+For errors of the type "retry time not reached" (also remotes skipped
+on queue run), logging is controlled by L_retry_defer. Note that this kind
+of error number is negative, and all the retry ones are less than any
+others. */
- log_write(addr->basic_errno <= ERRNO_RETRY_BASE ? L_retry_defer : 0, logflags,
- "== %s", s);
- }
+log_write(addr->basic_errno <= ERRNO_RETRY_BASE ? L_retry_defer : 0, logflags,
+ "== %Y", g);
store_reset(reset_point);
return;
/* Do the logging. For the message log, "routing failed" for those cases,
just to make it clearer. */
- {
- const uschar * s = string_from_gstring(g);
-
- if (driver_kind)
- deliver_msglog("%s %s failed for %s\n", now, driver_kind, s);
- else
- deliver_msglog("%s %s\n", now, s);
+if (driver_kind)
+ deliver_msglog("%s %s failed for %.*s\n", now, driver_kind, g->ptr, g->s);
+else
+ deliver_msglog("%s %.*s\n", now, g->ptr, g->s);
- log_write(0, LOG_MAIN, "** %s", s);
- }
+log_write(0, LOG_MAIN, "** %Y", g);
store_reset(reset_point);
return;
(void)close(addr->return_file);
}
-/* Check if the transport notifed continue-conn status explicitly, and
-update our knowlege. */
-
-if (testflag(addr, af_new_conn)) continue_sequence = 1;
-else if (testflag(addr, af_cont_conn)) continue_sequence++;
-
/* The success case happens only after delivery by a transport. */
if (result == OK)
}
else if (tp->expand_gid)
{
+ GET_OPTION("group");
if (!route_find_expanded_group(tp->expand_gid, tp->name, US"transport", gidp,
- &(addr->message)))
+ &addr->message))
{
common_error(FALSE, addr, ERRNO_GIDFAIL, NULL);
return FALSE;
else if (tp->expand_uid)
{
struct passwd *pw;
+ GET_OPTION("user");
if (!route_find_expanded_user(tp->expand_uid, tp->name, US"transport", &pw,
uidp, &(addr->message)))
{
int rc = OK;
int size_limit;
+GET_OPTION("message_size_limit");
deliver_set_expansions(addr);
size_limit = expand_string_integer(tp->message_size_limit, TRUE);
deliver_set_expansions(NULL);
previously_transported(address_item *addr, BOOL testing)
{
uschar * s = string_sprintf("%s/%s",
- addr->unique + (testflag(addr, af_homonym)? 3:0), addr->transport->name);
+ addr->unique + (testflag(addr, af_homonym) ? 3:0), addr->transport->name);
if (tree_search(tree_nonrecipients, s) != 0)
{
else
return_path = sender_address;
+GET_OPTION("return_path");
if (tp->return_path)
{
uschar * new_return_path = expand_string(tp->return_path);
home directory set in the address may already be expanded; a flag is set to
indicate that. In other cases we must expand it. */
+GET_OPTION("home_directory");
if ( (deliver_home = tp->home_dir) /* Set in transport, or */
|| ( (deliver_home = addr->home_dir) /* Set in address and */
&& !testflag(addr, af_home_expanded) /* not expanded */
operating systems when running pipes, as some commands (e.g. "rm" under Solaris
2.5) require this. */
+GET_OPTION("current_directory");
working_directory = tp->current_dir ? tp->current_dir : addr->current_dir;
if (working_directory)
{
addr->local_part, tp->name);
/* Setting these globals in the subprocess means we need never clear them */
- transport_name = addr->transport->name;
+
+ transport_name = tp->name;
+ if (addr->router) router_name = addr->router->name;
driver_srcfile = tp->srcfile;
driver_srcline = tp->srcline;
{
ok = transport_set_up_command(&transport_filter_argv,
tp->filter_command,
- TRUE, PANIC, addr, FALSE, US"transport filter", NULL);
+ TSUC_EXPAND_ARGS, PANIC, addr, US"transport filter", NULL);
transport_filter_timeout = tp->filter_timeout;
}
else transport_filter_argv = NULL;
and close the pipe we were writing down before exiting. */
(void)close(pfd[pipe_write]);
- search_tidyup();
- exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS);
}
/* Back in the main process: panic if the fork did not succeed. This seems
/* If SPECIAL_WARN is set in the top address, send a warning message. */
-if (addr->special_action == SPECIAL_WARN && addr->transport->warn_message)
+if (addr->special_action == SPECIAL_WARN)
{
- int fd;
- uschar *warn_message;
- pid_t pid;
+ uschar * warn_message = addr->transport->warn_message;
+ GET_OPTION("quota_warn_message");
+ if (warn_message)
+ {
+ int fd;
+ pid_t pid;
- DEBUG(D_deliver) debug_printf("Warning message requested by transport\n");
+ DEBUG(D_deliver) debug_printf("Warning message requested by transport\n");
- if (!(warn_message = expand_string(addr->transport->warn_message)))
- log_write(0, LOG_MAIN|LOG_PANIC, "Failed to expand \"%s\" (warning "
- "message for %s transport): %s", addr->transport->warn_message,
- addr->transport->name, expand_string_message);
+ if (!(warn_message = expand_string(warn_message)))
+ log_write(0, LOG_MAIN|LOG_PANIC, "Failed to expand \"%s\" (warning "
+ "message for %s transport): %s", addr->transport->warn_message,
+ addr->transport->name, expand_string_message);
- else if ((pid = child_open_exim(&fd, US"tpt-warning-message")) > 0)
- {
- FILE *f = fdopen(fd, "wb");
- if (errors_reply_to && !contains_header(US"Reply-To", warn_message))
- fprintf(f, "Reply-To: %s\n", errors_reply_to);
- fprintf(f, "Auto-Submitted: auto-replied\n");
- if (!contains_header(US"From", warn_message))
- moan_write_from(f);
- fprintf(f, "%s", CS warn_message);
+ else if ((pid = child_open_exim(&fd, US"tpt-warning-message")) > 0)
+ {
+ FILE * f = fdopen(fd, "wb");
+ if (errors_reply_to && !contains_header(US"Reply-To", warn_message))
+ fprintf(f, "Reply-To: %s\n", errors_reply_to);
+ fprintf(f, "Auto-Submitted: auto-replied\n");
+ if (!contains_header(US"From", warn_message))
+ moan_write_from(f);
+ fprintf(f, "%s", CS warn_message);
- /* Close and wait for child process to complete, without a timeout. */
+ /* Close and wait for child process to complete, without a timeout. */
- (void)fclose(f);
- (void)child_close(pid, 0);
- }
+ (void)fclose(f);
+ (void)child_close(pid, 0);
+ }
- addr->special_action = SPECIAL_NONE;
+ addr->special_action = SPECIAL_NONE;
+ }
}
}
{
unsigned max_parallel;
+GET_OPTION("max_parallel");
if (!tp->max_parallel) return FALSE;
max_parallel = (unsigned) expand_string_integer(tp->max_parallel, TRUE);
static void
do_local_deliveries(void)
{
-open_db dbblock;
-open_db *dbm_file = NULL;
+open_db dbblock, * dbm_file = NULL;
time_t now = time(NULL);
/* Loop until we have exhausted the supply of local deliveries */
/* Expand the batch_id string for comparison with other addresses.
Expansion failure suppresses batching. */
+ GET_OPTION("batch_id");
if (tp->batch_id)
{
deliver_set_expansions(addr);
if (ok && batch_id)
{
- uschar *bid;
- address_item *save_nextnext = next->next;
+ uschar * bid;
+ address_item * save_nextnext = next->next;
next->next = NULL; /* Expansion for a single address */
deliver_set_expansions(next);
next->next = save_nextnext;
+ GET_OPTION("batch_id");
bid = expand_string(tp->batch_id);
deliver_set_expansions(NULL);
if (!bid)
if (result == DEFER || testflag(addr2, af_lt_retry_exists))
{
int flags = result == DEFER ? 0 : rf_delete;
- uschar *retry_key = string_copy(tp->retry_use_local_part
+ uschar * retry_key = string_copy(tp->retry_use_local_part
? addr2->address_retry_key : addr2->domain_retry_key);
*retry_key = 'T';
retry_add_item(addr2, retry_key, flags);
uschar *msg = p->msg;
BOOL done = p->done;
+continue_hostname = NULL;
+continue_transport = NULL;
+
/* Loop through all items, reading from the pipe when necessary. The pipe
used to be non-blocking. But I do not see a reason for using non-blocking I/O
here, as the preceding poll() tells us, if data is available for reading.
pipeheader[PIPE_HEADER_SIZE] = '\0';
DEBUG(D_deliver)
- debug_printf("got %ld bytes (pipeheader) from transport process %d\n",
- (long) got, pid);
+ debug_printf("got %ld bytes (pipeheader) '%c' from transport process %d\n",
+ (long) got, *id, pid);
{
/* If we can't decode the pipeheader, the subprocess seems to have a
/* Put the amount of data written into the parlist block */
- case 'S':
+ case 'S': /* Size */
memcpy(&(p->transport_count), ptr, sizeof(transport_count));
ptr += sizeof(transport_count);
break;
if (*subid > '1') setflag(addr, af_tcp_fastopen_data);
break;
- case 'D':
+ case 'D': /* DSN */
if (!addr) goto ADDR_MISMATCH;
memcpy(&(addr->dsn_aware), ptr, sizeof(addr->dsn_aware));
ptr += sizeof(addr->dsn_aware);
switch (*subid)
{
- case 3: /* explicit notification of continued-connection (non)use;
+#ifndef DISABLE_DKIM
+ case '4': /* DKIM information */
+ addr->dkim_used = string_copy(ptr);
+ while(*ptr++);
+ break;
+#endif
+
+ case '3': /* explicit notification of continued-connection (non)use;
overrides caller's knowlege. */
if (*ptr & BIT(1)) setflag(addr, af_new_conn);
else if (*ptr & BIT(2)) setflag(addr, af_cont_conn);
h->dnssec = *ptr == '2' ? DS_YES
: *ptr == '1' ? DS_NO
: DS_UNK;
- ptr++;
addr->host_used = h;
}
- else ptr++;
+ ptr++;
+ continue_flags = 0;
+#ifndef DISABLE_TLS
+ if (testflag(addr, af_cert_verified)) continue_flags |= CTF_CV;
+# ifdef SUPPORT_DANE
+ if (testflag(addr, af_dane_verified)) continue_flags |= CTF_DV;
+# endif
+# ifndef DISABLE_TLS_RESUME
+ if (testflag(addr, af_tls_resume)) continue_flags |= CTF_TR;
+# endif
+#endif
/* Finished with this address */
addr = addr->next;
while (*ptr++) ;
break;
- /* Z marks the logical end of the data. It is followed by '0' if
+ /* Z0 marks the logical end of the data. It is followed by '0' if
continue_transport was NULL at the end of transporting, otherwise '1'.
- We need to know when it becomes NULL during a delivery down a passed SMTP
- channel so that we don't try to pass anything more down it. Of course, for
- most normal messages it will remain NULL all the time. */
+ Those are now for historical reasons only; we always clear the continued
+ channel info, and then set it explicitly if the transport indicates it
+ is still open, because it could differ for each transport we are running in
+ parallel.
+
+ Z1 is a suggested message_id to handle next, used during a
+ continued-transport sequence. */
case 'Z':
- if (*ptr == '0')
+ switch (*subid)
{
- continue_transport = NULL;
- continue_hostname = NULL;
+ case '0': /* End marker */
+ done = TRUE;
+ DEBUG(D_deliver) debug_printf("Z0%c item read\n", *ptr);
+ break;
+ case '1': /* Suggested continuation message */
+ Ustrncpy(continue_next_id, ptr, MESSAGE_ID_LENGTH);
+ continue_sequence = atoi(CS ptr + MESSAGE_ID_LENGTH + 1);
+ DEBUG(D_deliver) debug_printf("continue_next_id: %s seq %d\n",
+ continue_next_id, continue_sequence);
+ break;
+ case '2': /* Continued transport, host & addr */
+ {
+ int recvd_fd;
+
+ DEBUG(D_any) if (Ustrcmp(process_purpose, "continued-delivery") != 0)
+ debug_printf("%s becomes continued-delivery\n", process_purpose);
+ process_purpose = US"continued-delivery";
+ continue_transport = string_copy(ptr); while (*ptr++) ;
+ continue_hostname = string_copy(ptr); while (*ptr++) ;
+ continue_host_address = string_copy(ptr); while (*ptr++) ;
+ continue_sequence = atoi(CS ptr);
+
+ dup2((recvd_fd = recv_fd_from_sock(fd)), 0);
+ close(recvd_fd);
+
+ DEBUG(D_deliver)
+ debug_printf("continue: tpt '%s' host '%s' addr '%s' seq %d\n",
+ continue_transport, continue_hostname,
+ continue_host_address, continue_sequence);
+ break;
+ }
+ case '3': /* Continued conn info */
+ smtp_peer_options = ptr[0];
+ f.smtp_authenticated = ptr[1] & 1;
+ break;
+#ifndef DISABLE_TLS
+ case '4': /* Continued TLS info */
+ continue_proxy_cipher = string_copy(ptr);
+ break;
+ case '5': /* Continued DANE info */
+ case '6': /* Continued TLS info */
+# ifdef SUPPORT_DANE
+ continue_proxy_dane = *subid == '5';
+# endif
+ continue_proxy_sni = *ptr ? string_copy(ptr) : NULL;
+ break;
+#endif
+#ifndef DISABLE_ESMTP_LIMITS
+ case '7': /* Continued peer limits */
+ sscanf(CS ptr, "%u %u %u",
+ &continue_limit_mail, &continue_limit_rcpt,
+ &continue_limit_rcptdom);
+ break;
+#endif
+#ifdef SUPPORT_SOCKS
+ case '8': /* Continued proxy info */
+ proxy_local_address = string_copy(ptr); while (*ptr++) ;
+ proxy_local_port = atoi(CS ptr); while (*ptr++) ;
+ proxy_external_address = string_copy(ptr); while (*ptr++) ;
+ proxy_external_port = atoi(CS ptr);
+ break;
+#endif
}
- done = TRUE;
- DEBUG(D_deliver) debug_printf("Z0%c item read\n", *ptr);
break;
/* Anything else is a disaster. */
transport splitting further by max_rcp. So we potentially lose some
parallellism. */
+ GET_OPTION("max_rcpt");
address_count_max = mua_wrapper || Ustrchr(tp->max_addresses, '$')
? UNLIMITED_ADDRS : expand_max_rcpt(tp->max_addresses);
&& address_count_max < remote_delivery_count/remote_max_parallel
)
{
- int new_max = remote_delivery_count/remote_max_parallel;
- int message_max = tp->connection_max_messages;
+ int new_max = remote_delivery_count/remote_max_parallel, message_max;
+ GET_OPTION("connection_max_messages");
+ message_max = tp->connection_max_messages;
if (connection_max_messages >= 0) message_max = connection_max_messages;
message_max -= continue_sequence - 1;
if (message_max > 0 && new_max > address_count_max * message_max)
/* Compute the return path, expanding a new one if required. The old one
must be set first, as it might be referred to in the expansion. */
- if(addr->prop.errors_address)
- return_path = addr->prop.errors_address;
- else
- return_path = sender_address;
+ return_path = addr->prop.errors_address
+ ? addr->prop.errors_address : sender_address;
+ GET_OPTION("return_path");
if (tp->return_path)
{
- uschar *new_return_path = expand_string(tp->return_path);
+ uschar * new_return_path = expand_string(tp->return_path);
if (new_return_path)
return_path = new_return_path;
else if (!f.expand_string_forcedfail)
continue;
}
+ }
- /* Set a flag indicating whether there are further addresses that list
- the continued host. This tells the transport to leave the channel open,
- but not to pass it to another delivery process. We'd like to do that
- for non-continue_transport cases too but the knowlege of which host is
- connected to is too hard to manage. Perhaps we need a finer-grain
- interface to the transport. */
+ /* Once we hit the max number of parallel transports set a flag indicating
+ whether there are further addresses that list the same host. This tells the
+ transport to leave the channel open for us. */
+/*XXX maybe we should *count* possible further's, and set continue_more if
+parmax * tpt-max is exceeded? */
- for (next = addr_remote; next && !f.continue_more; next = next->next)
- for (host_item * h = next->host_list; h; h = h->next)
- if (Ustrcmp(h->name, continue_hostname) == 0)
- { f.continue_more = TRUE; break; }
+ if (parcount+1 >= remote_max_parallel)
+ {
+ host_item * h1 = addr->host_list;
+ if (h1)
+ {
+ const uschar * name = continue_hostname ? continue_hostname : h1->name;
+ for (next = addr_remote; next && !f.continue_more; next = next->next)
+ for (host_item * h = next->host_list; h; h = h->next)
+ if (Ustrcmp(h->name, name) == 0)
+ { f.continue_more = TRUE; break; }
+ }
}
+ else DEBUG(D_deliver)
+ debug_printf(
+ "not reached parallelism limit (%d/%d) so not setting continue_more\n",
+ parcount+1, remote_max_parallel);
/* The transports set up the process info themselves as they may connect
to more than one remote machine. They also have to set up the filter
fails, it is probably because the value of remote_max_parallel is so
large that too many file descriptors for pipes have been created. Arrange
to wait for a process to finish, and then try again. If we still can't
- create a pipe when all processes have finished, break the retry loop. */
+ create a pipe when all processes have finished, break the retry loop.
+ Use socketpair() rather than pipe() so we can pass an fd back from the
+ transport process.
+ */
while (!pipe_done)
{
- if (pipe(pfd) == 0) pipe_done = TRUE;
- else if (parcount > 0) parmax = parcount;
- else break;
+ if (socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) == 0) pipe_done = TRUE;
+ else if (parcount > 0) parmax = parcount;
+ else break;
/* We need to make the reading end of the pipe non-blocking. There are
two different options for this. Exim is cunningly (I hope!) coded so
search_tidyup();
+/*
+A continued-tpt will, in the tpt parent here, call par_reduce for
+the one child. But we are hoping to never do continued-transport...
+SO.... we may have called par_reduce for a single child, above when we'd
+hit the limit on child-count. Possibly multiple times with different
+transports and target hosts. Does it matter if several return a suggested
+next-id, and we lose all but the last? Hmm. Less parallel working would
+happen. Perhaps still do continued-tpt once one has been set? No, that won't
+work for all cases.
+BAH.
+Could take the initial continued-tpt hit, and then do the next-id thing?
+
+do_remote_deliveries par_reduce par_wait par_read_pipe
+*/
+
+ /*XXX what about firsttime? */
+ if (continue_transport && !exim_lockfile_needed())
+ if (!continue_wait_db)
+ {
+ continue_wait_db = dbfn_open_multi(
+ string_sprintf("wait-%.200s", continue_transport),
+ O_RDWR,
+ (open_db *) store_get(sizeof(open_db), GET_UNTAINTED));
+ continue_next_id[0] = '\0';
+ }
+
if ((pid = exim_fork(US"transport")) == 0)
{
int fd = pfd[pipe_write];
host_item *h;
/* Setting these globals in the subprocess means we need never clear them */
- transport_name = addr->transport->name;
+
+ transport_name = tp->name;
+ if (addr->router) router_name = addr->router->name;
driver_srcfile = tp->srcfile;
driver_srcline = tp->srcline;
is flagged by an identifying byte, and is then in a fixed format (with
strings terminated by zeros), and there is a final terminator at the
end. The host information and retry information is all attached to
- the first address, so that gets sent at the start. */
+ the first address, so that gets sent at the start.
+
+ Result item tags:
+ A C D H I K L P R S T X Z
+ */
/* Host unusability information: for most success cases this will
be null. */
{
if (!h->address || h->status < hstatus_unusable) continue;
sprintf(CS big_buffer, "%c%c%s", h->status, h->why, h->address);
- rmt_dlv_checked_write(fd, 'H', '0', big_buffer, Ustrlen(big_buffer+2) + 3);
+ rmt_dlv_checked_write(fd, 'H','0', big_buffer, Ustrlen(big_buffer+2) + 3);
}
/* The number of bytes written. This is the same for each address. Even
/* Information about what happened to each address. Four item types are
used: an optional 'X' item first, for TLS information, then an optional "C"
item for any client-auth info followed by 'R' items for any retry settings,
- and finally an 'A' item for the remaining data. */
+ and finally an 'A' item for the remaining data. The actual recipient address
+ is not sent but is implicit in the address-chain being handled. */
for(; addr; addr = addr->next)
{
- uschar *ptr;
+ uschar * ptr;
- /* The certificate verification status goes into the flags */
+#ifndef DISABLE_TLS
+ /* The certificate verification status goes into the flags, in A0 */
if (tls_out.certificate_verified) setflag(addr, af_cert_verified);
-#ifdef SUPPORT_DANE
+# ifdef SUPPORT_DANE
if (tls_out.dane_verified) setflag(addr, af_dane_verified);
-#endif
+# endif
# ifndef DISABLE_TLS_RESUME
if (tls_out.resumption & RESUME_USED) setflag(addr, af_tls_resume);
# endif
/* Use an X item only if there's something to send */
-#ifndef DISABLE_TLS
if (addr->cipher)
{
ptr = big_buffer + sprintf(CS big_buffer, "%.128s", addr->cipher) + 1;
rmt_dlv_checked_write(fd, 'R', '0', big_buffer, ptr - big_buffer);
}
+#ifndef DISABLE_DKIM
+ if (addr->dkim_used && LOGGING(dkim_verbose))
+ {
+ DEBUG(D_deliver) debug_printf("dkim used: %s\n", addr->dkim_used);
+ ptr = big_buffer + sprintf(CS big_buffer, "%.128s", addr->dkim_used) + 1;
+ rmt_dlv_checked_write(fd, 'A', '4', big_buffer, ptr - big_buffer);
+ }
+#endif
+
if (testflag(addr, af_new_conn) || testflag(addr, af_cont_conn))
{
DEBUG(D_deliver) debug_printf("%scontinued-connection\n",
#endif
/* The rest of the information goes in an 'A0' item. */
-
+#ifdef notdef
+ DEBUG(D_deliver)
+ debug_printf("%s %s for MAIL\n",
+ addr->special_action == '=' ? "initial RCPT"
+ : addr->special_action == '-' ? "additional RCPT" : "?",
+ addr->address);
+#endif
sprintf(CS big_buffer, "%c%c", addr->transport_return, addr->special_action);
ptr = big_buffer + 2;
memcpy(ptr, &addr->basic_errno, sizeof(addr->basic_errno));
if (LOGGING(incoming_interface) && sending_ip_address)
#endif
{
- uschar * ptr;
- ptr = big_buffer + sprintf(CS big_buffer, "%.128s", sending_ip_address) + 1;
+ uschar * ptr = big_buffer
+ + sprintf(CS big_buffer, "%.128s", sending_ip_address) + 1;
ptr += sprintf(CS ptr, "%d", sending_port) + 1;
rmt_dlv_checked_write(fd, 'I', '0', big_buffer, ptr - big_buffer);
}
+ /* Continuation message-id, if a continuation is for that reason,
+ and the next sequence number (MAIL FROM count) for the connection. */
+
+ if (*continue_next_id)
+ rmt_dlv_checked_write(fd, 'Z', '1', big_buffer,
+ sprintf(CS big_buffer, "%.*s %u",
+ MESSAGE_ID_LENGTH, continue_next_id, continue_sequence+1) + 1);
+
+ /* Connection details, only on the first suggested continuation for
+ wait-db ones, but for all continue-more ones (though any after the
+ delivery proc has the info are pointless). */
+
+ if (continue_hostname)
+ {
+ {
+ uschar * ptr = big_buffer;
+ ptr += sprintf(CS ptr, "%.128s", continue_transport) + 1;
+ ptr += sprintf(CS ptr, "%.128s", continue_hostname) + 1;
+ ptr += sprintf(CS ptr, "%.128s", continue_host_address) + 1;
+ ptr += sprintf(CS ptr, "%u", continue_sequence+1) + 1;
+ rmt_dlv_checked_write(fd, 'Z', '2', big_buffer, ptr - big_buffer);
+ send_fd_over_socket(fd, continue_fd);
+ }
+
+ big_buffer[0] = smtp_peer_options;
+ big_buffer[1] = f.smtp_authenticated ? 1 : 0;
+ rmt_dlv_checked_write(fd, 'Z', '3', big_buffer, 2);
+
+ if (tls_out.active.sock >= 0 || continue_proxy_cipher)
+ rmt_dlv_checked_write(fd, 'Z', '4', big_buffer,
+ sprintf(CS big_buffer, "%.128s", continue_proxy_cipher) + 1);
+
+ if (tls_out.sni)
+ rmt_dlv_checked_write(fd, 'Z',
+#ifdef SUPPORT_DANE
+ tls_out.dane_verified ? '5' : '6',
+#else
+ '6',
+#endif
+ tls_out.sni, Ustrlen(tls_out.sni)+1);
+
+#ifndef DISABLE_ESMTP_LIMITS
+ if (continue_limit_mail || continue_limit_rcpt || continue_limit_rcptdom)
+ rmt_dlv_checked_write(fd, 'Z', '7', big_buffer,
+ sprintf(CS big_buffer, "%u %u %u",
+ continue_limit_mail, continue_limit_rcpt,
+ continue_limit_rcptdom) + 1);
+#endif
+
+#ifdef SUPPORT_SOCKS
+ if (proxy_session)
+ {
+ uschar * ptr = big_buffer;
+ ptr += sprintf(CS ptr, "%.128s", proxy_local_address) + 1;
+ ptr += sprintf(CS ptr, "%u", proxy_local_port) + 1;
+ ptr += sprintf(CS ptr, "%.128s", proxy_external_address) + 1;
+ ptr += sprintf(CS ptr, "%u", proxy_external_port) + 1;
+ rmt_dlv_checked_write(fd, 'Z', '8', big_buffer, ptr - big_buffer);
+ }
+#endif
+ }
+
/* Add termination flag, close the pipe, and that's it. The character
- after 'Z' indicates whether continue_transport is now NULL or not.
+ after "Z0" indicates whether continue_transport is now NULL or not.
A change from non-NULL to NULL indicates a problem with a continuing
connection. */
big_buffer[0] = continue_transport ? '1' : '0';
rmt_dlv_checked_write(fd, 'Z', '0', big_buffer, 1);
(void)close(fd);
- exit(EXIT_SUCCESS);
+ exim_exit(EXIT_SUCCESS);
}
/* Back in the mainline: close the unwanted half of the pipe. */
(continue_transport gets set to NULL) before we consider any other addresses
in this message. */
- if (continue_transport) par_reduce(0, fallback);
+ if (continue_transport)
+ {
+ par_reduce(0, fallback);
+ if (!continue_next_id && continue_wait_db)
+ { dbfn_close_multi(continue_wait_db); continue_wait_db = NULL; }
+ }
/* Otherwise, if we are running in the test harness, wait a bit, to let the
newly created process get going before we create another process. This should
ensure repeatability in the tests. Wait long enough for most cases to complete
the transport. */
- else testharness_pause_ms(600);
+ else
+ testharness_pause_ms(600);
continue;
int
deliver_split_address(address_item * addr)
{
-uschar * address = addr->address;
+const uschar * address = addr->address;
uschar * domain;
uschar * t;
int len;
this, Jan 1999.] We know the syntax is valid, so this can be done by simply
removing quoting backslashes and any unquoted doublequotes. */
-t = addr->cc_local_part = store_get(len+1, address);
+addr->cc_local_part = t = store_get(len+1, address);
while(len-- > 0)
{
int c = *address++;
}
else *t++ = c;
}
-*t = 0;
+*t = '\0';
/* We do the percent hack only for those domains that are listed in
percent_hack_domains. A loop is required, to copy with multiple %-hacks. */
if (percent_hack_domains)
{
int rc;
- uschar *new_address = NULL;
- uschar *local_part = addr->cc_local_part;
+ uschar * new_address = NULL;
+ const uschar * local_part = addr->cc_local_part;
deliver_domain = addr->domain; /* set $domain */
if (Ustrcmp(t->name, continue_transport) == 0)
{
if (t->info->closedown) (t->info->closedown)(t);
+ continue_transport = NULL;
break;
}
return DELIVER_NOT_ATTEMPTED;
*/
static BOOL
-print_address_information(address_item *addr, FILE *f, uschar *si, uschar *sc,
- uschar *se)
+print_address_information(address_item * addr, FILE * f, uschar * si,
+ uschar * sc, uschar * se)
{
BOOL yield = TRUE;
-uschar *printed = US"";
-address_item *ancestor = addr;
+const uschar * printed = US"";
+address_item * ancestor = addr;
while (ancestor->parent) ancestor = ancestor->parent;
fprintf(f, "%s", CS si);
else
{
- uschar *s = addr->address;
- uschar *ss;
+ const uschar * s = addr->address;
+ const uschar * ss;
if (addr->address[0] == '>') { ss = US"mail"; s++; }
else if (addr->address[0] == '|') ss = US"pipe";
if (ancestor != addr)
{
- uschar *original = ancestor->onetime_parent;
+ const uschar * original = ancestor->onetime_parent;
if (!original) original= ancestor->address;
if (strcmpic(original, printed) != 0)
fprintf(f, "%s(%sgenerated from %s)", sc,
*/
static void
-do_duplicate_check(address_item **anchor)
+do_duplicate_check(address_item ** anchor)
{
-address_item *addr;
+address_item * addr;
while ((addr = *anchor))
{
- tree_node *tnode;
+ tree_node * tnode;
if (testflag(addr, af_pfr))
- {
- anchor = &(addr->next);
- }
+ anchor = &addr->next;
else if ((tnode = tree_search(tree_duplicates, addr->unique)))
{
DEBUG(D_deliver|D_route)
else
{
tree_add_duplicate(addr->unique, addr);
- anchor = &(addr->next);
+ anchor = &addr->next;
}
}
}
static FILE *
expand_open(const uschar * filename,
- const uschar * varname, const uschar * reason)
+ const uschar * optname, const uschar * reason)
{
const uschar * s = expand_cstring(filename);
FILE * fp = NULL;
if (!s || !*s)
log_write(0, LOG_MAIN|LOG_PANIC,
- "Failed to expand %s: '%s'\n", varname, filename);
+ "Failed to expand %s: '%s'\n", optname, filename);
else if (*s != '/' || is_tainted(s))
log_write(0, LOG_MAIN|LOG_PANIC,
"%s is not %s after expansion: '%s'\n",
- varname, *s == '/' ? "untainted" : "absolute", s);
+ optname, *s == '/' ? "untainted" : "absolute", s);
else if (!(fp = Ufopen(s, "rb")))
log_write(0, LOG_MAIN|LOG_PANIC, "Failed to open %s for %s "
"message texts: %s", s, reason, strerror(errno));
static void
dsn_put_wrapped(FILE * fp, const uschar * header, const uschar * s)
{
-const uschar * t;
-int llen = fprintf(fp, "%s", CS header), sleft = Ustrlen(s);
-int remain = 1022 - llen;
-
-if (*s && remain > 0)
- {
- for(;;)
- {
- unsigned ltail; /* source chars to skip */
-
- /* Chop at a newline, or end of string */
+gstring * g = string_cat(NULL, header);
- if ((t = Ustrchr(s, '\\')) && t[1] == 'n')
- ltail = 2;
- else if ((t = Ustrchr(s, '\n')))
- ltail = 1;
- else
- {
- t = s + sleft;
- ltail = 0;
- }
-
- /* If that is too long, search backward for a space */
-
- if ((llen + t - s) > 78)
- {
- const uschar * u;
- for (u = s + 78 - llen; u > s + 10; --u) if (*u == ' ') break;
- if (u > s + 10)
- { /* found a space to linebreak at */
- llen = u - s;
- remain -= fprintf(fp, "%.*s", (int)llen, s);
- s += ++llen; /* skip the space also */
- }
- else if (llen < 78)
- { /* just linebreak at 78 */
- llen = 78 - llen;
- remain -= fprintf(fp, "%.*s", llen, s);
- s += llen;
- }
- else /* header rather long */
- llen = 0;
- }
- else
- {
- llen = t - s;
- remain -= fprintf(fp, "%.*s", llen, s);
- s = t + ltail;
- }
+g = string_cat(g, s);
+gstring_release_unused(g);
+fprintf(fp, "%s\n", wrap_header(string_from_gstring(g), 79, 1023, US" ", 1));
+}
- sleft -= llen;
- remain -= 2;
- if (!*s || remain <= 0)
- break;
- fputs("\n ", fp);
- llen = 1; /* one for the leading space output above */
- }
- if (s[-1] != '\n') fputs("\n", fp);
- }
-else
- fputs("\n", fp);
-}
/*************************************************
/* Open a template file if one is provided. Log failure to open, but
carry on - default texts will be used. */
+ GET_OPTION("bounce_message_file");
if (bounce_message_file)
emf = expand_open(bounce_message_file,
US"bounce_message_file", US"error");
if (addr->return_file >= 0)
{
- paddr = &(addr->next);
+ paddr = &addr->next;
filecount++;
}
for (address_item * addr = handled_addr; addr; addr = addr->next)
{
host_item * hu;
+#ifdef EXPERIMENTAL_DSN_INFO
+ const uschar * s;
+#endif
print_dsn_addr_action(fp, addr, US"failed", US"5.0.0");
{
fprintf(fp, "Remote-MTA: dns; %s\n", hu->name);
#ifdef EXPERIMENTAL_DSN_INFO
- {
- const uschar * s;
if (hu->address)
{
uschar * p = hu->port == 25
dsn_put_wrapped(fp, US"X-Remote-MTA-smtp-greeting: X-str; ", s);
if ((s = addr->helo_response) && *s)
dsn_put_wrapped(fp, US"X-Remote-MTA-helo-response: X-str; ", s);
- if ((s = addr->message) && *s)
+ if (testflag(addr, af_pass_message) && (s = addr->message) && *s)
dsn_put_wrapped(fp, US"X-Exim-Diagnostic: X-str; ", s);
- }
#endif
print_dsn_diagnostic_code(addr, fp);
}
+#ifdef EXPERIMENTAL_DSN_INFO
+ else if (testflag(addr, af_pass_message) && (s = addr->message) && *s)
+ dsn_put_wrapped(fp, US"X-Exim-Diagnostic: X-str; ", s);
+#endif
fputc('\n', fp);
}
tctx.u.fd = fileno(fp);
tctx.tblock = &tb;
- tctx.options = topt;
+ tctx.options = topt | topt_truncate_headers;
tb.add_headers = dsnnotifyhdr;
/*XXX no checking for failure! buggy! */
if (rc != 0)
{
- uschar *s = US"";
+ uschar * s = US"";
if (now - received_time.tv_sec < retry_maximum_timeout && !addr_defer)
{
addr_defer = (address_item *)(+1);
if (pid <= 0) return FALSE;
+GET_OPTION("warn_message_file");
if (warn_message_file)
wmf = expand_open(warn_message_file,
US"warn_message_file", US"warning");
fflush(f);
/* header only as required by RFC. only failure DSN needs to honor RET=FULL */
tctx.u.fd = fileno(f);
-tctx.options = topt_add_return_path | topt_no_body;
+tctx.options = topt_add_return_path | topt_truncate_headers | topt_no_body;
transport_filter_argv = NULL; /* Just in case */
return_path = sender_address; /* In case not previously set */
*************************************************/
static void
-maybe_send_dsn(void)
+maybe_send_dsn(const address_item * const addr_succeed)
{
address_item * addr_senddsn = NULL;
-for (address_item * a = addr_succeed; a; a = a->next)
+for (const address_item * a = addr_succeed; a; a = a->next)
{
/* af_ignore_error not honored here. it's not an error */
DEBUG(D_deliver) debug_printf("DSN: processing router : %s\n"
/* Write the original email out */
tctx.u.fd = fd;
- tctx.options = topt_add_return_path | topt_no_body;
+ tctx.options = topt_add_return_path | topt_truncate_headers | topt_no_body;
/*XXX hmm, FALSE(fail) retval ignored.
Could error for any number of reasons, and they are not handled. */
transport_write_message(&tctx, 0);
*/
int
-deliver_message(uschar *id, BOOL forced, BOOL give_up)
+deliver_message(const uschar * id, BOOL forced, BOOL give_up)
{
-int i, rc;
-int final_yield = DELIVER_ATTEMPTED_NORMAL;
-time_t now = time(NULL);
-address_item *addr_last = NULL;
-uschar *filter_message = NULL;
-int process_recipients = RECIP_ACCEPT;
-open_db dbblock;
-open_db *dbm_file;
+int i, rc, final_yield, process_recipients;
+time_t now;
+address_item * addr_last;
+uschar * filter_message, * info;
+open_db dbblock, * dbm_file;
extern int acl_where;
-uschar *info;
+
+CONTINUED_ID:
+final_yield = DELIVER_ATTEMPTED_NORMAL;
+now = time(NULL);
+addr_last = NULL;
+filter_message = NULL;
+process_recipients = RECIP_ACCEPT;
#ifdef MEASURE_TIMING
report_time_since(×tamp_startup, US"delivery start"); /* testcase 0022, 2100 */
if (rc != spool_read_hdrerror)
{
received_time.tv_sec = received_time.tv_usec = 0;
- /*XXX subsec precision?*/
- for (i = 0; i < 6; i++)
+ /*III subsec precision?*/
+ for (i = 0; i < MESSAGE_ID_TIME_LEN; i++)
received_time.tv_sec = received_time.tv_sec * BASE_62 + tab62[id[i] - '0'];
}
/* Any error in the filter file causes a delivery to be abandoned. */
+ GET_OPTION("system_filter");
redirect.string = system_filter;
redirect.isfile = TRUE;
redirect.check_owner = redirect.check_group = FALSE;
if (p->address[0] == '|')
{
type = US"pipe";
+ GET_OPTION("system_filter_pipe_transport");
tpname = system_filter_pipe_transport;
address_pipe = p->address;
}
else if (p->address[0] == '>')
{
type = US"reply";
+ GET_OPTION("system_filter_reply_transport");
tpname = system_filter_reply_transport;
}
else
if (p->address[Ustrlen(p->address)-1] == '/')
{
type = US"directory";
+ GET_OPTION("system_filter_directory_transport");
tpname = system_filter_directory_transport;
}
else
{
type = US"file";
+ GET_OPTION("system_filter_file_transport");
tpname = system_filter_file_transport;
}
address_file = p->address;
transport_instance *tp;
for (tp = transports; tp; tp = tp->next)
if (Ustrcmp(tp->name, tpname) == 0)
- {
- p->transport = tp;
- break;
- }
+ { p->transport = tp; break; }
if (!tp)
p->message = string_sprintf("failed to find \"%s\" transport "
"for system filter delivery", tpname);
if (!p->transport)
{
- address_item *badp = p;
+ address_item * badp = p;
p = p->next;
if (!addr_last) addr_new = p; else addr_last->next = p;
badp->local_part = badp->address; /* Needed for log line */
for (i = 0; i < recipients_count; i++)
if (!tree_search(tree_nonrecipients, recipients_list[i].address))
{
- recipient_item *r = recipients_list + i;
- address_item *new = deliver_make_addr(r->address, FALSE);
+ recipient_item * r = recipients_list + i;
+ address_item * new = deliver_make_addr(r->address, FALSE);
+
new->prop.errors_address = r->errors_to;
#ifdef SUPPORT_I18N
if ((new->prop.utf8_msg = message_smtputf8))
case RECIP_FAIL:
new->message = US"delivery cancelled by administrator";
+ /* not setting af_pass_message here means that will not
+ appear in the bounce message */
/* Fall through */
/* Common code for the failure cases above. If this is not a bounce
The incident has already been logged. */
RECIP_QUEUE_FAILED:
- if (sender_address[0])
+ if (*sender_address)
{
new->next = addr_failed;
addr_failed = new;
#ifndef DISABLE_EVENT
if (process_recipients != RECIP_ACCEPT && event_action)
{
- uschar * save_local = deliver_localpart;
+ const uschar * save_local = deliver_localpart;
const uschar * save_domain = deliver_domain;
- uschar * addr = new->address, * errmsg = NULL;
+ const uschar * addr = new->address;
+ uschar * errmsg = NULL;
int start, end, dom;
if (!parse_extract_address(addr, &errmsg, &start, &end, &dom, TRUE))
address_item * addr, * parent;
/* Failure to open the retry database is treated the same as if it does
- not exist. In both cases, dbm_file is NULL. */
+ not exist. In both cases, dbm_file is NULL. For the first stage of a 2-phase
+ queue run don't bother checking domain- or address-retry info; they will take
+ effect on the second stage. */
- if (!(dbm_file = dbfn_open(US"retry", O_RDONLY, &dbblock, FALSE, TRUE)))
- DEBUG(D_deliver|D_retry|D_route|D_hints_lookup)
- debug_printf("no retry data available\n");
+ if (f.queue_2stage)
+ dbm_file = NULL;
+ else
+ {
+ /* If we have transaction-capable hintsdbs, open the retry db without
+ locking, and leave open for the transport process and for subsequent
+ deliveries. If the open fails, tag that explicitly for the transport but
+ retry the open next time around, in case it was created in the interim. */
+
+ if (continue_retry_db == (open_db *)-1)
+ continue_retry_db = NULL;
+
+ if (continue_retry_db)
+ dbm_file = continue_retry_db;
+ else if (!exim_lockfile_needed() && continue_transport)
+ {
+ dbm_file = dbfn_open_multi(US"retry", O_RDONLY, &dbblock);
+ continue_retry_db = dbm_file ? dbm_file : (open_db *)-1;
+ }
+ else
+ dbm_file = dbfn_open(US"retry", O_RDONLY, &dbblock, FALSE, TRUE);
+
+ if (!dbm_file)
+ DEBUG(D_deliver|D_retry|D_route|D_hints_lookup)
+ debug_printf("no retry data available\n");
+ }
/* Scan the current batch of new addresses, to handle pipes, files and
autoreplies, and determine which others are ready for routing. */
addr->unique =
string_sprintf("%s:%s", addr->address, addr->parent->unique +
- (testflag(addr->parent, af_homonym)? 3:0));
+ (testflag(addr->parent, af_homonym) ? 3:0));
addr->address_retry_key = addr->domain_retry_key =
string_sprintf("T:%s", addr->unique);
/* The database is closed while routing is actually happening. Requests to
update it are put on a chain and all processed together at the end. */
- if (dbm_file) dbfn_close(dbm_file);
+ if (dbm_file && !continue_retry_db)
+ { dbfn_close(dbm_file); dbm_file = NULL; }
/* If queue_domains is set, we don't even want to try routing addresses in
those domains. During queue runs, queue_domains is forced to be unset.
else if (testflag(addr, af_dr_retry_exists))
{
- uschar *altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
+ uschar * altkey = string_sprintf("%s:<%s>", addr->address_retry_key,
sender_address);
retry_add_item(addr, altkey, rf_delete);
retry_add_item(addr, addr->address_retry_key, rf_delete);
}
} /* Continue with routing the next address. */
} /* Loop to process any child addresses that the routers created, and
- any rerouted addresses that got put back on the new chain. */
+ any rerouted addresses that got put back on the new chain. */
+if (dbm_file) /* Can only be continue_retry_db */
+ { dbfn_close_multi(continue_retry_db); continue_retry_db = dbm_file = NULL; }
/* Debugging: show the results of the routing */
/* Send DSN for successful messages if requested */
-maybe_send_dsn();
+maybe_send_dsn(addr_succeed);
/* If any addresses failed, we must send a message to somebody, unless
af_ignore_error is set, in which case no action is taken. It is possible for
for (i = 0; i < recipients_count; i++)
{
- uschar *r = recipients_list[i].address;
+ const uschar * r = recipients_list[i].address;
if (Ustrcmp(otaddr->onetime_parent, r) == 0) t = i;
if (Ustrcmp(otaddr->address, r) == 0) break;
}
if (sender_address[0])
{
- uschar * s = addr->prop.errors_address;
+ const uschar * s = addr->prop.errors_address;
if (!s) s = sender_address;
if (Ustrstr(recipients, s) == NULL)
recipients = string_sprintf("%s%s%s", recipients,
|| addr_defer->dsn_flags & rf_notify_delay
)
&& delay_warning[1] > 0
- && sender_address[0] != 0
- && ( !delay_warning_condition
- || expand_check_condition(delay_warning_condition,
- US"delay_warning", US"option")
- )
- )
+ && sender_address[0] != 0)
{
- int count;
- int show_time;
- int queue_time = time(NULL) - received_time.tv_sec;
-
- queue_time = test_harness_fudged_queue_time(queue_time);
+ GET_OPTION("delay_warning_condition");
+ if ( ( !delay_warning_condition
+ || expand_check_condition(delay_warning_condition,
+ US"delay_warning", US"option")
+ )
+ )
+ {
+ int count;
+ int show_time;
+ int queue_time = time(NULL) - received_time.tv_sec;
- /* See how many warnings we should have sent by now */
+ queue_time = test_harness_fudged_queue_time(queue_time);
- for (count = 0; count < delay_warning[1]; count++)
- if (queue_time < delay_warning[count+2]) break;
+ /* See how many warnings we should have sent by now */
- show_time = delay_warning[count+1];
+ for (count = 0; count < delay_warning[1]; count++)
+ if (queue_time < delay_warning[count+2]) break;
- if (count >= delay_warning[1])
- {
- int extra;
- int last_gap = show_time;
- if (count > 1) last_gap -= delay_warning[count];
- extra = (queue_time - delay_warning[count+1])/last_gap;
- show_time += last_gap * extra;
- count += extra;
- }
+ show_time = delay_warning[count+1];
- DEBUG(D_deliver)
- {
- debug_printf("time on queue = %s id %s addr %s\n",
- readconf_printtime(queue_time), message_id, addr_defer->address);
- debug_printf("warning counts: required %d done %d\n", count,
- warning_count);
- }
-
- /* We have computed the number of warnings there should have been by now.
- If there haven't been enough, send one, and up the count to what it should
- have been. */
+ if (count >= delay_warning[1])
+ {
+ int extra;
+ int last_gap = show_time;
+ if (count > 1) last_gap -= delay_warning[count];
+ extra = (queue_time - delay_warning[count+1])/last_gap;
+ show_time += last_gap * extra;
+ count += extra;
+ }
- if (warning_count < count)
- if (send_warning_message(recipients, queue_time, show_time))
+ DEBUG(D_deliver)
{
- warning_count = count;
- update_spool = TRUE; /* Ensure spool rewritten */
+ debug_printf("time on queue = %s id %s addr %s\n",
+ readconf_printtime(queue_time), message_id, addr_defer->address);
+ debug_printf("warning counts: required %d done %d\n", count,
+ warning_count);
}
+
+ /* We have computed the number of warnings there should have been by now.
+ If there haven't been enough, send one, and up the count to what it should
+ have been. */
+
+ if (warning_count < count)
+ if (send_warning_message(recipients, queue_time, show_time))
+ {
+ warning_count = count;
+ update_spool = TRUE; /* Ensure spool rewritten */
+ }
+ }
}
/* Clear deliver_domain */
report_time_since(×tamp_startup, US"delivery end"); /* testcase 0005 */
#endif
+/* If the transport suggested another message to deliver, go round again. */
+
+if (final_yield == DELIVER_ATTEMPTED_NORMAL && *continue_next_id)
+ {
+ addr_defer = addr_failed = addr_succeed = NULL;
+ tree_duplicates = NULL; /* discard dups info from old message */
+ id = string_copyn(continue_next_id, MESSAGE_ID_LENGTH);
+ continue_next_id[0] = '\0';
+ goto CONTINUED_ID;
+ }
+
/* It is unlikely that there will be any cached resources, since they are
released after routing, and in the delivery subprocesses. However, it's
possible for an expansion for something afterwards (for example,