Handle expansion fails in router "set" options. Bug 3058
authorJeremy Harris <jgh146exb@wizmail.org>
Thu, 7 Dec 2023 19:59:35 +0000 (19:59 +0000)
committerJeremy Harris <jgh146exb@wizmail.org>
Thu, 7 Dec 2023 19:59:35 +0000 (19:59 +0000)
doc/doc-docbook/spec.xfpt
doc/doc-txt/ChangeLog
src/src/route.c
test/confs/0606
test/log/0606
test/mail/0606.b
test/scripts/0000-Basic/0606

index dc8f5cc4d0347419fdfed60b57d6d235d24ee8a8..0007d255e97503f6b79524b3c3583f262c73652f 100644 (file)
@@ -25918,6 +25918,7 @@ permits this.
 .cindex "line length" limit
 This option sets the maximum line length, in bytes, that the transport
 will send.  Any messages with lines exceeding the given value
 .cindex "line length" limit
 This option sets the maximum line length, in bytes, that the transport
 will send.  Any messages with lines exceeding the given value
+(before a transport filter, if any)
 will fail and a failure-DSN ("bounce") message will if possible be returned
 to the sender.
 The default value is that defined by the SMTP standards.
 will fail and a failure-DSN ("bounce") message will if possible be returned
 to the sender.
 The default value is that defined by the SMTP standards.
index 2d82df43d8010a67794413ad532eb6ead75cab74..85064cc8d8beea1651a86592099f635b49722f12 100644 (file)
@@ -49,6 +49,10 @@ JH/09 Bug 3057: Add heuristic for spotting mistyped IPv6 addresses in lists
       documentation, the error results by default in a no-match result for the
       list.  It is logged if the unknown_in_list log_selector is used.
 
       documentation, the error results by default in a no-match result for the
       list.  It is logged if the unknown_in_list log_selector is used.
 
+JH/10 Bug 3058: Ensure that a failing expansion in a router "set" option defers
+      the routing operation.  Previously it would silently stop routing the
+      message.
+
 
 
 Exim version 4.97
 
 
 Exim version 4.97
index 0bd87b83729a841bdaad705caabdadb08836148d..3401f15b415695a1f9bb166a6b8843ea59fcc049 100644 (file)
@@ -1492,7 +1492,11 @@ for (uschar * ele; (ele = string_nextinlist(&varlist, &sep, NULL, 0)); )
       {
       addr->message = string_sprintf("expansion of \"%s\" failed "
        "in %s router: %s", ele, r->name, expand_string_message);
       {
       addr->message = string_sprintf("expansion of \"%s\" failed "
        "in %s router: %s", ele, r->name, expand_string_message);
-      return DEFER;
+      /* Caller will replace that for logging, if a DB lookup, to avoid exposing
+      passwords */
+      DEBUG(D_route) debug_printf("%s\n", addr->message);
+      if (!f.search_find_defer)
+      return f.search_find_defer ? DEFER : FAIL;
       }
 
   if (!(node = tree_search(*root, name)))
       }
 
   if (!(node = tree_search(*root, name)))
@@ -1546,8 +1550,8 @@ route_address(address_item *addr, address_item **paddr_local,
 {
 int yield = OK;
 BOOL unseen;
 {
 int yield = OK;
 BOOL unseen;
-router_instance *r, *nextr;
-const uschar *old_domain = addr->domain;
+router_instance * r, * nextr;
+const uschar * old_domain = addr->domain;
 
 HDEBUG(D_route)
   {
 
 HDEBUG(D_route)
   {
@@ -1561,8 +1565,8 @@ instead of at the first router. */
 
 for (r = addr->start_router ? addr->start_router : routers; r; r = nextr)
   {
 
 for (r = addr->start_router ? addr->start_router : routers; r; r = nextr)
   {
-  uschar *error;
-  struct passwd *pw = NULL;
+  uschar * error;
+  struct passwd * pw = NULL;
   struct passwd pwcopy;
   BOOL loop_detected = FALSE;
   BOOL more;
   struct passwd pwcopy;
   BOOL loop_detected = FALSE;
   BOOL more;
@@ -1736,11 +1740,11 @@ for (r = addr->start_router ? addr->start_router : routers; r; r = nextr)
   router traversal.  On the addr string they are held as a variable tree, so
   as to maintain the post-expansion taints separate. */
 
   router traversal.  On the addr string they are held as a variable tree, so
   as to maintain the post-expansion taints separate. */
 
-  switch (set_router_vars(addr, r))
+  switch (rc = set_router_vars(addr, r))
     {
     case OK:   break;
     case PASS: continue;               /* with next router */
     {
     case OK:   break;
     case PASS: continue;               /* with next router */
-    default:    goto ROUTE_EXIT;
+    default:   yield = rc; goto ROUTE_EXIT;
     }
 
   /* Finally, expand the address_data field in the router. Forced failure
     }
 
   /* Finally, expand the address_data field in the router. Forced failure
index 6388962dbff3420574d2699795eac944458e0f1e..63aa94897fd62e6fe0bd8c2069522e0ef641ff12 100644 (file)
@@ -19,10 +19,21 @@ not_smtp:
 
 begin routers
 
 
 begin routers
 
+dump_bounce:
+  driver =     redirect
+  senders =    :
+  data =       :blackhole:
+
 hide_verifies:
   driver =     accept
   verify_only
 
 hide_verifies:
   driver =     accept
   verify_only
 
+bad:
+  driver =     accept
+  local_parts =        bad
+  set =                r_srs_domain = ${lookup mysql{wrong things
+  transport =  local_delivery
+
 alias:
   driver =     redirect
   debug_print = DEBUG: $r_r1 $r_r2
 alias:
   driver =     redirect
   debug_print = DEBUG: $r_r1 $r_r2
@@ -66,4 +77,8 @@ local_delivery:
   headers_add =        X-r1: <$r_r1>\nX-r2: <$r_r2>\nX-r3: <$r_r3>
 
 
   headers_add =        X-r1: <$r_r1>\nX-r2: <$r_r2>\nX-r3: <$r_r3>
 
 
+# ----- Retry -----
+begin retry
+* * F,5d,10s
+
 # End
 # End
index 58d340f03dcbe22d37f10494e4e1da2141544c5b..718c2d4ffbe5d5580f31ff30e18c5a83155660f3 100644 (file)
@@ -1,3 +1,7 @@
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@test.ex U=CALLER P=local S=sss
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 <= CALLER@test.ex U=CALLER P=local S=sss
+1999-03-02 09:44:33 10HmaX-000000005vi-0000 ** bad@test.ex R=bad: Temporary internal error
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 => b <a@test.ex> R=user T=local_delivery
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 => b <a@test.ex> R=user T=local_delivery
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 <= <> R=10HmaX-000000005vi-0000 U=EXIMUSER P=local S=sss
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 => :blackhole: <CALLER@test.ex> R=dump_bounce
+1999-03-02 09:44:33 10HmaY-000000005vi-0000 Completed
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 Completed
 1999-03-02 09:44:33 10HmaX-000000005vi-0000 Completed
index cd41258500f4b19b84a2d1b85eae788898e1b629..5f9ac43a95da107c426453798c8a1eb220a6574d 100644 (file)
@@ -2,8 +2,7 @@ From bad_check@test.ex Tue Mar 02 09:44:33 1999
 Envelope-to: a@test.ex
 Received: from CALLER by the.local.host.name with local (Exim x.yz)
        (envelope-from <CALLER@test.ex>)
 Envelope-to: a@test.ex
 Received: from CALLER by the.local.host.name with local (Exim x.yz)
        (envelope-from <CALLER@test.ex>)
-       id 10HmaX-000000005vi-0000
-       for a@test.ex;
+       id 10HmaX-000000005vi-0000;
        Tue, 2 Mar 1999 09:44:33 +0000
 Subject: foo
 Message-Id: <E10HmaX-000000005vi-0000@the.local.host.name>
        Tue, 2 Mar 1999 09:44:33 +0000
 Subject: foo
 Message-Id: <E10HmaX-000000005vi-0000@the.local.host.name>
index 96d598834dab457036583759abf77e0a9018167a..5bac064d3df77f0987e54ef1eb529edd3c1256f6 100644 (file)
@@ -1,5 +1,5 @@
 # router variables
 # router variables
-exim -odi a
+exim -odi a bad
 Subject: foo
 
 body
 Subject: foo
 
 body