X-Git-Url: https://git.exim.org/exim.git/blobdiff_plain/7e66e54dcf419ff995a49250902ae71a73228373..3386088d5af4d4c61faa12ae29560e2c5bd43304:/src/src/routers/rf_lookup_hostlist.c diff --git a/src/src/routers/rf_lookup_hostlist.c b/src/src/routers/rf_lookup_hostlist.c index d146e02c7..fefc1a4ed 100644 --- a/src/src/routers/rf_lookup_hostlist.c +++ b/src/src/routers/rf_lookup_hostlist.c @@ -1,10 +1,8 @@ -/* $Cambridge: exim/src/src/routers/rf_lookup_hostlist.c,v 1.5 2005/12/06 10:25:59 ph10 Exp $ */ - /************************************************* * Exim - an Internet mail transport agent * *************************************************/ -/* Copyright (c) University of Cambridge 1995 - 2005 */ +/* Copyright (c) University of Cambridge 1995 - 2015 */ /* See the file NOTICE for conditions of use and distribution. */ @@ -64,13 +62,13 @@ list of MX hosts. If the first host is the local host, act according to the "self" option in the configuration. */ prev = NULL; -for (h = addr->host_list; h != NULL; prev = h, h = next_h) +for (h = addr->host_list; h != NULL; h = next_h) { - uschar *canonical_name; + const uschar *canonical_name; int rc, len, port; next_h = h->next; - if (h->address != NULL) continue; + if (h->address != NULL) { prev = h; continue; } DEBUG(D_route|D_host_lookup) debug_printf("finding IP address for %s\n", h->name); @@ -96,6 +94,7 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) NULL, /* SRV service not relevant */ NULL, /* failing srv domains not relevant */ NULL, /* no special mx failing domains */ + &rblock->dnssec, /* dnssec request/require */ NULL, /* fully_qualified_name */ NULL); /* indicate local host removed */ } @@ -106,7 +105,8 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) else if (lookup_type == lk_byname || string_is_ip_address(h->name, NULL) != 0) { DEBUG(D_route|D_host_lookup) debug_printf("calling host_find_byname\n"); - rc = host_find_byname(h, ignore_target_hosts, &canonical_name, TRUE); + rc = host_find_byname(h, ignore_target_hosts, HOST_FIND_QUALIFY_SINGLE, + &canonical_name, TRUE); } /* Otherwise, do a DNS lookup. If that yields "host not found", and the @@ -118,7 +118,9 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) BOOL removed; DEBUG(D_route|D_host_lookup) debug_printf("doing DNS lookup\n"); rc = host_find_bydns(h, ignore_target_hosts, HOST_FIND_BY_A, NULL, NULL, - NULL, &canonical_name, &removed); + NULL, + &rblock->dnssec, /* domains for request/require */ + &canonical_name, &removed); if (rc == HOST_FOUND) { if (removed) setflag(addr, af_local_host_removed); @@ -129,7 +131,8 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) { DEBUG(D_route|D_host_lookup) debug_printf("DNS lookup failed: trying getipnodebyname\n"); - rc = host_find_byname(h, ignore_target_hosts, &canonical_name, TRUE); + rc = host_find_byname(h, ignore_target_hosts, HOST_FIND_QUALIFY_SINGLE, + &canonical_name, TRUE); } } } @@ -155,9 +158,16 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) if (rc == HOST_FIND_FAILED) { + if (hff_code == hff_ignore) + { + if (prev == NULL) addr->host_list = next_h; else prev->next = next_h; + continue; /* With the next host, leave prev unchanged */ + } + if (hff_code == hff_pass) return PASS; if (hff_code == hff_decline) return DECLINE; + addr->basic_errno = ERRNO_UNKNOWNHOST; addr->message = string_sprintf("lookup of host \"%s\" failed in %s router%s", h->name, rblock->name, @@ -204,6 +214,12 @@ for (h = addr->host_list; h != NULL; prev = h, h = next_h) } self_send = TRUE; } + + /* Ensure that prev is the host before next_h; this will not be h if a lookup + found multiple addresses or multiple MX records. */ + + prev = h; + while (prev->next != next_h) prev = prev->next; } return OK;