Change callout EHLO/HELO from smtp_active_hostname to the helo_data
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Mon, 25 Sep 2006 11:25:37 +0000 (11:25 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Mon, 25 Sep 2006 11:25:37 +0000 (11:25 +0000)
setting from the transport, when there is one.

doc/doc-txt/ChangeLog
src/README.UPDATING
src/src/structs.h
src/src/transports/smtp.c
src/src/verify.c
test/confs/0540 [new file with mode: 0644]
test/scripts/0000-Basic/0540 [new file with mode: 0644]
test/stdout/0540 [new file with mode: 0644]

index ba67b731549ed972e5bd82c6b7ce4d9f603c29cc..be2b79735257e1ebd13908f2824e132bfcbb048c 100644 (file)
@@ -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
 -------------------------------------------
 
 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/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
 
 
 Exim version 4.63
index e4975ba6a77db839f7eeb6b13400120c890f4caf..45822fdef2c0b4f783bb77e8c6b049c94df4c291 100644 (file)
@@ -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
 
 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.
 
 
 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
 -----------------
 
 Exim version 4.63
 -----------------
 
index 890867d0aad5768cb32591590f8f053f426cf9ec..c5bb3b3215614faa94f63f8254dbce29f0f06e9d 100644 (file)
@@ -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    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -89,6 +89,7 @@ typedef struct transport_feedback {
   uschar *port;
   uschar *protocol;
   uschar *hosts;
   uschar *port;
   uschar *protocol;
   uschar *hosts;
+  uschar *helo_data;
   BOOL   hosts_override;
   BOOL   hosts_randomize;
   BOOL   gethostbyname;
   BOOL   hosts_override;
   BOOL   hosts_randomize;
   BOOL   gethostbyname;
index e223bb183e418530dd399cb1d838330219dde102..3d7c64e40fa16c0c1944dddd3a47b4e41466f001 100644 (file)
@@ -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    *
 
 /*************************************************
 *     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.
 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
 
 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->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
   }
 
 /* Set the fallback host list for all the addresses that don't have fallback
index 7833789464a5f575c0fe1cc47325b5a6fbee581e..8881926b5612fdc2a629e010914bf987e66c8290 100644 (file)
@@ -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    *
 
 /*************************************************
 *     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;
   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];
   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);
 
     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;
 
   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_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);
 
     smtp_read_response(&inblock, responsebuffer, sizeof(responsebuffer),
       '2', callout);
 
@@ -1073,10 +1085,21 @@ while (addr_new != NULL)
       {
       host_item *host_list = addr->host_list;
 
       {
       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
 
       /* 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 (file)
index 0000000..641335f
--- /dev/null
@@ -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 (file)
index 0000000..62bb4fb
--- /dev/null
@@ -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:<abc@yes1> 
+RCPT TO:<def@yes2> 
+RCPT TO:<abc@no> 
+RCPT TO:<def@no> 
+quit
+****
diff --git a/test/stdout/0540 b/test/stdout/0540
new file mode 100644 (file)
index 0000000..935f990
--- /dev/null
@@ -0,0 +1,57 @@
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+250 Accepted\r
+250 Accepted\r
+250 Accepted\r
+221 myhost.test.ex closing connection\r
+
+******** SERVER ********
+Listening on port 1224 ... 
+Connection request from [127.0.0.1]
+220 Welcome
+HELO localhost
+250 Hi
+MAIL FROM:<>
+250 OK
+RCPT TO:<abc@yes1>
+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:<def@yes2>
+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:<abc@no>
+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:<def@no>
+250 OK
+QUIT
+250 OK
+End of script