Cutthrough: fix multi-message initiating connections. Bug 2230
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 25 Jan 2018 21:27:00 +0000 (21:27 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 25 Jan 2018 22:00:43 +0000 (22:00 +0000)
doc/doc-txt/ChangeLog
src/src/acl.c
src/src/verify.c
test/confs/5400
test/confs/5406 [new symlink]
test/log/5406 [new file with mode: 0644]
test/scripts/5400-cutthrough/5406 [new file with mode: 0644]
test/stdout/5406 [new file with mode: 0644]

index a62d767c9eec3c8c82ba16ea76469f6349ede39a..108f03f84dbeaaf3885d0283facdf81ba7f90601 100644 (file)
@@ -42,6 +42,11 @@ JH/07 Bug 2214: Fix SMTP responses resulting from non-accept result of MIME ACL.
 JH/10 Bug 2223: Fix mysql lookup returns for the no-data case (when the number of
       rows affected is given instead).
 
+JH/12 Bug 2230: Fix cutthrough routing for nonfirst messages in an initiating
+      SMTP connection.  Previously, when one had more receipients than the
+      first, an abortive onward connection was made.  Move to full support for
+      multiple onward connections in sequence, handling cutthrough connection
+      for all multi-message initiating connections.
 
 Exim version 4.90
 -----------------
index 739cd91aea037180d3d61a0177dfeef2a3a3bf00..750fd2da5174ff92090208db2ca7b88b5348940d 100644 (file)
@@ -3293,6 +3293,8 @@ for (; cb != NULL; cb = cb->next)
                p = pp;
                }
              }
+           else
+             DEBUG(D_acl) debug_printf(" cutthrough request ignored for nonfirst rcpt\n");
            break;
            }
          *log_msgptr = string_sprintf("\"control=%s\" on %s item",
@@ -4422,22 +4424,29 @@ switch (where)
     else if (  rc == OK
            && cutthrough.delivery
            && rcpt_count > cutthrough.nrcpt
-           && (rc = open_cutthrough_connection(addr)) == DEFER
            )
-      if (cutthrough.defer_pass)
-       {
-       uschar * s = addr->message;
-       /* Horrid kludge to recover target's SMTP message */
-       while (*s) s++;
-       do --s; while (!isdigit(*s));
-       if (*--s && isdigit(*s) && *--s && isdigit(*s)) *user_msgptr = s;
-       acl_temp_details = TRUE;
-       }
-      else
-       {
-       HDEBUG(D_acl) debug_printf_indent("cutthrough defer; will spool\n");
-       rc = OK;
-       }
+      {
+      if ((rc = open_cutthrough_connection(addr)) == DEFER)
+       if (cutthrough.defer_pass)
+         {
+         uschar * s = addr->message;
+         /* Horrid kludge to recover target's SMTP message */
+         while (*s) s++;
+         do --s; while (!isdigit(*s));
+         if (*--s && isdigit(*s) && *--s && isdigit(*s)) *user_msgptr = s;
+         acl_temp_details = TRUE;
+         }
+       else
+         {
+         HDEBUG(D_acl) debug_printf_indent("cutthrough defer; will spool\n");
+         rc = OK;
+         }
+      }
+    else HDEBUG(D_acl) if (cutthrough.delivery)
+      if (rcpt_count <= cutthrough.nrcpt)
+       debug_printf_indent("ignore cutthrough request; nonfirst message\n");
+      else if (rc != OK)
+       debug_printf_indent("ignore cutthrough request; ACL did not accept\n");
     break;
 
   case ACL_WHERE_PREDATA:
index b957c709b7f0ae0cc79429563efbc738bbb9044d..0f0430b5ee5416f4e26361ecc2ccf0fcdc3deef4 100644 (file)
@@ -1380,6 +1380,7 @@ if(fd >= 0)
   _cutthrough_puts(US"QUIT\r\n", 6);   /* avoid recursion */
   _cutthrough_flush_send();
   cutthrough.fd = -1;                  /* avoid recursion via read timeout */
+  cutthrough.nrcpt = 0;                        /* permit re-cutthrough on subsequent message */
 
   /* Wait a short time for response, and discard it */
   cutthrough_response(fd, '2', NULL, 1);
index 9be13fea6b4f24184306b74fa786ed8de1092f98..5a5e60a8836abf90ece32b7a77b09af6e5bfd4a6 100644 (file)
@@ -1,6 +1,6 @@
 # Exim test configuration 5400
 
-# any options on the cutthrough_delivery contol
+# any options on the cutthrough_delivery control
 CONTROL=
 
 # optional verify-callout
diff --git a/test/confs/5406 b/test/confs/5406
new file mode 120000 (symlink)
index 0000000..8f6811b
--- /dev/null
@@ -0,0 +1 @@
+5400
\ No newline at end of file
diff --git a/test/log/5406 b/test/log/5406
new file mode 100644 (file)
index 0000000..227e696
--- /dev/null
@@ -0,0 +1,18 @@
+1999-03-02 09:44:33 rcpt for userx@domain.com
+1999-03-02 09:44:33 10HmaX-0005vi-00 >> userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaX-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for userx@domain.com
+1999-03-02 09:44:33 10HmaX-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for usery@domain.com
+1999-03-02 09:44:33 10HmaY-0005vi-00 >> usery@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaY-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for usery@domain.com
+1999-03-02 09:44:33 10HmaY-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for userx@domain.com
+1999-03-02 09:44:33 10HmaZ-0005vi-00 >> userx@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmaZ-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for userx@domain.com
+1999-03-02 09:44:33 10HmaZ-0005vi-00 Completed
+1999-03-02 09:44:33 rcpt for usery@domain.com
+1999-03-02 09:44:33 rcpt for userz@domain.com
+1999-03-02 09:44:33 10HmbA-0005vi-00 >> userz@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmbA-0005vi-00 >> usery@domain.com R=all T=smtp H=127.0.0.1 [127.0.0.1] C="250 OK"
+1999-03-02 09:44:33 10HmbA-0005vi-00 <= CALLER@myhost.test.ex U=CALLER P=local-esmtp S=sss for usery@domain.com userz@domain.com
+1999-03-02 09:44:33 10HmbA-0005vi-00 Completed
diff --git a/test/scripts/5400-cutthrough/5406 b/test/scripts/5400-cutthrough/5406
new file mode 100644 (file)
index 0000000..7a46532
--- /dev/null
@@ -0,0 +1,110 @@
+# cutthrough_delivery multiple messages on initiator conn
+need_ipv4
+munge loopback
+#
+# Two single-RCPT messages.
+# Both should get cuttthrough, using separate onward connections
+server PORT_S 2
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+*eof
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+*eof
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<userx@domain.com>
+DATA
+
+.
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<usery@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+#
+#
+#
+# A single-RCPT followed by a double-RCPT message
+# Both should get cuttthrough, using separate onward connections
+server PORT_S 2
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+*eof
+220 ESMTP
+EHLO
+250 OK
+MAIL FROM:
+250 Sender OK
+RCPT TO:
+250 Recipient OK
+RCPT TO:
+250 Recipient OK
+DATA
+354 Send data
+.
+250 OK
+QUIT
+250 OK
+*eof
+****
+exim -bs
+EHLO myhost.test.ex
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<userx@domain.com>
+DATA
+
+.
+MAIL FROM:<CALLER@myhost.test.ex>
+RCPT TO:<usery@domain.com>
+RCPT TO:<userz@domain.com>
+DATA
+
+.
+QUIT
+****
+#
+#
+#
+#
+#
+# End
diff --git a/test/stdout/5406 b/test/stdout/5406
new file mode 100644 (file)
index 0000000..773c25d
--- /dev/null
@@ -0,0 +1,140 @@
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250-myhost.test.ex Hello CALLER at myhost.test.ex\r
+250-SIZE 52428800\r
+250-8BITMIME\r
+250-PIPELINING\r
+250 HELP\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaX-0005vi-00\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaY-0005vi-00\r
+221 myhost.test.ex closing connection\r
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250-myhost.test.ex Hello CALLER at myhost.test.ex\r
+250-SIZE 52428800\r
+250-8BITMIME\r
+250-PIPELINING\r
+250 HELP\r
+250 OK\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmaZ-0005vi-00\r
+250 OK\r
+250 Accepted\r
+250 Accepted\r
+354 Enter message, ending with "." on a line by itself\r
+250 OK id=10HmbA-0005vi-00\r
+221 myhost.test.ex closing connection\r
+
+******** SERVER ********
+Listening on port 1224 ... 
+Connection request from [ip4.ip4.ip4.ip4]
+220 ESMTP
+EHLO myhost.test.ex
+250 OK
+MAIL FROM:<CALLER@myhost.test.ex>
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+Received: from CALLER (helo=myhost.test.ex)
+       by myhost.test.ex with local-esmtp (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmaX-0005vi-00
+       for userx@domain.com; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmaX-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+X-hdr-rtr-new: +++
+
+.
+250 OK
+QUIT
+250 OK
+Expected EOF read from client
+Listening on port 1224 ... 
+Connection request from [ip4.ip4.ip4.ip4]
+220 ESMTP
+EHLO myhost.test.ex
+250 OK
+MAIL FROM:<CALLER@myhost.test.ex>
+250 Sender OK
+RCPT TO:<usery@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+Received: from CALLER (helo=myhost.test.ex)
+       by myhost.test.ex with local-esmtp (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmaY-0005vi-00
+       for usery@domain.com; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmaY-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+X-hdr-rtr-new: +++
+
+.
+250 OK
+QUIT
+250 OK
+Expected EOF read from client
+End of script
+Listening on port 1224 ... 
+Connection request from [ip4.ip4.ip4.ip4]
+220 ESMTP
+EHLO myhost.test.ex
+250 OK
+MAIL FROM:<CALLER@myhost.test.ex>
+250 Sender OK
+RCPT TO:<userx@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+Received: from CALLER (helo=myhost.test.ex)
+       by myhost.test.ex with local-esmtp (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmaZ-0005vi-00
+       for userx@domain.com; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmaZ-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+X-hdr-rtr-new: +++
+
+.
+250 OK
+QUIT
+250 OK
+Expected EOF read from client
+Listening on port 1224 ... 
+Connection request from [ip4.ip4.ip4.ip4]
+220 ESMTP
+EHLO myhost.test.ex
+250 OK
+MAIL FROM:<CALLER@myhost.test.ex>
+250 Sender OK
+RCPT TO:<usery@domain.com>
+250 Recipient OK
+RCPT TO:<userz@domain.com>
+250 Recipient OK
+DATA
+354 Send data
+Received: from CALLER (helo=myhost.test.ex)
+       by myhost.test.ex with local-esmtp (Exim x.yz)
+       (envelope-from <CALLER@myhost.test.ex>)
+       id 10HmbA-0005vi-00; Tue, 2 Mar 1999 09:44:33 +0000
+Message-Id: <E10HmbA-0005vi-00@myhost.test.ex>
+From: CALLER_NAME <CALLER@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+X-hdr-rtr-new: +++
+
+.
+250 OK
+QUIT
+250 OK
+Expected EOF read from client
+End of script