handle resolv.conf 'search' line, client side. Also, fix a bug in lwresd that would return success, but no addresses, for NXDOMAIN or NXRRSET.
This commit is contained in:
+11
-10
@@ -151,8 +151,8 @@ mem_free(void *arg, void *mem, size_t size)
|
||||
static void
|
||||
parse_resolv_conf(isc_mem_t *mem)
|
||||
{
|
||||
lwres_conf_t lwc;
|
||||
lwres_context_t *lwctx;
|
||||
lwres_conf_t *lwc;
|
||||
int lwresult;
|
||||
struct in_addr ina;
|
||||
struct in6_addr ina6;
|
||||
@@ -164,26 +164,27 @@ parse_resolv_conf(isc_mem_t *mem)
|
||||
if (lwresult != LWRES_R_SUCCESS)
|
||||
return;
|
||||
|
||||
lwres_conf_init(lwctx, &lwc);
|
||||
|
||||
lwresult = lwres_conf_parse("/etc/resolv.conf", &lwc);
|
||||
lwresult = lwres_conf_parse(lwctx, "/etc/resolv.conf");
|
||||
if (lwresult != LWRES_R_SUCCESS)
|
||||
goto out;
|
||||
|
||||
#if 1
|
||||
lwres_conf_print(stderr, &lwc);
|
||||
lwres_conf_print(lwctx, stderr);
|
||||
#endif
|
||||
|
||||
lwc = lwres_conf_get(lwctx);
|
||||
INSIST(lwc != NULL);
|
||||
|
||||
/*
|
||||
* Run through the list of nameservers, and set them to be our
|
||||
* forwarders.
|
||||
*/
|
||||
for (i = 0 ; i < lwc.nsnext ; i++) {
|
||||
switch (lwc.nameservers[i].family) {
|
||||
for (i = 0 ; i < lwc->nsnext ; i++) {
|
||||
switch (lwc->nameservers[i].family) {
|
||||
case AF_INET:
|
||||
sa = isc_mem_get(mem, sizeof *sa);
|
||||
INSIST(sa != NULL);
|
||||
memcpy(&ina.s_addr, lwc.nameservers[i].address, 4);
|
||||
memcpy(&ina.s_addr, lwc->nameservers[i].address, 4);
|
||||
isc_sockaddr_fromin(sa, &ina, 53);
|
||||
ISC_LIST_APPEND(forwarders, sa, link);
|
||||
sa = NULL;
|
||||
@@ -191,7 +192,7 @@ parse_resolv_conf(isc_mem_t *mem)
|
||||
case AF_INET6:
|
||||
sa = isc_mem_get(mem, sizeof *sa);
|
||||
INSIST(sa != NULL);
|
||||
memcpy(&ina6.s6_addr, lwc.nameservers[i].address, 16);
|
||||
memcpy(&ina6.s6_addr, lwc->nameservers[i].address, 16);
|
||||
isc_sockaddr_fromin6(sa, &ina6, 53);
|
||||
ISC_LIST_APPEND(forwarders, sa, link);
|
||||
sa = NULL;
|
||||
@@ -202,7 +203,7 @@ parse_resolv_conf(isc_mem_t *mem)
|
||||
}
|
||||
|
||||
out:
|
||||
lwres_conf_clear(&lwc);
|
||||
lwres_conf_clear(lwctx);
|
||||
lwres_context_destroy(&lwctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -162,7 +162,14 @@ generate_reply(client_t *client)
|
||||
client->pkt.recvlength = LWRES_RECVLENGTH;
|
||||
client->pkt.authtype = 0; /* XXXMLG */
|
||||
client->pkt.authlength = 0;
|
||||
client->pkt.result = LWRES_R_SUCCESS;
|
||||
|
||||
/*
|
||||
* If there are no addresses and no aliases, return failure.
|
||||
*/
|
||||
if (client->gabn.naddrs == 0 && client->gabn.naliases == 0)
|
||||
client->pkt.result = LWRES_R_NOTFOUND;
|
||||
else
|
||||
client->pkt.result = LWRES_R_SUCCESS;
|
||||
|
||||
lwres = lwres_gabnresponse_render(cm->lwctx, &client->gabn,
|
||||
&client->pkt, &lwb);
|
||||
|
||||
+20
-2
@@ -171,6 +171,7 @@ test_gabn(char *target)
|
||||
printf("FAILURE!\n");
|
||||
if (res != NULL)
|
||||
lwres_gabnresponse_free(ctx, &res);
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Returned real name: (%u, %s)\n",
|
||||
@@ -268,18 +269,35 @@ main(int argc, char *argv[])
|
||||
#else
|
||||
ret = lwres_context_create(&ctx, NULL, NULL, NULL);
|
||||
#endif
|
||||
|
||||
CHECK(ret, "lwres_context_create");
|
||||
|
||||
ret = lwres_conf_parse(ctx, "/etc/resolv.conf");
|
||||
CHECK(ret, "lwres_conf_parse");
|
||||
|
||||
lwres_conf_print(ctx, stdout);
|
||||
|
||||
test_noop();
|
||||
test_gabn("notthereatall.flame.org.");
|
||||
test_gabn("alias-05.test.flame.org.");
|
||||
|
||||
/*
|
||||
* The following comments about tests all assume your search path is
|
||||
* nominum.com isc.org flame.org
|
||||
* and ndots is the default of 1.
|
||||
*/
|
||||
test_gabn("alias-05.test"); /* exact, then search. */
|
||||
test_gabn("f.root-servers.net.");
|
||||
test_gabn("poofball.flame.org.");
|
||||
test_gabn("foo.ip6.int.");
|
||||
test_gabn("notthereatall.flame.org"); /* exact, then search (!found)*/
|
||||
test_gabn("shell"); /* search (found in nominum.com), then exact */
|
||||
test_gabn("kechara"); /* search (found in flame.org), then exact */
|
||||
test_gabn("lkasdjlaksjdlkasjdlkasjdlkasjd"); /* search, exact(!found)*/
|
||||
|
||||
test_gnba("198.133.199.1", LWRES_ADDRTYPE_V4);
|
||||
test_gnba("204.152.184.79", LWRES_ADDRTYPE_V4);
|
||||
test_gnba("3ffe:8050:201:1860:42::1", LWRES_ADDRTYPE_V6);
|
||||
|
||||
lwres_conf_clear(ctx);
|
||||
lwres_context_destroy(&ctx);
|
||||
|
||||
#ifdef USE_ISC_MEM
|
||||
|
||||
Reference in New Issue
Block a user