Add +ignore_defer and +include_defer to host lists.
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 26 Jun 2007 09:23:34 +0000 (09:23 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Tue, 26 Jun 2007 09:23:34 +0000 (09:23 +0000)
doc/doc-txt/ChangeLog
doc/doc-txt/NewStuff
src/src/match.c
test/confs/0069
test/scripts/0000-Basic/0069
test/stderr/0069
test/stdout/0069

index 7c74094302dabfd960e345a39a196048179858fe..a4a83e70a155927ae9653c50e8d9c19fd3668d40 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.517 2007/06/22 14:38:58 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.518 2007/06/26 09:23:34 ph10 Exp $
 
 Change log file for Exim from version 4.21
 -------------------------------------------
 
 Change log file for Exim from version 4.21
 -------------------------------------------
@@ -69,6 +69,8 @@ PH/10 Added the /noupdate option to the ratelimit ACL condition.
 
 PH/11 Added $max_received_linelength.
 
 
 PH/11 Added $max_received_linelength.
 
+PH/12 Added +ignore_defer and +include_defer to host lists.
+
 
 Exim version 4.67
 -----------------
 
 Exim version 4.67
 -----------------
index 547534ad6c7cc45d322e2c0fa88802fce16b6f22..f61b1f7a3b55168e729bcfbf0bd74a5ab2ebb5de 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.152 2007/06/22 14:38:58 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.153 2007/06/26 09:23:34 ph10 Exp $
 
 New Features in Exim
 --------------------
 
 New Features in Exim
 --------------------
@@ -78,6 +78,10 @@ Version 4.68
     longest line that was received as part of the message, not counting the
     line termination character(s).
 
     longest line that was received as part of the message, not counting the
     line termination character(s).
 
+ 7. Host lists can now include +ignore_defer and +include_defer, analagous to
+    +ignore_unknown and +include_unknown. These options should be used with
+    care, probably only in non-critical host lists such as whitelists.
+
 
 Version 4.67
 ------------
 
 Version 4.67
 ------------
index 01b52ed0e0c77bb49e2d179a5166a34095a55078..ae1d90149b27034dd08e2a93e401adc4d9017c16 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/match.c,v 1.17 2007/01/08 10:50:18 ph10 Exp $ */
+/* $Cambridge: exim/src/src/match.c,v 1.18 2007/06/26 09:23:34 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -444,6 +444,8 @@ int yield = OK;
 unsigned int *original_cache_bits = *cache_ptr;
 BOOL include_unknown = FALSE;
 BOOL ignore_unknown = FALSE;
 unsigned int *original_cache_bits = *cache_ptr;
 BOOL include_unknown = FALSE;
 BOOL ignore_unknown = FALSE;
+BOOL include_defer = FALSE;
+BOOL ignore_defer = FALSE;
 uschar *list;
 uschar *sss;
 uschar *ot = NULL;
 uschar *list;
 uschar *sss;
 uschar *ot = NULL;
@@ -553,10 +555,11 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
       }
     }
 
       }
     }
 
-  /* If the host item is "+include_unknown", remember it in case there's a
-  subsequent failed reverse lookup. */
+  /* If the host item is "+include_unknown" or "+ignore_unknown", remember it
+  in case there's a subsequent failed reverse lookup. There is similar
+  processing for "defer". */
 
 
-  else if (type == MCL_HOST)
+  else if (type == MCL_HOST && *ss == '+')
     {
     if (Ustrcmp(ss, "+include_unknown") == 0)
       {
     {
     if (Ustrcmp(ss, "+include_unknown") == 0)
       {
@@ -570,6 +573,18 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
       include_unknown = FALSE;
       continue;
       }
       include_unknown = FALSE;
       continue;
       }
+    if (Ustrcmp(ss, "+include_defer") == 0)
+      {
+      include_defer = TRUE;
+      ignore_defer = FALSE;
+      continue;
+      }
+    if (Ustrcmp(ss, "+ignore_defer") == 0)
+      {
+      ignore_defer = TRUE;
+      include_defer = FALSE;
+      continue;
+      }
     }
 
   /* Starting with ! specifies a negative item. It is theoretically possible
     }
 
   /* Starting with ! specifies a negative item. It is theoretically possible
@@ -724,6 +739,21 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
         return yield;
 
         case DEFER:
         return yield;
 
         case DEFER:
+        if (error == NULL)
+          error = string_sprintf("DNS lookup of %s deferred", ss);
+        if (ignore_defer)
+          {
+          HDEBUG(D_lists) debug_printf("%s: item ignored by +ignore_defer\n",
+            error);
+          break;
+          }
+        HDEBUG(D_lists) debug_printf("%s %s (%s)\n", ot,
+          include_defer? "yes":"no", error);
+        if (include_defer)
+          {
+          log_write(0, LOG_MAIN, "%s: accepted by +include_defer", error);
+          return OK;
+          }
         goto DEFER_RETURN;
 
         /* The ERROR return occurs when checking hosts, when either a forward
         goto DEFER_RETURN;
 
         /* The ERROR return occurs when checking hosts, when either a forward
@@ -823,7 +853,22 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL)
         return file_yield;
 
         case DEFER:
         return file_yield;
 
         case DEFER:
+        if (error == NULL)
+          error = string_sprintf("DNS lookup of %s deferred", ss);
+        if (ignore_defer)
+          {
+          HDEBUG(D_lists) debug_printf("%s: item ignored by +ignore_defer\n",
+            error);
+          break;
+          }
         (void)fclose(f);
         (void)fclose(f);
+        HDEBUG(D_lists) debug_printf("%s %s (%s)\n", ot,
+          include_defer? "yes":"no", error);
+        if (include_defer)
+          {
+          log_write(0, LOG_MAIN, "%s: accepted by +include_defer", error);
+          return OK;
+          }
         goto DEFER_RETURN;
 
         case ERROR:          /* host name lookup failed - this can only */
         goto DEFER_RETURN;
 
         case ERROR:          /* host name lookup failed - this can only */
index 469c393305f84aafb22e607266ebf26e4c10d666..4e1e70d45f42842a7b76d14500f8226513f6addf 100644 (file)
@@ -37,4 +37,18 @@ check_recipientz:
   accept  hosts = +ignore_unknown : non.existent.invalid : V4NET.0.0.13
   deny    message = "Denied"
 
   accept  hosts = +ignore_unknown : non.existent.invalid : V4NET.0.0.13
   deny    message = "Denied"
 
+check_recipienta:
+  accept  hosts = :
+  deny    hosts = +include_defer : test.again.dns
+  accept  domains = +local_domains
+  deny    message = relay not permitted
+
+check_recipientb:
+  accept  hosts = test.again.dns : V4NET.0.0.13
+  deny    message = "Denied"
+
+check_recipientc:
+  accept  hosts = +ignore_defer : test.again.dns : V4NET.0.0.13
+  deny    message = "Denied"
+
 # End
 # End
index 5afefcec5fd35bb5f14ad993903b7e1560ecfb81..b8ff04a6d3f21f81d224ae41764dea4d66528f2c 100644 (file)
@@ -1,4 +1,4 @@
-# +include_unknown and +ignore_unknown
+# +include_unknown, +ignore_unknown, +include_defer, +ignore_defer
 exim -bh V4NET.0.0.1
 mail from:<x@y>
 rcpt to:<x@test.ex>
 exim -bh V4NET.0.0.1
 mail from:<x@y>
 rcpt to:<x@test.ex>
@@ -24,3 +24,18 @@ MAIL FROM:<userx@test.ex>
 rcpt to:<y@test.ex>
 quit
 ****
 rcpt to:<y@test.ex>
 quit
 ****
+exim -bh V4NET.0.0.13
+MAIL FROM:<userx>
+rcpt to:<a@test.ex>
+quit
+****
+exim -bh V4NET.0.0.13
+MAIL FROM:<userx@test.ex>
+rcpt to:<b@test.ex>
+quit
+****
+exim -bh V4NET.0.0.13
+MAIL FROM:<userx@test.ex>
+rcpt to:<c@test.ex>
+quit
+****
index 8c3bb1f5f91c30f1808816e3bf09724516dc57bb..72ef492baa73c6a7881e9097393e0febd67d4241 100644 (file)
@@ -113,3 +113,66 @@ LOG: list matching forced to fail: failed to find IP address for non.existent.in
 >>> processing "deny"
 >>> deny: condition test succeeded
 LOG: H=[V4NET.0.0.13] F=<userx@test.ex> rejected RCPT <y@test.ex>: "Denied"
 >>> processing "deny"
 >>> deny: condition test succeeded
 LOG: H=[V4NET.0.0.13] F=<userx@test.ex> rejected RCPT <y@test.ex>: "Denied"
+>>> host in hosts_connection_nolog? no (option unset)
+>>> host in host_lookup? no (option unset)
+>>> host in host_reject_connection? no (option unset)
+>>> sender host name required, to match against ^ten-1\.test\.ex
+>>> looking up host name for V4NET.0.0.13
+LOG: no host name found for IP address V4NET.0.0.13
+>>> host in sender_unqualified_hosts? yes (failed to find host name for V4NET.0.0.13)
+LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
+>>> host in recipient_unqualified_hosts? no (option unset)
+>>> host in helo_verify_hosts? no (option unset)
+>>> host in helo_try_verify_hosts? no (option unset)
+>>> host in helo_accept_junk_hosts? no (option unset)
+>>> using ACL "check_recipienta"
+>>> processing "accept"
+>>> check hosts = :
+>>> host in ":"? no (end of list)
+>>> accept: condition test failed
+>>> processing "deny"
+>>> check hosts = +include_defer : test.again.dns
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> host in "+include_defer : test.again.dns"? yes (DNS lookup of test.again.dns deferred)
+LOG: DNS lookup of test.again.dns deferred: accepted by +include_defer
+>>> deny: condition test succeeded
+LOG: H=[V4NET.0.0.13] F=<userx@myhost.test.ex> rejected RCPT <a@test.ex>
+>>> host in hosts_connection_nolog? no (option unset)
+>>> host in host_lookup? no (option unset)
+>>> host in host_reject_connection? no (option unset)
+>>> sender host name required, to match against ^ten-1\.test\.ex
+>>> looking up host name for V4NET.0.0.13
+LOG: no host name found for IP address V4NET.0.0.13
+>>> host in sender_unqualified_hosts? yes (failed to find host name for V4NET.0.0.13)
+LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
+>>> host in recipient_unqualified_hosts? no (option unset)
+>>> host in helo_verify_hosts? no (option unset)
+>>> host in helo_try_verify_hosts? no (option unset)
+>>> host in helo_accept_junk_hosts? no (option unset)
+>>> using ACL "check_recipientb"
+>>> processing "accept"
+>>> check hosts = test.again.dns : V4NET.0.0.13
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> host in "test.again.dns : V4NET.0.0.13"? no (DNS lookup of test.again.dns deferred)
+>>> host in "test.again.dns : V4NET.0.0.13"? list match deferred for test.again.dns
+>>> accept: condition test deferred
+LOG: H=[V4NET.0.0.13] F=<userx@test.ex> temporarily rejected RCPT <b@test.ex>
+>>> host in hosts_connection_nolog? no (option unset)
+>>> host in host_lookup? no (option unset)
+>>> host in host_reject_connection? no (option unset)
+>>> sender host name required, to match against ^ten-1\.test\.ex
+>>> looking up host name for V4NET.0.0.13
+LOG: no host name found for IP address V4NET.0.0.13
+>>> host in sender_unqualified_hosts? yes (failed to find host name for V4NET.0.0.13)
+LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown
+>>> host in recipient_unqualified_hosts? no (option unset)
+>>> host in helo_verify_hosts? no (option unset)
+>>> host in helo_try_verify_hosts? no (option unset)
+>>> host in helo_accept_junk_hosts? no (option unset)
+>>> using ACL "check_recipientc"
+>>> processing "accept"
+>>> check hosts = +ignore_defer : test.again.dns : V4NET.0.0.13
+>>> test.again.dns in dns_again_means_nonexist? no (option unset)
+>>> DNS lookup of test.again.dns deferred: item ignored by +ignore_defer
+>>> host in "+ignore_defer : test.again.dns : V4NET.0.0.13"? yes (matched "V4NET.0.0.13")
+>>> accept: condition test succeeded
index 52d0db340a98e8c4a9d8bcf24ec4f12a064474d8..6a55298b96ee149b8a39a2e143677f1d48ae5456 100644 (file)
 250 OK\r
 550 "Denied"\r
 221 myhost.test.ex closing connection\r
 250 OK\r
 550 "Denied"\r
 221 myhost.test.ex closing connection\r
+
+**** SMTP testing session as if from host V4NET.0.0.13
+**** but without any ident (RFC 1413) callback.
+**** This is not for real!
+
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+550 Administrative prohibition\r
+221 myhost.test.ex closing connection\r
+
+**** SMTP testing session as if from host V4NET.0.0.13
+**** but without any ident (RFC 1413) callback.
+**** This is not for real!
+
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+451 Temporary local problem - please try later\r
+221 myhost.test.ex closing connection\r
+
+**** SMTP testing session as if from host V4NET.0.0.13
+**** but without any ident (RFC 1413) callback.
+**** This is not for real!
+
+220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000\r
+250 OK\r
+250 Accepted\r
+221 myhost.test.ex closing connection\r