From 4a452c432a063c45bca4079acb5f654cb0ec5d6d Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 5 May 2015 22:50:56 +0100 Subject: [PATCH 1/1] Log reason for defer, on a hostlist dns-lookup temporary error. Bug 1328 --- src/src/acl.c | 6 +++--- src/src/host.c | 8 ++++---- src/src/match.c | 3 ++- test/confs/0605 | 17 +++++++++++++++++ test/scripts/0000-Basic/0605 | 10 ++++++++++ test/stderr/0069 | 6 +++--- test/stderr/0605 | 15 +++++++++++++++ test/stdout/0605 | 10 ++++++++++ 8 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 test/confs/0605 create mode 100644 test/scripts/0000-Basic/0605 create mode 100644 test/stderr/0605 create mode 100644 test/stdout/0605 diff --git a/src/src/acl.c b/src/src/acl.c index aa9f58f2c..b42492d88 100644 --- a/src/src/acl.c +++ b/src/src/acl.c @@ -3582,7 +3582,8 @@ for (; cb != NULL; cb = cb->next) rc = verify_check_this_host(&arg, sender_host_cache, NULL, (sender_host_address == NULL)? US"" : sender_host_address, CUSS &host_data); - if (host_data != NULL) host_data = string_copy_malloc(host_data); + if (rc == DEFER) *log_msgptr = search_error_message; + if (host_data) host_data = string_copy_malloc(host_data); break; case ACLC_LOCAL_PARTS: @@ -3597,8 +3598,7 @@ for (; cb != NULL; cb = cb->next) int sep = 0; const uschar *s = arg; uschar *ss; - while ((ss = string_nextinlist(&s, &sep, big_buffer, big_buffer_size)) - != NULL) + while ((ss = string_nextinlist(&s, &sep, big_buffer, big_buffer_size))) { if (Ustrcmp(ss, "main") == 0) logbits |= LOG_MAIN; else if (Ustrcmp(ss, "panic") == 0) logbits |= LOG_PANIC; diff --git a/src/src/host.c b/src/src/host.c index f6c8faac7..4d76fc4a3 100644 --- a/src/src/host.c +++ b/src/src/host.c @@ -1995,11 +1995,11 @@ for (i = 1; i <= times; switch (error_num) { case HOST_NOT_FOUND: error = US"HOST_NOT_FOUND"; break; - case TRY_AGAIN: error = US"TRY_AGAIN"; break; - case NO_RECOVERY: error = US"NO_RECOVERY"; break; - case NO_DATA: error = US"NO_DATA"; break; + case TRY_AGAIN: error = US"TRY_AGAIN"; break; + case NO_RECOVERY: error = US"NO_RECOVERY"; break; + case NO_DATA: error = US"NO_DATA"; break; #if NO_DATA != NO_ADDRESS - case NO_ADDRESS: error = US"NO_ADDRESS"; break; + case NO_ADDRESS: error = US"NO_ADDRESS"; break; #endif default: error = US"?"; break; } diff --git a/src/src/match.c b/src/src/match.c index 5bf4ef5d8..893ff4863 100644 --- a/src/src/match.c +++ b/src/src/match.c @@ -740,7 +740,7 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) case DEFER: if (error == NULL) - error = string_sprintf("DNS lookup of %s deferred", ss); + error = string_sprintf("DNS lookup of \"%s\" deferred", ss); if (ignore_defer) { HDEBUG(D_lists) debug_printf("%s: item ignored by +ignore_defer\n", @@ -752,6 +752,7 @@ while ((sss = string_nextinlist(&list, &sep, buffer, sizeof(buffer))) != NULL) log_write(0, LOG_MAIN, "%s: accepted by +include_defer", error); return OK; } + if (!search_error_message) search_error_message = error; goto DEFER_RETURN; /* The ERROR return occurs when checking hosts, when either a forward diff --git a/test/confs/0605 b/test/confs/0605 new file mode 100644 index 000000000..32c7b286f --- /dev/null +++ b/test/confs/0605 @@ -0,0 +1,17 @@ +# Exim test configuration 0605 + +exim_path = EXIM_PATH +host_lookup_order = bydns +spool_directory = DIR/spool +log_file_path = DIR/spool/log/SERVER%slog +gecos_pattern = "" +gecos_name = CALLER_NAME + +# ----- Main settings ----- + +acl_smtp_rcpt = accept hosts = test.again.dns + +queue_only + +# End + diff --git a/test/scripts/0000-Basic/0605 b/test/scripts/0000-Basic/0605 new file mode 100644 index 000000000..79652be65 --- /dev/null +++ b/test/scripts/0000-Basic/0605 @@ -0,0 +1,10 @@ +# dns retry in hostlist +# Exim test configuration 0605 +# +# +exim -bh HOSTIPV4 +helo test +mail from: +rcpt to: +quit +**** diff --git a/test/stderr/0069 b/test/stderr/0069 index df768dde2..9008167df 100644 --- a/test/stderr/0069 +++ b/test/stderr/0069 @@ -140,7 +140,7 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown >>> processing "deny" >>> check hosts = +include_defer : test.again.dns >>> test.again.dns in dns_again_means_nonexist? no (option unset) -LOG: DNS lookup of test.again.dns deferred: accepted by +include_defer +LOG: DNS lookup of "test.again.dns" deferred: accepted by +include_defer >>> deny: condition test succeeded in ACL "check_recipienta" >>> end of ACL "check_recipienta": DENY LOG: H=[V4NET.0.0.13] F= rejected RCPT @@ -162,7 +162,7 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown >>> test.again.dns in dns_again_means_nonexist? no (option unset) >>> host in "test.again.dns : V4NET.0.0.13"? list match deferred for test.again.dns >>> accept: condition test deferred in ACL "check_recipientb" -LOG: H=[V4NET.0.0.13] F= temporarily rejected RCPT +LOG: H=[V4NET.0.0.13] F= temporarily rejected RCPT : DNS lookup of "test.again.dns" deferred >>> host in hosts_connection_nolog? no (option unset) >>> host in host_lookup? no (option unset) >>> host in host_reject_connection? no (option unset) @@ -179,7 +179,7 @@ LOG: failed to find host name for V4NET.0.0.13: accepted by +include_unknown >>> 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 +>>> 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 in ACL "check_recipientc" >>> end of ACL "check_recipientc": ACCEPT diff --git a/test/stderr/0605 b/test/stderr/0605 new file mode 100644 index 000000000..9e144d402 --- /dev/null +++ b/test/stderr/0605 @@ -0,0 +1,15 @@ +>>> host in hosts_connection_nolog? no (option unset) +>>> host in host_lookup? no (option unset) +>>> 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) +>>> test in helo_lookup_domains? no (end of list) +>>> processing "accept" +>>> check hosts = test.again.dns +>>> test.again.dns in dns_again_means_nonexist? no (option unset) +>>> host in "test.again.dns"? list match deferred for test.again.dns +>>> accept: condition test deferred in inline ACL +LOG: H=(test) [ip4.ip4.ip4.ip4] F= temporarily rejected RCPT : DNS lookup of "test.again.dns" deferred diff --git a/test/stdout/0605 b/test/stdout/0605 new file mode 100644 index 000000000..64db9998c --- /dev/null +++ b/test/stdout/0605 @@ -0,0 +1,10 @@ + +**** SMTP testing session as if from host ip4.ip4.ip4.ip4 +**** but without any ident (RFC 1413) callback. +**** This is not for real! + +220 the.local.host.name ESMTP Exim x.yz Tue, 2 Mar 1999 09:44:33 +0000 +250 the.local.host.name Hello test [ip4.ip4.ip4.ip4] +250 OK +451 Temporary local problem - please try later +221 the.local.host.name closing connection -- 2.25.1