From 26da7e207f1978012085c096366d623dc15b9778 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Mon, 25 Sep 2006 11:25:37 +0000 Subject: [PATCH] Change callout EHLO/HELO from smtp_active_hostname to the helo_data setting from the transport, when there is one. --- doc/doc-txt/ChangeLog | 10 ++++++- src/README.UPDATING | 16 +++++++++- src/src/structs.h | 3 +- src/src/transports/smtp.c | 7 +++-- src/src/verify.c | 35 ++++++++++++++++++---- test/confs/0540 | 53 +++++++++++++++++++++++++++++++++ test/scripts/0000-Basic/0540 | 52 ++++++++++++++++++++++++++++++++ test/stdout/0540 | 57 ++++++++++++++++++++++++++++++++++++ 8 files changed, 221 insertions(+), 12 deletions(-) create mode 100644 test/confs/0540 create mode 100644 test/scripts/0000-Basic/0540 create mode 100644 test/stdout/0540 diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index ba67b7315..be2b79735 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.397 2006/09/25 10:14:20 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.398 2006/09/25 11:25:37 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -55,6 +55,14 @@ JJ/02 exipick 20060919.0, --show-vars args can now be regular expressions, PH/10 Added the log_reject_target ACL modifier to specify where to log rejections. +PH/11 Callouts were setting the name used for EHLO/HELO from $smtp_active_ + hostname. This is wrong, because it relates to the incoming message (and + probably the interface on which it is arriving) and not to the outgoing + callout (which could be using a different interface). This has been + changed to use the value of the helo_data option from the smtp transport + instead - this is what is used when a message is actually being sent. If + there is no remote transport (possible with a router that sets up host + addresses), $smtp_active_hostname is used. Exim version 4.63 diff --git a/src/README.UPDATING b/src/README.UPDATING index e4975ba6a..45822fdef 100644 --- a/src/README.UPDATING +++ b/src/README.UPDATING @@ -1,4 +1,4 @@ -$Cambridge: exim/src/README.UPDATING,v 1.12 2006/07/13 13:53:33 ph10 Exp $ +$Cambridge: exim/src/README.UPDATING,v 1.13 2006/09/25 11:25:37 ph10 Exp $ This document contains detailed information about incompatibilities that might be encountered when upgrading from one release of Exim to another. The @@ -28,6 +28,20 @@ The rest of this document contains information about changes in 4.xx releases that might affect a running system. +Exim version 4.64 +----------------- + +1. Callouts were setting the name used for EHLO/HELO from $smtp_active_ +hostname. This is wrong, because it relates to the incoming message (and +probably the interface on which it is arriving) and not to the outgoing +callout (which could be using a different interface). This has been +changed to use the value of the helo_data option from the smtp transport +instead - this is what is used when a message is actually being sent. If +there is no remote transport (possible with a router that sets up host +addresses), $smtp_active_hostname is used. This change is mentioned here in +case somebody is relying on the use of $smtp_active_hostname. + + Exim version 4.63 ----------------- diff --git a/src/src/structs.h b/src/src/structs.h index 890867d0a..c5bb3b321 100644 --- a/src/src/structs.h +++ b/src/src/structs.h @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/structs.h,v 1.11 2006/09/19 11:28:45 ph10 Exp $ */ +/* $Cambridge: exim/src/src/structs.h,v 1.12 2006/09/25 11:25:37 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -89,6 +89,7 @@ typedef struct transport_feedback { uschar *port; uschar *protocol; uschar *hosts; + uschar *helo_data; BOOL hosts_override; BOOL hosts_randomize; BOOL gethostbyname; diff --git a/src/src/transports/smtp.c b/src/src/transports/smtp.c index e223bb183..3d7c64e40 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.25 2006/03/09 15:10:16 ph10 Exp $ */ +/* $Cambridge: exim/src/src/transports/smtp.c,v 1.26 2006/09/25 11:25:37 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -203,8 +203,8 @@ static uschar *mail_command; /* Points to MAIL cmd for error messages */ but before running it in a sub-process. It is used for two things: (1) To set the fallback host list in addresses, when delivering. - (2) To pass back the interface, port, and protocol options, for use during - callout verification. + (2) To pass back the interface, port, protocol, and other options, for use + during callout verification. Arguments: tblock pointer to the transport instance block @@ -241,6 +241,7 @@ if (tf != NULL) tf->gethostbyname = ob->gethostbyname; tf->qualify_single = ob->dns_qualify_single; tf->search_parents = ob->dns_search_parents; + tf->helo_data = ob->helo_data; } /* Set the fallback host list for all the addresses that don't have fallback diff --git a/src/src/verify.c b/src/src/verify.c index 783378946..8881926b5 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/verify.c,v 1.38 2006/09/05 13:24:10 ph10 Exp $ */ +/* $Cambridge: exim/src/src/verify.c,v 1.39 2006/09/25 11:25:37 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -389,6 +389,7 @@ for (host = host_list; host != NULL && !done; host = host->next) int host_af; int port = 25; BOOL send_quit = TRUE; + uschar *active_hostname = smtp_active_hostname; uschar *helo = US"HELO"; uschar *interface = NULL; /* Outgoing interface to use; NULL => any */ uschar inbuffer[4096]; @@ -435,6 +436,17 @@ for (host = host_list; host != NULL && !done; host = host->next) log_write(0, LOG_MAIN|LOG_PANIC, "<%s>: %s", addr->address, addr->message); + /* Expand the helo_data string to find the host name to use. */ + + if (tf->helo_data != NULL) + { + uschar *s = expand_string(tf->helo_data); + if (active_hostname == NULL) + log_write(0, LOG_MAIN|LOG_PANIC, "<%s>: failed to expand transport's " + "helo_data value for callout: %s", expand_string_message); + else active_hostname = s; + } + deliver_host = deliver_host_address = NULL; deliver_domain = save_deliver_domain; @@ -481,7 +493,7 @@ for (host = host_list; host != NULL && !done; host = host->next) smtp_read_response(&inblock, responsebuffer, sizeof(responsebuffer), '2', callout) && smtp_write_command(&outblock, FALSE, "%s %s\r\n", helo, - smtp_active_hostname) >= 0 && + active_hostname) >= 0 && smtp_read_response(&inblock, responsebuffer, sizeof(responsebuffer), '2', callout); @@ -1073,10 +1085,21 @@ while (addr_new != NULL) { host_item *host_list = addr->host_list; - /* Default, if no remote transport, to NULL for the interface (=> any), - "smtp" for the port, and "smtp" for the protocol. */ - - transport_feedback tf = { NULL, US"smtp", US"smtp", NULL, FALSE, FALSE }; + /* Make up some data for use in the case where there is no remote + transport. */ + + transport_feedback tf = { + NULL, /* interface (=> any) */ + US"smtp", /* port */ + US"smtp", /* protocol */ + NULL, /* hosts */ + US"$smtp_active_hostname", /* helo_data */ + FALSE, /* hosts_override */ + FALSE, /* hosts_randomize */ + FALSE, /* gethostbyname */ + TRUE, /* qualify_single */ + FALSE /* search_parents */ + }; /* If verification yielded a remote transport, we want to use that transport's options, so as to mimic what would happen if we were really diff --git a/test/confs/0540 b/test/confs/0540 new file mode 100644 index 000000000..641335f6b --- /dev/null +++ b/test/confs/0540 @@ -0,0 +1,53 @@ +# Exim test configuration 0540 + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +rfc1413_query_timeout = 0s +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + +# ----- Main settings ----- + +acl_smtp_rcpt = check_rcpt + +queue_only + + +# ----- ACLs ----- + +begin acl + +check_rcpt: + accept verify = recipient/callout + + +# ----- Routers ----- + +begin routers + +r1: + driver = accept + transport = ${if match {$domain}{^yes}{t1}{t2}} + + +# ----- Transports ----- + +begin transports + +t1: + driver = smtp + hosts = 127.0.0.1 + port = PORT_S + allow_localhost + helo_data = ${if eq{$domain}{yes1}{localhost}{aname}} + +t2: + driver = smtp + hosts = 127.0.0.1 + port = PORT_S + allow_localhost + +# End diff --git a/test/scripts/0000-Basic/0540 b/test/scripts/0000-Basic/0540 new file mode 100644 index 000000000..62bb4fbce --- /dev/null +++ b/test/scripts/0000-Basic/0540 @@ -0,0 +1,52 @@ +# Affixes in RCPT commands for recipient callouts +need_ipv4 +# +server PORT_S 4 +220 Welcome +HELO +250 Hi +MAIL FROM +250 OK +RCPT TO +250 OK +QUIT +250 OK +*eof +220 Welcome +HELO +250 Hi +MAIL FROM +250 OK +RCPT TO +250 OK +QUIT +250 OK +*eof +220 Welcome +HELO +250 Hi +MAIL FROM +250 OK +RCPT TO +250 OK +QUIT +250 OK +*eof +220 Welcome +HELO +250 Hi +MAIL FROM +250 OK +RCPT TO +250 OK +QUIT +250 OK +**** +exim -odq -bs +mail from:<> +RCPT TO: +RCPT TO: +RCPT TO: +RCPT TO: +quit +**** diff --git a/test/stdout/0540 b/test/stdout/0540 new file mode 100644 index 000000000..935f990f1 --- /dev/null +++ b/test/stdout/0540 @@ -0,0 +1,57 @@ +220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 OK +250 Accepted +250 Accepted +250 Accepted +250 Accepted +221 myhost.test.ex closing connection + +******** SERVER ******** +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +HELO localhost +250 Hi +MAIL FROM:<> +250 OK +RCPT TO: +250 OK +QUIT +250 OK +Expected EOF read from client +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +HELO aname +250 Hi +MAIL FROM:<> +250 OK +RCPT TO: +250 OK +QUIT +250 OK +Expected EOF read from client +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +HELO myhost.test.ex +250 Hi +MAIL FROM:<> +250 OK +RCPT TO: +250 OK +QUIT +250 OK +Expected EOF read from client +Listening on port 1224 ... +Connection request from [127.0.0.1] +220 Welcome +HELO myhost.test.ex +250 Hi +MAIL FROM:<> +250 OK +RCPT TO: +250 OK +QUIT +250 OK +End of script -- 2.30.2