]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2179. [func] 'rndc command zone' will now find 'zone' if it is
authorMark Andrews <marka@isc.org>
Tue, 15 May 2007 02:38:34 +0000 (02:38 +0000)
committerMark Andrews <marka@isc.org>
Tue, 15 May 2007 02:38:34 +0000 (02:38 +0000)
                        unique to all the views. [RT #16821]

CHANGES
bin/named/server.c
lib/dns/include/dns/view.h
lib/dns/view.c

diff --git a/CHANGES b/CHANGES
index 349aabe926d634d769366f9fc4603f78d2de26f4..e30decd1fcb316f73f4f5c3ea577b9fe7c0a2d76 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2179.  [func]          'rndc command zone' will now find 'zone' if it is
+                       unique to all the views. [RT #16821]
+
 2178.  [bug]           'rndc reload' of a slave or stub zone resulted in
                        a reference leak. [RT #16867]
 
index 976da7e9605e6d21b7a8dcb81aa2498bb880d378..4bf2e5e44b4aab1de3a0d34cc9dbc247429a1df0 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: server.c,v 1.484 2007/05/15 02:28:27 marka Exp $ */
+/* $Id: server.c,v 1.485 2007/05/15 02:38:34 marka Exp $ */
 
 /*! \file */
 
@@ -4124,23 +4124,28 @@ zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep) {
                result = dns_rdataclass_fromtext(&rdclass, &r);
                if (result != ISC_R_SUCCESS)
                        goto fail1;
-       } else {
+       } else
                rdclass = dns_rdataclass_in;
-       }
        
-       if (viewtxt == NULL)
-               viewtxt = "_default";
-       result = dns_viewlist_find(&server->viewlist, viewtxt,
-                                  rdclass, &view);
-       if (result != ISC_R_SUCCESS)
-               goto fail1;
+       if (viewtxt == NULL) {
+               result = dns_viewlist_findzone(&server->viewlist,
+                                              dns_fixedname_name(&name),
+                                              ISC_TF(classtxt == NULL),
+                                              rdclass, zonep);
+       } else {
+               result = dns_viewlist_find(&server->viewlist, viewtxt,
+                                          rdclass, &view);
+               if (result != ISC_R_SUCCESS)
+                       goto fail1;
        
-       result = dns_zt_find(view->zonetable, dns_fixedname_name(&name),
-                            0, NULL, zonep);
+               result = dns_zt_find(view->zonetable, dns_fixedname_name(&name),
+                                    0, NULL, zonep);
+               dns_view_detach(&view);
+       }
+
        /* Partial match? */
        if (result != ISC_R_SUCCESS && *zonep != NULL)
                dns_zone_detach(zonep);
-       dns_view_detach(&view);
  fail1:
        return (result);
 }
index 716b40faf204060d67b965bba7b0ee72350cfb22..1f3a01125724727c4093d342834ac5e85827d00d 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: view.h,v 1.105 2007/03/29 23:47:04 tbox Exp $ */
+/* $Id: view.h,v 1.106 2007/05/15 02:38:34 marka Exp $ */
 
 #ifndef DNS_VIEW_H
 #define DNS_VIEW_H 1
@@ -594,6 +594,19 @@ dns_viewlist_find(dns_viewlist_t *list, const char *name,
  *\li  #ISC_R_NOTFOUND         No matching view was found.
  */
 
+isc_result_t
+dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name, isc_boolean_t allclasses,
+                      dns_rdataclass_t rdclass, dns_zone_t **zonep);
+
+/*%<
+ * Search zone with 'name' in view with 'rdclass' in viewlist 'list'
+ * If found, zone is returned in *zonep. If allclasses is set rdclass is ignored
+ *
+ * Returns:
+ *\li  #ISC_R_SUCCESS          A matching zone was found.
+ *\li  #ISC_R_NOTFOUND         No matching zone was found.
+ */
+
 isc_result_t
 dns_view_findzone(dns_view_t *view, dns_name_t *name, dns_zone_t **zonep);
 /*%<
index e831d0565c32f4402a09494ccc937abdbb07a466..48ac79ac00821ee76d146bdb40577e7ced75d12b 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: view.c,v 1.141 2007/03/29 06:36:30 marka Exp $ */
+/* $Id: view.c,v 1.142 2007/05/15 02:38:34 marka Exp $ */
 
 /*! \file */
 
@@ -1146,6 +1146,40 @@ dns_viewlist_find(dns_viewlist_t *list, const char *name,
        return (ISC_R_SUCCESS);
 }
 
+isc_result_t
+dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name,
+                     isc_boolean_t allclasses, dns_rdataclass_t rdclass,
+                     dns_zone_t **zonep)
+{
+       dns_view_t *view;
+       isc_result_t result;
+       dns_zone_t *zone1 = NULL, *zone2 = NULL;
+
+       REQUIRE(list != NULL);
+       for (view = ISC_LIST_HEAD(*list);
+             view != NULL;
+             view = ISC_LIST_NEXT(view, link)) {
+               if (allclasses == ISC_FALSE && view->rdclass != rdclass)
+                       continue;
+               result = dns_zt_find(view->zonetable, name, 0, NULL,
+                                   (zone1 == NULL) ? &zone1 : &zone2);
+               INSIST(result == ISC_R_SUCCESS || result == ISC_R_NOTFOUND);
+               if (zone2 != NULL) {
+                       dns_zone_detach(&zone1);
+                       dns_zone_detach(&zone2);
+                       return (ISC_R_NOTFOUND);
+               }
+       }
+
+       if (zone1 != NULL) {
+               dns_zone_attach(zone1, zonep);
+               dns_zone_detach(&zone1);
+               return (ISC_R_SUCCESS);
+       }
+
+       return (ISC_R_NOTFOUND);
+}
+
 isc_result_t
 dns_view_load(dns_view_t *view, isc_boolean_t stop) {