Fix logging of delivery port for callout lazy-close, when port specified by router
authorJeremy Harris <jgh146exb@wizmail.org>
Fri, 2 Jun 2017 13:22:42 +0000 (14:22 +0100)
committerJeremy Harris <jgh146exb@wizmail.org>
Sat, 3 Jun 2017 21:04:50 +0000 (22:04 +0100)
doc/doc-txt/ChangeLog
src/src/transports/smtp.c
test/log/2035
test/log/2135
test/stderr/2035
test/stderr/2135

index 7f2e9d097b75663ec0466c8b8806308afe6ee8b0..336935329246f1a89b68d935cf6faf892deb55d4 100644 (file)
@@ -106,6 +106,9 @@ JH/15 Fix a crash in the smtp transport caused when two hosts in succession
       are unsuable for non-message-specific reasons - eg. connection timeout,
       banner-time rejection.
 
       are unsuable for non-message-specific reasons - eg. connection timeout,
       banner-time rejection.
 
+JH/16 Fix logging of delivery remote port, when specified by router, under
+      callout/hold.
+
 
 Exim version 4.89
 -----------------
 
 Exim version 4.89
 -----------------
index dc9e03be1b8c2b3bf1c4a93727d1d926742c4def..d6a52034bb4fe71c9bbf810974a42c476944c729 100644 (file)
@@ -1846,7 +1846,7 @@ else
   else
     {
     sx->inblock.sock = sx->outblock.sock = 0;  /* stdin */
   else
     {
     sx->inblock.sock = sx->outblock.sock = 0;  /* stdin */
-    sx->host->port = sx->port;    /* Record the port that was used */
+    smtp_port_for_connect(sx->host, sx->port); /* Record the port that was used */
     }
   smtp_command = big_buffer;
   sx->helo_data = NULL;                /* ensure we re-expand ob->helo_data */
     }
   smtp_command = big_buffer;
   sx->helo_data = NULL;                /* ensure we re-expand ob->helo_data */
@@ -2660,7 +2660,8 @@ Arguments:
                   failed by one of them.
   host            host to deliver to
   host_af         AF_INET or AF_INET6
                   failed by one of them.
   host            host to deliver to
   host_af         AF_INET or AF_INET6
-  port            default TCP/IP port to use, in host byte order
+  defport         default TCP/IP port to use if host does not specify, in host
+                 byte order
   interface       interface to bind to, or NULL
   tblock          transport instance block
   message_defer   set TRUE if yield is OK, but all addresses were deferred
   interface       interface to bind to, or NULL
   tblock          transport instance block
   message_defer   set TRUE if yield is OK, but all addresses were deferred
@@ -2682,7 +2683,7 @@ Returns:          OK    - the connection was made and the delivery attempted;
 */
 
 static int
 */
 
 static int
-smtp_deliver(address_item *addrlist, host_item *host, int host_af, int port,
+smtp_deliver(address_item *addrlist, host_item *host, int host_af, int defport,
   uschar *interface, transport_instance *tblock,
   BOOL *message_defer, BOOL suppress_tls)
 {
   uschar *interface, transport_instance *tblock,
   BOOL *message_defer, BOOL suppress_tls)
 {
@@ -2705,7 +2706,7 @@ suppress_tls = suppress_tls;  /* stop compiler warning when no TLS support */
 sx.addrlist = addrlist;
 sx.host = host;
 sx.host_af = host_af,
 sx.addrlist = addrlist;
 sx.host = host;
 sx.host_af = host_af,
-sx.port = port;
+sx.port = defport;
 sx.interface = interface;
 sx.helo_data = NULL;
 sx.tblock = tblock;
 sx.interface = interface;
 sx.helo_data = NULL;
 sx.tblock = tblock;
@@ -3661,7 +3662,7 @@ smtp_transport_entry(
   address_item *addrlist)          /* addresses we are working on */
 {
 int cutoff_retry;
   address_item *addrlist)          /* addresses we are working on */
 {
 int cutoff_retry;
-int port;
+int defport;
 int hosts_defer = 0;
 int hosts_fail  = 0;
 int hosts_looked_up = 0;
 int hosts_defer = 0;
 int hosts_fail  = 0;
 int hosts_looked_up = 0;
@@ -3816,7 +3817,7 @@ else if (ob->hosts_randomize && hostlist->mx == MX_NONE && !continue_hostname)
 
 /* Sort out the default port.  */
 
 
 /* Sort out the default port.  */
 
-if (!smtp_get_port(ob->port, addrlist, &port, tid)) return FALSE;
+if (!smtp_get_port(ob->port, addrlist, &defport, tid)) return FALSE;
 
 /* For each host-plus-IP-address on the list:
 
 
 /* For each host-plus-IP-address on the list:
 
@@ -4055,7 +4056,7 @@ for (cutoff_retry = 0;
     the default. */
 
     pistring = string_sprintf(":%d", host->port == PORT_NONE
     the default. */
 
     pistring = string_sprintf(":%d", host->port == PORT_NONE
-      ? port : host->port);
+      ? defport : host->port);
     if (Ustrcmp(pistring, ":25") == 0) pistring = US"";
 
     /* Select IPv4 or IPv6, and choose an outgoing interface. If the interface
     if (Ustrcmp(pistring, ":25") == 0) pistring = US"";
 
     /* Select IPv4 or IPv6, and choose an outgoing interface. If the interface
@@ -4255,7 +4256,7 @@ for (cutoff_retry = 0;
       /* Attempt the delivery. */
 
       total_hosts_tried++;
       /* Attempt the delivery. */
 
       total_hosts_tried++;
-      rc = smtp_deliver(addrlist, thost, host_af, port, interface, tblock,
+      rc = smtp_deliver(addrlist, thost, host_af, defport, interface, tblock,
         &message_defer, FALSE);
 
       /* Yield is one of:
         &message_defer, FALSE);
 
       /* Yield is one of:
@@ -4302,7 +4303,7 @@ for (cutoff_retry = 0;
          "%s: delivering unencrypted to H=%s [%s] (not in hosts_require_tls)",
          first_addr->message, host->name, host->address);
         first_addr = prepare_addresses(addrlist, host);
          "%s: delivering unencrypted to H=%s [%s] (not in hosts_require_tls)",
          first_addr->message, host->name, host->address);
         first_addr = prepare_addresses(addrlist, host);
-        rc = smtp_deliver(addrlist, thost, host_af, port, interface, tblock,
+        rc = smtp_deliver(addrlist, thost, host_af, defport, interface, tblock,
           &message_defer, TRUE);
         if (rc == DEFER && first_addr->basic_errno != ERRNO_AUTHFAIL)
           write_logs(first_addr, host);
           &message_defer, TRUE);
         if (rc == DEFER && first_addr->basic_errno != ERRNO_AUTHFAIL)
           write_logs(first_addr, host);
index 423d9be1306df5cf46f373b84c9492e95557eb89..ea335213ad06d0f657e560aecf3cf06e3b16b192 100644 (file)
@@ -1,5 +1,5 @@
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for userb@test.ex
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for userb@test.ex
-1999-03-02 09:44:33 10HmaX-0005vi-00 => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:25 X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no C="250 OK id=10HmaY-0005vi-00"
+1999-03-02 09:44:33 10HmaX-0005vi-00 => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:1225 X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no C="250 OK id=10HmaY-0005vi-00"
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 Start queue run: pid=pppp
 1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: <userb@test.ex> R=target
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 Start queue run: pid=pppp
 1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: <userb@test.ex> R=target
index ee8d8709a827b9634ece1de1127c21d859b46a2d..50a8dbc1989be48bede9464bf3288a38b4f06556 100644 (file)
@@ -1,5 +1,5 @@
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for userb@test.ex
 1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-smtp S=sss for userb@test.ex
-1999-03-02 09:44:33 10HmaX-0005vi-00 => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:25 X=TLSv1:AES256-SHA:256 CV=no C="250 OK id=10HmaY-0005vi-00"
+1999-03-02 09:44:33 10HmaX-0005vi-00 => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:1225 X=TLSv1:AES256-SHA:256 CV=no C="250 OK id=10HmaY-0005vi-00"
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 Start queue run: pid=pppp
 1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: <userb@test.ex> R=target
 1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
 1999-03-02 09:44:33 Start queue run: pid=pppp
 1999-03-02 09:44:33 10HmaY-0005vi-00 => :blackhole: <userb@test.ex> R=target
index aa0e4380567bb5bb7b862b88559677db68ab19a3..e374950929f074a5bfc20e8c43b104f32994d395 100644 (file)
@@ -50,6 +50,7 @@ already connected to 127.0.0.1 [127.0.0.1] (on fd 0)
 checking status of 127.0.0.1
 127.0.0.1 [127.0.0.1]:1111 retry-status = usable
 delivering 10HmaX-0005vi-00 to 127.0.0.1 [127.0.0.1] (userb@test.ex)
 checking status of 127.0.0.1
 127.0.0.1 [127.0.0.1]:1111 retry-status = usable
 delivering 10HmaX-0005vi-00 to 127.0.0.1 [127.0.0.1] (userb@test.ex)
+Transport port=25 replaced by host-specific port=1225
 continued connection, proxied TLS
   SMTP>> DATA
 cmd buf flush ddd bytes
 continued connection, proxied TLS
   SMTP>> DATA
 cmd buf flush ddd bytes
@@ -65,7 +66,7 @@ cmd buf flush ddd bytes
 Leaving t1 transport
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
 Leaving t1 transport
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
-  => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:25 X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no C="250 OK id=10HmaY-0005vi-00"
+  => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:1225 X=TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256 CV=no C="250 OK id=10HmaY-0005vi-00"
 LOG: MAIN
   Completed
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
   Completed
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
index c61239a11802e263ab267c312b693efd48f603a4..5a4de14ec315bf3e46f8af83ae2fa189a7be3bd1 100644 (file)
@@ -50,6 +50,7 @@ already connected to 127.0.0.1 [127.0.0.1] (on fd 0)
 checking status of 127.0.0.1
 127.0.0.1 [127.0.0.1]:1111 retry-status = usable
 delivering 10HmaX-0005vi-00 to 127.0.0.1 [127.0.0.1] (userb@test.ex)
 checking status of 127.0.0.1
 127.0.0.1 [127.0.0.1]:1111 retry-status = usable
 delivering 10HmaX-0005vi-00 to 127.0.0.1 [127.0.0.1] (userb@test.ex)
+Transport port=25 replaced by host-specific port=1225
 continued connection, proxied TLS
   SMTP>> DATA
 cmd buf flush ddd bytes
 continued connection, proxied TLS
   SMTP>> DATA
 cmd buf flush ddd bytes
@@ -65,7 +66,7 @@ cmd buf flush ddd bytes
 Leaving t1 transport
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
 Leaving t1 transport
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
-  => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:25 X=TLSv1:AES256-SHA:256 CV=no C="250 OK id=10HmaY-0005vi-00"
+  => userb@test.ex R=client T=t1 H=127.0.0.1 [127.0.0.1]:1225 X=TLSv1:AES256-SHA:256 CV=no C="250 OK id=10HmaY-0005vi-00"
 LOG: MAIN
   Completed
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>
 LOG: MAIN
   Completed
 >>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>>