From d52120f2b5b5464091a61a47fe881a6e8f6ec09f Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 26 Jun 2007 09:23:34 +0000 Subject: [PATCH] Add +ignore_defer and +include_defer to host lists. --- doc/doc-txt/ChangeLog | 4 ++- doc/doc-txt/NewStuff | 6 +++- src/src/match.c | 53 +++++++++++++++++++++++++++--- test/confs/0069 | 14 ++++++++ test/scripts/0000-Basic/0069 | 17 +++++++++- test/stderr/0069 | 63 ++++++++++++++++++++++++++++++++++++ test/stdout/0069 | 27 ++++++++++++++++ 7 files changed, 177 insertions(+), 7 deletions(-) diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 7c7409430..a4a83e70a 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -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 ------------------------------------------- @@ -69,6 +69,8 @@ PH/10 Added the /noupdate option to the ratelimit ACL condition. PH/11 Added $max_received_linelength. +PH/12 Added +ignore_defer and +include_defer to host lists. + Exim version 4.67 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 547534ad6..f61b1f7a3 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -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 -------------------- @@ -78,6 +78,10 @@ Version 4.68 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 ------------ diff --git a/src/src/match.c b/src/src/match.c index 01b52ed0e..ae1d90149 100644 --- a/src/src/match.c +++ b/src/src/match.c @@ -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 * @@ -444,6 +444,8 @@ int yield = OK; 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; @@ -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) { @@ -570,6 +573,18 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) 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 @@ -724,6 +739,21 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) 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 @@ -823,7 +853,22 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) 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); + 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 */ diff --git a/test/confs/0069 b/test/confs/0069 index 469c39330..4e1e70d45 100644 --- a/test/confs/0069 +++ b/test/confs/0069 @@ -37,4 +37,18 @@ check_recipientz: 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 diff --git a/test/scripts/0000-Basic/0069 b/test/scripts/0000-Basic/0069 index 5afefcec5..b8ff04a6d 100644 --- a/test/scripts/0000-Basic/0069 +++ b/test/scripts/0000-Basic/0069 @@ -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: rcpt to: @@ -24,3 +24,18 @@ MAIL FROM: rcpt to: quit **** +exim -bh V4NET.0.0.13 +MAIL FROM: +rcpt to: +quit +**** +exim -bh V4NET.0.0.13 +MAIL FROM: +rcpt to: +quit +**** +exim -bh V4NET.0.0.13 +MAIL FROM: +rcpt to: +quit +**** diff --git a/test/stderr/0069 b/test/stderr/0069 index 8c3bb1f5f..72ef492ba 100644 --- a/test/stderr/0069 +++ b/test/stderr/0069 @@ -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= rejected RCPT : "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= rejected RCPT +>>> 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= temporarily rejected RCPT +>>> 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 diff --git a/test/stdout/0069 b/test/stdout/0069 index 52d0db340..6a55298b9 100644 --- a/test/stdout/0069 +++ b/test/stdout/0069 @@ -43,3 +43,30 @@ 250 OK 550 "Denied" 221 myhost.test.ex closing connection + +**** 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 +250 OK +550 Administrative prohibition +221 myhost.test.ex closing connection + +**** 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 +250 OK +451 Temporary local problem - please try later +221 myhost.test.ex closing connection + +**** 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 +250 OK +250 Accepted +221 myhost.test.ex closing connection -- 2.30.2