resolved: correctly handle non-address RR types with /etc/hosts lookups (#4808)

Fix wrong condition test in manager_etc_hosts_lookup(), which caused it to
return an IPv4 answer when an IPv6 question was asked, and vice versa.
Also only return success if we actually found any A or AAAA record.

In systemd-resolved.service(8), point out that /etc/hosts mappings only
affect address-type lookups, not other types.

The test case currently disables DNSSEC in resolved, as there is a bug
where "-t MX" fails due to "DNSSEC validation failed" even after
"downgrading to non-DNSSEC mode". This should be dropped once that bug
gets fixed.

Fixes #4801
This commit is contained in:
Martin Pitt
2016-12-22 07:58:02 +01:00
committed by GitHub
parent eb64b435eb
commit 4050e04b2c
3 changed files with 61 additions and 5 deletions
+3 -3
View File
@@ -431,8 +431,8 @@ int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer) {
for (i = 0; i < bn->n_items; i++) {
_cleanup_(dns_resource_record_unrefp) DnsResourceRecord *rr = NULL;
if ((found_a && bn->items[i]->family != AF_INET) &&
(found_aaaa && bn->items[i]->family != AF_INET6))
if ((!found_a && bn->items[i]->family == AF_INET) ||
(!found_aaaa && bn->items[i]->family == AF_INET6))
continue;
r = dns_resource_record_new_address(&rr, bn->items[i]->family, &bn->items[i]->address, bn->name);
@@ -444,5 +444,5 @@ int manager_etc_hosts_lookup(Manager *m, DnsQuestion* q, DnsAnswer **answer) {
return r;
}
return 1;
return found_a || found_aaaa;
}