Adam Tkac 5691ae
diff -up bind-9.5.1b2/bin/dig/dighost.c.rh469440 bind-9.5.1b2/bin/dig/dighost.c
Adam Tkac 5691ae
--- bind-9.5.1b2/bin/dig/dighost.c.rh469440	2008-11-03 10:14:05.000000000 +0100
Adam Tkac 5691ae
+++ bind-9.5.1b2/bin/dig/dighost.c	2008-11-03 10:33:13.000000000 +0100
Adam Tkac 5691ae
@@ -596,6 +596,11 @@ copy_server_list(lwres_conf_t *confdata,
Adam Tkac 5691ae
 	for (i = 0; i < confdata->nsnext; i++) {
Adam Tkac 5691ae
 		af = addr2af(confdata->nameservers[i].family);
Adam Tkac 5691ae
 
Adam Tkac 5691ae
+		if (af == AF_INET && !have_ipv4)
Adam Tkac 5691ae
+			continue;
Adam Tkac 5691ae
+		if (af == AF_INET6 && !have_ipv6)
Adam Tkac 5691ae
+			continue;
Adam Tkac 5691ae
+
Adam Tkac 5691ae
 		lwres_net_ntop(af, confdata->nameservers[i].address,
Adam Tkac 5691ae
 				   tmp, sizeof(tmp));
Adam Tkac 5691ae
 		newsrv = make_server(tmp, tmp);
Adam Tkac 5691ae
@@ -1051,8 +1056,10 @@ setup_system(void) {
Adam Tkac 5691ae
 		debug("ndots is %d.", ndots);
Adam Tkac 5691ae
 	}
Adam Tkac 5691ae
 
Adam Tkac 5691ae
+	copy_server_list(lwconf, &server_list);
Adam Tkac 5691ae
+
Adam Tkac 5691ae
 	/* If we don't find a nameserver fall back to localhost */
Adam Tkac 5691ae
-	if (lwconf->nsnext == 0) {
Adam Tkac 5691ae
+	if (ISC_LIST_EMPTY(server_list)) {
Adam Tkac 5691ae
 		if (have_ipv4) {
Adam Tkac 5691ae
 			lwresult = add_nameserver(lwconf, "127.0.0.1", AF_INET);
Adam Tkac 5691ae
 			if (lwresult != ISC_R_SUCCESS)
Adam Tkac 5691ae
@@ -1063,10 +1070,12 @@ setup_system(void) {
Adam Tkac 5691ae
 			if (lwresult != ISC_R_SUCCESS)
Adam Tkac 5691ae
 				fatal("add_nameserver failed");
Adam Tkac 5691ae
 		}
Adam Tkac 5691ae
-	}
Adam Tkac 5691ae
 
Adam Tkac 5691ae
-	if (ISC_LIST_EMPTY(server_list))
Adam Tkac 5691ae
 		copy_server_list(lwconf, &server_list);
Adam Tkac 5691ae
+		if (ISC_LIST_EMPTY(server_list)) {
Adam Tkac 5691ae
+			fatal("Could not find any nameserver");
Adam Tkac 5691ae
+		}
Adam Tkac 5691ae
+	}
Adam Tkac 5691ae
 
Adam Tkac 5691ae
 #ifdef WITH_IDN
Adam Tkac 5691ae
 	initialize_idn();