summaryrefslogtreecommitdiff
path: root/source4/libcli/resolve
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2011-11-02 09:39:23 +0100
committerMatthieu Patou <mat@samba.org>2011-11-02 11:15:34 +0100
commit251209bd6f6e66ca9bcf28cd652d85d1cd729fdc (patch)
tree3ad50c53a1dc75069615e5b65743af7219944fa3 /source4/libcli/resolve
parent6b11c9119fa3e2ea401f86873273533d673e04fa (diff)
downloadsamba-251209bd6f6e66ca9bcf28cd652d85d1cd729fdc.tar.gz
samba-251209bd6f6e66ca9bcf28cd652d85d1cd729fdc.tar.bz2
samba-251209bd6f6e66ca9bcf28cd652d85d1cd729fdc.zip
s4-resolver: make it work back with ipv4 only DNS records
It turns out that if there is no AAAA record the dns server (bind and MS windows at least) do not return the A record when just asked for AAAA. Autobuild-User: Matthieu Patou <mat@samba.org> Autobuild-Date: Wed Nov 2 11:15:34 CET 2011 on sn-devel-104
Diffstat (limited to 'source4/libcli/resolve')
-rw-r--r--source4/libcli/resolve/dns_ex.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c
index 60e9afda37..993ef43caa 100644
--- a/source4/libcli/resolve/dns_ex.c
+++ b/source4/libcli/resolve/dns_ex.c
@@ -178,29 +178,38 @@ static struct dns_records_container get_a_aaaa_records(TALLOC_CTX *mem_ctx,
to avoid them in the parent */
reply = rk_dns_lookup(name, "AAAA");
- if (!reply) {
- return ret;
- }
+ count = count2 = 0;
+
+ if (reply) {
+
+ count = count_dns_rr(reply->head, rk_ns_t_aaaa);
+ count2 = count_dns_rr(reply->head, rk_ns_t_a);
+
+ if (!count2) {
+ /*
+ * DNS server didn't returned A when asked for AAAA records.
+ * Most of the server do it, let's ask for A specificaly.
+ */
+ reply2 = rk_dns_lookup(name, "A");
- count = count_dns_rr(reply->head, rk_ns_t_aaaa);
- count2 = count_dns_rr(reply->head, rk_ns_t_a);
+ if (!reply2) {
+ return ret;
+ }
- if (!count2) {
- /*
- * DNS server didn't returned A when asked for AAAA records.
- * Most of the server do it, let's ask for A specificaly.
- */
- reply2 = rk_dns_lookup(name, "A");
+ count2 = count_dns_rr(reply2->head, rk_ns_t_a);
+ } else {
+ reply2 = NULL;
+ }
+ } else {
- if (!reply2) {
+ reply = rk_dns_lookup(name, "A");
+ if (!reply) {
return ret;
}
- count2 = count_dns_rr(reply2->head, rk_ns_t_a);
- } else {
reply2 = NULL;
+ count = count_dns_rr(reply->head, rk_ns_t_a);
}
-
count += count2;
if (count == 0) {
@@ -322,7 +331,7 @@ static struct dns_records_container get_srv_records(TALLOC_CTX *mem_ctx,
addrs = talloc_realloc(mem_ctx, addrs, char*, total);
for (j=0; j < c.count; j++) {
- addrs[total - j] = talloc_steal(addrs, c.list[j]);
+ addrs[total - j - 1] = talloc_steal(addrs, c.list[j]);
}
}
}