Don't defer for lists of domains (in dnsdb and dnslists sublists) if any
authorPhilip Hazel <ph10@hermes.cam.ac.uk>
Thu, 25 Nov 2004 14:31:28 +0000 (14:31 +0000)
committerPhilip Hazel <ph10@hermes.cam.ac.uk>
Thu, 25 Nov 2004 14:31:28 +0000 (14:31 +0000)
of the other items is actually found.

doc/doc-txt/NewStuff
src/src/lookups/dnsdb.c
src/src/verify.c

index f8e31469df8de8db129be37b9f5d0dccb77fc284..b4fda862d9e9886bbb700cc480f302ead5f5ac4c 100644 (file)
@@ -1,4 +1,4 @@
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.18 2004/11/25 13:54:31 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.19 2004/11/25 14:31:28 ph10 Exp $
 
 New Features in Exim
 --------------------
@@ -151,9 +151,10 @@ Version 4.44
     default - see 14 below), in the same way that multiple DNS records for a
     single item are handled.
 
-    The lookup fails only if all the DNS lookups fail. As long as at least one
-    of them yields some data, the lookup succeeds. However, if there is a
-    temporary DNS error for any of them, the lookup defers.
+    The dnsdb lookup fails only if all the DNS lookups fail. If there is a
+    temporary DNS error for any of them, the remaining lookups are still done,
+    and only if none of them succeed does the dnsdb lookup defer. As long as at
+    least one of the DNS lookups yields some data, the dnsdb lookup succeeds.
 
 15. It is now possible to specify the character to be used as a separator when
     a dnsdb lookup returns data from more than one DNS record. The default is a
@@ -198,7 +199,11 @@ Version 4.44
        2.1.168.192.black.list.tld  and  a.domain.black.list.tld
 
     Once a DNS record has been found (that matches a specific IP return
-    address, if specified), no further lookups are done.
+    address, if specified), no further lookups are done. If there is a
+    temporary DNS error, the rest of the sublist of domains or IP addresses is
+    tried. The dnslists item itself defers only if none of the other DNS
+    lookups in this sublist succeeds. In other words, a successful lookup for
+    any of the items in the sublist overrides a defer for a previous item.
 
 17. The log selector queue_time_overall causes Exim to output the time spent on
     the queue as an addition to the "Completed" message. Like queue_time (which
index 29a36081e951b0fc4dd6a5bf28fa28b3cc80592f..3f9dc8e7806dc365711a97150a9e5718f5885eab 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/lookups/dnsdb.c,v 1.4 2004/11/24 15:43:36 ph10 Exp $ */
+/* $Cambridge: exim/src/src/lookups/dnsdb.c,v 1.5 2004/11/25 14:31:28 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -103,6 +103,7 @@ int size = 256;
 int ptr = 0;
 int sep = 0;
 int type = T_TXT;
+int failrc = FAIL;
 uschar *outsep = US"\n";
 uschar *equals, *domain;
 uschar buffer[256];
@@ -205,12 +206,17 @@ while ((domain = string_nextinlist(&keystring, &sep, buffer, sizeof(buffer)))
   lookup function so that the facility could be used from other parts of the
   Exim code. The latter affects only what happens later on in this function,
   but for tidiness it is handled in a similar way. If the lookup fails,
-  continue with the next domain. */
+  continue with the next domain. In the case of DEFER, adjust the final 
+  "nothing found" result, but carry on to the next domain. */
   
   rc = dns_special_lookup(&dnsa, domain, type, NULL);
   
   if (rc == DNS_NOMATCH || rc == DNS_NODATA) continue;
-  if (rc != DNS_SUCCEED) return DEFER;
+  if (rc != DNS_SUCCEED)
+    {
+    failrc = DEFER;
+    continue;
+    }
   
   /* Search the returned records */
 
@@ -301,7 +307,7 @@ store_reset(yield + ptr + 1);
 /* If ptr == 0 we have not found anything. Otherwise, insert the terminating 
 zero and return the result. */
 
-if (ptr == 0) return FAIL;
+if (ptr == 0) return failrc;
 yield[ptr] = 0;
 *result = yield;
 return OK;
index 0c1d6b0ebe3b0b56c987ce93f82db02e41affa3f..54a8b2b652694a1b04b992b7f49f5411daa84d5f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/src/src/verify.c,v 1.7 2004/11/22 11:30:04 ph10 Exp $ */
+/* $Cambridge: exim/src/src/verify.c,v 1.8 2004/11/25 14:31:28 ph10 Exp $ */
 
 /*************************************************
 *     Exim - an Internet mail transport agent    *
@@ -2593,6 +2593,7 @@ while ((domain = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL
   else
     {
     int keysep = 0;
+    BOOL defer = FALSE; 
     uschar *keydomain; 
     uschar keybuffer[256];
   
@@ -2625,11 +2626,17 @@ while ((domain = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL
         dnslist_domain = string_copy(domain);
         HDEBUG(D_dnsbl) debug_printf("=> that means %s is listed at %s\n", 
           keydomain, domain);
+        return OK;   
         }
          
-      if (rc != FAIL) return rc;   /* OK or DEFER */
+      /* If the lookup deferred, remember this fact. We keep trying the rest
+      of the list to see if we get a useful result, and if we don't, we return
+      DEFER at the end. */
 
+      if (rc == DEFER) defer = TRUE;
       }    /* continue with next keystring domain/address */
+
+    if (defer) return DEFER;
     }  
   }        /* continue with next dnsdb outer domain */