From 9b8fadde9b0b4b04124f69996c378958fd5b0127 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Tue, 4 Apr 2006 11:18:30 +0000 Subject: [PATCH] Make dns_again_means_nonexist apply to gethostbyname lookups as well. --- doc/doc-txt/ChangeLog | 6 ++- src/src/host.c | 32 +++++++++++++--- src/src/verify.c | 3 +- test/confs/0533 | 30 +++++++++++++++ test/scripts/0000-Basic/0533 | 6 +++ test/stderr/0533 | 73 ++++++++++++++++++++++++++++++++++++ test/stdout/0533 | 9 +++++ 7 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 test/confs/0533 create mode 100644 test/scripts/0000-Basic/0533 create mode 100644 test/stderr/0533 create mode 100644 test/stdout/0533 diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index fcf835025..bf092ca4f 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -1,4 +1,4 @@ -$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.337 2006/04/04 09:09:44 ph10 Exp $ +$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.338 2006/04/04 11:18:31 ph10 Exp $ Change log file for Exim from version 4.21 ------------------------------------------- @@ -352,6 +352,10 @@ PH/71 Fixed an obscure and subtle bug (thanks Alexander & Matthias). The this was missing, in the iplookup router, which I don't think anybody now uses, but I've fixed it anyway. +PH/72 Make dns_again_means_nonexist apply to lookups using gethostbyname() as + well as to direct DNS lookups. Otherwise the handling of names in host + lists is inconsistent and therefore confusing. + Exim version 4.60 ----------------- diff --git a/src/src/host.c b/src/src/host.c index 01191f454..4d637fb51 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/host.c,v 1.23 2006/03/17 16:51:45 ph10 Exp $ */ +/* $Cambridge: exim/src/src/host.c,v 1.24 2006/04/04 11:18:31 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1890,13 +1890,13 @@ int af; #endif /* If we are in the test harness, a name ending in .test.again.dns always -forces a temporary error response. */ +forces a temporary error response, unless the name is in +dns_again_means_nonexist. */ if (running_in_test_harness) { uschar *endname = host->name + Ustrlen(host->name); - if (Ustrcmp(endname - 14, "test.again.dns") == 0) - return HOST_FIND_AGAIN; + if (Ustrcmp(endname - 14, "test.again.dns") == 0) goto RETURN_AGAIN; } /* In an IPv6 world, unless IPv6 has been disabled, we need to scan for both @@ -2071,7 +2071,7 @@ if (host->address == NULL) string_sprintf("no IP address found for host %s", host->name); HDEBUG(D_host_lookup) debug_printf("%s\n", msg); - if (temp_error) return HOST_FIND_AGAIN; + if (temp_error) goto RETURN_AGAIN; if (host_checking || !log_testing_mode) log_write(L_host_lookup_failed, LOG_MAIN, "%s", msg); return HOST_FIND_FAILED; @@ -2108,6 +2108,28 @@ HDEBUG(D_host_lookup) /* Return the found status. */ return yield; + +/* Handle the case when there is a temporary error. If the name matches +dns_again_means_nonexist, return permanent rather than temporary failure. */ + +RETURN_AGAIN: + { + #ifndef STAND_ALONE + int rc; + uschar *save = deliver_domain; + deliver_domain = host->name; /* set $domain */ + rc = match_isinlist(host->name, &dns_again_means_nonexist, 0, NULL, NULL, + MCL_DOMAIN, TRUE, NULL); + deliver_domain = save; + if (rc == OK) + { + DEBUG(D_host_lookup) debug_printf("%s is in dns_again_means_nonexist: " + "returning HOST_FIND_FAILED\n", host->name); + return HOST_FIND_FAILED; + } + #endif + return HOST_FIND_AGAIN; + } } diff --git a/src/src/verify.c b/src/src/verify.c index 8776700a0..93d9f582d 100644 --- a/src/src/verify.c +++ b/src/src/verify.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/verify.c,v 1.35 2006/03/16 12:07:55 ph10 Exp $ */ +/* $Cambridge: exim/src/src/verify.c,v 1.36 2006/04/04 11:18:31 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -2125,6 +2125,7 @@ if (*t == 0) h.name = ss; h.address = NULL; h.mx = MX_NONE; + rc = host_find_byname(&h, NULL, NULL, FALSE); if (rc == HOST_FOUND || rc == HOST_FOUND_LOCAL) { diff --git a/test/confs/0533 b/test/confs/0533 new file mode 100644 index 000000000..8727cc3fb --- /dev/null +++ b/test/confs/0533 @@ -0,0 +1,30 @@ +# Exim test configuration 0533 + +CONNECTCOND= + +exim_path = EXIM_PATH +host_lookup_order = bydns +primary_hostname = myhost.test.ex +rfc1413_query_timeout = 0s +spool_directory = DIR/spool +log_file_path = DIR/spool/log/%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + +# ----- Main settings ----- + +acl_smtp_rcpt = rcpt +dns_again_means_nonexist = * +disable_ipv6 + +# ----- ACL ----- + +begin acl + +rcpt: + accept hosts = +ignore_unknown : \ + *.$sender_address_domain : \ + $sender_address_domain : \ + ${lookup dnsdb{>:defer_never,mxh=$sender_address_domain}} + +# End diff --git a/test/scripts/0000-Basic/0533 b/test/scripts/0000-Basic/0533 new file mode 100644 index 000000000..0f0651d6f --- /dev/null +++ b/test/scripts/0000-Basic/0533 @@ -0,0 +1,6 @@ +# dns_again_means_nonexist +exim -d -bh HOSTIPV4 +mail from: +rcpt to: +quit +**** diff --git a/test/stderr/0533 b/test/stderr/0533 new file mode 100644 index 000000000..be4943468 --- /dev/null +++ b/test/stderr/0533 @@ -0,0 +1,73 @@ +Exim version x.yz .... +changed uid/gid: forcing real = effective + uid=uuuu gid=CALLER_GID pid=pppp +configuration file is TESTSUITE/test-config +admin user +changed uid/gid: privilege not needed + uid=EXIM_UID gid=EXIM_GID pid=pppp +originator: uid=CALLER_UID gid=CALLER_GID login=CALLER name=CALLER_NAME +sender address = CALLER@myhost.test.ex +sender_fullhost = [ip4.ip4.ip4.ip4] +sender_rcvhost = [ip4.ip4.ip4.ip4] +host in hosts_connection_nolog? no (option unset) +LOG: smtp_connection MAIN + SMTP connection from [ip4.ip4.ip4.ip4] +host in host_lookup? no (option unset) +set_process_info: pppp handling incoming connection from [ip4.ip4.ip4.ip4] +host in host_reject_connection? no (option unset) +host in sender_unqualified_hosts? no (option unset) +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) +SMTP>> 220 myhost.test.ex ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +smtp_setup_msg entered +SMTP<< mail from: +SMTP>> 250 OK +SMTP<< rcpt to: +using ACL "rcpt" +processing "accept" +check hosts = +ignore_unknown : *.$sender_address_domain : $sender_address_domain : ${lookup dnsdb{>:defer_never,mxh=$sender_address_domain}} +search_open: dnsdb "NULL" +search_find: file="NULL" + key=">:defer_never,mxh=cioce.test.again.dns" partial=-1 affix=NULL starflags=0 +LRU list: +internal_search_find: file="NULL" + type=dnsdb key=">:defer_never,mxh=cioce.test.again.dns" +database lookup required for >:defer_never,mxh=cioce.test.again.dns +dnsdb key: cioce.test.again.dns +Return from DNS lookup of cioce.test.again.dns (MX) faked for testing +DNS lookup of cioce.test.again.dns (MX) gave TRY_AGAIN +cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*") +cioce.test.again.dns is in dns_again_means_nonexist: returning DNS_NOMATCH +lookup failed +sender host name required, to match against *.cioce.test.again.dns +looking up host name for ip4.ip4.ip4.ip4 +DNS lookup of 206.10.111.131.in-addr.arpa (PTR) using fakens +DNS lookup of 206.10.111.131.in-addr.arpa (PTR) succeeded +IP address lookup yielded the.local.host.name +using host_fake_gethostbyname for the.local.host.name (IPv4) +DNS lookup of the.local.host.name (A) using fakens +DNS lookup of the.local.host.name (A) succeeded +MUNGED: ::1 will be omitted in what follows +get[host|ipnode]byname[2] looked up these IP addresses: + name=the.local.host.name address=ip4.ip4.ip4.ip4 +checking addresses for the.local.host.name + ip4.ip4.ip4.ip4 OK +sender_fullhost = the.local.host.name [ip4.ip4.ip4.ip4] +sender_rcvhost = the.local.host.name ([ip4.ip4.ip4.ip4]) +cioce.test.again.dns in dns_again_means_nonexist? yes (matched "*") +cioce.test.again.dns is in dns_again_means_nonexist: returning HOST_FIND_FAILED +failed to find IP address for cioce.test.again.dns: item ignored by +ignore_unknown +host in "+ignore_unknown : *.cioce.test.again.dns : cioce.test.again.dns : "? no (end of list) +accept: condition test failed +end of ACL "rcpt": implicit DENY +SMTP>> 550 Administrative prohibition +LOG: MAIN REJECT + H=the.local.host.name [ip4.ip4.ip4.ip4] F= rejected RCPT +SMTP<< quit +SMTP>> 221 myhost.test.ex closing connection +LOG: smtp_connection MAIN + SMTP connection from the.local.host.name [ip4.ip4.ip4.ip4] closed by QUIT +search_tidyup called +>>>>>>>>>>>>>>>> Exim pid=pppp terminating with rc=0 >>>>>>>>>>>>>>>> diff --git a/test/stdout/0533 b/test/stdout/0533 new file mode 100644 index 000000000..bcb3fa204 --- /dev/null +++ b/test/stdout/0533 @@ -0,0 +1,9 @@ + +**** SMTP testing session as if from host ip4.ip4.ip4.ip4 +**** 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 -- 2.25.1