]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2649. [bug] Set the domain for forward only zones. [RT #19944]
authorMark Andrews <marka@isc.org>
Thu, 13 Aug 2009 04:54:21 +0000 (04:54 +0000)
committerMark Andrews <marka@isc.org>
Thu, 13 Aug 2009 04:54:21 +0000 (04:54 +0000)
CHANGES
lib/dns/resolver.c

diff --git a/CHANGES b/CHANGES
index 941b0db3aacb989c3fc7ac73af1b9052aad0a4a7..f9a5e43d45ed078f777c74047ebbc8cc2aa2442b 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+2649.  [bug]           Set the domain for forward only zones. [RT #19944]
+
 2648.  [port]          win32: isc_time_seconds() was broken. [RT #19900]
 
 2646.  [bug]           Incorrect cleanup on error in socket.c. [RT #19987]
index cdb1475544d485cd60daf6296f89349519c5c06c..1441f61dba1e97f3a8a25ee88e7ccdfe1055832c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.355.12.43 2009/07/13 06:33:11 marka Exp $ */
+/* $Id: resolver.c,v 1.355.12.44 2009/08/13 04:54:21 marka Exp $ */
 
 /*! \file */
 
@@ -2464,6 +2464,16 @@ findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port,
        }
 }
 
+static isc_boolean_t
+isstrictsubdomain(dns_name_t *name1, dns_name_t *name2) {
+       int order;
+       unsigned int nlabels;
+       dns_namereln_t namereln;
+
+       namereln = dns_name_fullcompare(name1, name2, &order, &nlabels);
+       return (ISC_TF(namereln == dns_namereln_subdomain));
+}
+
 static isc_result_t
 fctx_getaddresses(fetchctx_t *fctx) {
        dns_rdata_t rdata = DNS_RDATA_INIT;
@@ -2509,6 +2519,8 @@ fctx_getaddresses(fetchctx_t *fctx) {
                dns_name_t *name = &fctx->name;
                dns_name_t suffix;
                unsigned int labels;
+               dns_fixedname_t fixed;
+               dns_name_t *domain;
 
                /*
                 * DS records are found in the parent server.
@@ -2521,11 +2533,26 @@ fctx_getaddresses(fetchctx_t *fctx) {
                        dns_name_getlabelsequence(name, 1, labels - 1, &suffix);
                        name = &suffix;
                }
-               result = dns_fwdtable_find(fctx->res->view->fwdtable, name,
-                                          &forwarders);
+
+               dns_fixedname_init(&fixed);
+               domain = dns_fixedname_name(&fixed);
+               result = dns_fwdtable_find2(fctx->res->view->fwdtable, name,
+                                           domain, &forwarders);
                if (result == ISC_R_SUCCESS) {
                        sa = ISC_LIST_HEAD(forwarders->addrs);
                        fctx->fwdpolicy = forwarders->fwdpolicy;
+                       if (fctx->fwdpolicy == dns_fwdpolicy_only &&
+                           isstrictsubdomain(domain, &fctx->domain)) {
+                               isc_mem_t *mctx;
+
+                               mctx = res->buckets[fctx->bucketnum].mctx;
+                               dns_name_free(&fctx->domain, mctx);
+                               dns_name_init(&fctx->domain, NULL);
+                               result = dns_name_dup(domain, mctx,
+                                                     &fctx->domain);
+                               if (result != ISC_R_SUCCESS)
+                                       return (result);
+                       }
                }
        }