X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Ftransports%2Fsmtp.c;h=a503d8f139635241c0d2391d3ad6d4df1080fe75;hb=7546de58d97a3a4d36dc27ab4e8764f77dc4f887;hp=42179898a972d4d6554c1c7e3e18bd57c4536dfc;hpb=f15132938afa3813819da28497bcabedc551dcf2;p=exim.git diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index 42179898a..a503d8f13 100644 --- a/src/src/transports/smtp.c +++ b/src/src/transports/smtp.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/transports/smtp.c,v 1.15 2005/08/02 11:22:24 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transports/smtp.c,v 1.17 2005/08/09 13:31:53 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -329,8 +329,8 @@ this particular type of timeout. Returns: nothing */ -static -void set_errno(address_item *addrlist, int errno_value, uschar *msg, int rc, +static void +set_errno(address_item *addrlist, int errno_value, uschar *msg, int rc, BOOL pass_message) { address_item *addr; @@ -505,14 +505,14 @@ if (addr->message != NULL) } else { - log_write(0, LOG_MAIN, "%s [%s]: %s", - host->name, - host->address, - strerror(addr->basic_errno)); - deliver_msglog("%s %s [%s]: %s\n", - tod_stamp(tod_log), - host->name, - host->address, + uschar *msg = + ((log_extra_selector & LX_outgoing_port) != 0)? + string_sprintf("%s [%s]:%d", host->name, host->address, + (host->port == PORT_NONE)? 25 : host->port) + : + string_sprintf("%s [%s]", host->name, host->address); + log_write(0, LOG_MAIN, "%s %s", msg, strerror(addr->basic_errno)); + deliver_msglog("%s %s %s\n", tod_stamp(tod_log), msg, strerror(addr->basic_errno)); } } @@ -749,7 +749,7 @@ Arguments: failed by one of them. host host to deliver to host_af AF_INET or AF_INET6 - port TCP/IP port to use, in host byte order + port default TCP/IP port to use, in host byte order interface interface to bind to, or NULL tblock transport instance block copy_host TRUE if host set in addr->host_used must be copied, because @@ -1577,11 +1577,10 @@ if (!ok) ok = TRUE; else } /* SMTP, or success return from LMTP for this address. Pass back the - actual port used. */ + actual host that was used. */ addr->transport_return = OK; addr->more_errno = delivery_time; - thost->port = port; addr->host_used = thost; addr->special_action = flag; addr->message = conf; @@ -2130,12 +2129,9 @@ else if (ob->hosts_randomize && hostlist->mx == MX_NONE && !continuing) } -/* Sort out the port. Set up a string for adding to the retry key if the port -number is not the standard SMTP port. */ +/* Sort out the default port. */ if (!smtp_get_port(ob->port, addrlist, &port, tid)) return FALSE; -pistring = string_sprintf(":%d", port); -if (Ustrcmp(pistring, ":25") == 0) pistring = US""; /* For each host-plus-IP-address on the list: @@ -2239,6 +2235,8 @@ for (cutoff_retry = 0; expired && if (host->address == NULL) { + int new_port; + host_item *hh; uschar *canonical_name; if (host->status >= hstatus_unusable) @@ -2250,6 +2248,13 @@ for (cutoff_retry = 0; expired && DEBUG(D_transport) debug_printf("getting address for %s\n", host->name); + /* The host name is permitted to have an attached port. Find it, and + strip it from the name. Just remember it for now. */ + + new_port = host_item_get_port(host); + + /* Count hosts looked up */ + hosts_looked_up++; /* Find by name if so configured, or if it's an IP address. We don't @@ -2266,6 +2271,11 @@ for (cutoff_retry = 0; expired && &canonical_name, NULL); } + /* Update the host (and any additional blocks, resulting from + multihoming) with a host-specific port, if any. */ + + for (hh = host; hh != nexthost; hh = hh->next) hh->port = new_port; + /* Failure to find the host at this time (usually DNS temporary failure) is really a kind of routing failure rather than a transport failure. Therefore we add a retry item of the routing kind, not to stop us trying @@ -2359,6 +2369,14 @@ for (cutoff_retry = 0; expired && deliver_host = host->name; deliver_host_address = host->address; + /* Set up a string for adding to the retry key if the port number is not + the standard SMTP port. A host may have its own port setting that overrides + the default. */ + + pistring = string_sprintf(":%d", (host->port == PORT_NONE)? + port : host->port); + if (Ustrcmp(pistring, ":25") == 0) pistring = US""; + /* Select IPv4 or IPv6, and choose an outgoing interface. If the interface string changes upon expansion, we must add it to the key that is used for retries, because connections to the same host from a different interface