]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3908. [bug] rndc now differentiates between a zone in multiple
authorMark Andrews <marka@isc.org>
Sat, 2 Aug 2014 04:43:26 +0000 (14:43 +1000)
committerMark Andrews <marka@isc.org>
Sat, 2 Aug 2014 05:09:29 +0000 (15:09 +1000)
                        views and a zone that doesn't exist at all. [RT #36691]

(cherry picked from commit c38341ec435fb78de6d12c1001201f9ac7487b68)
(cherry picked from commit 13ffd78910e81a666723a25341b1636b625abfbd)

CHANGES
bin/named/server.c
bin/tests/system/zonechecks/ns1/named.conf [new file with mode: 0644]
bin/tests/system/zonechecks/setup.sh [new file with mode: 0644]
bin/tests/system/zonechecks/tests.sh
lib/dns/include/dns/view.h
lib/dns/view.c
lib/isc/include/isc/result.h
lib/isc/result.c

diff --git a/CHANGES b/CHANGES
index acc877f60fa6221764298660f1bdda3d563e94b1..2ce93c8139d13981518f5cae8508e29bd2fc0187 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3908.  [bug]           rndc now differentiates between a zone in multiple
+                       views and a zone that doesn't exist at all. [RT #36691]
+
 3907.  [cleanup]       Alphabetise rndc help. [RT#36683]
 
 3906.  [protocol]      Update URI record format to comply with
index 721aac57251ecebe32bb37daa35203831617782f..74d04f0afc6b1e96c98e3ebbfabfb01227cd4f9b 100644 (file)
@@ -6273,6 +6273,10 @@ zone_from_args(ns_server_t *server, char *args, dns_zone_t **zonep,
                        snprintf(problem, sizeof(problem),
                                 "no matching zone '%s' in any view",
                                 zonetxt);
+               else if (result == ISC_R_MULTIPLE)
+                       snprintf(problem, sizeof(problem),
+                                "zone '%s' was found in multiple views",
+                                zonetxt);
        } else {
                result = dns_viewlist_find(&server->viewlist, viewtxt,
                                           rdclass, &view);
diff --git a/bin/tests/system/zonechecks/ns1/named.conf b/bin/tests/system/zonechecks/ns1/named.conf
new file mode 100644 (file)
index 0000000..a0393ce
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2012, 2013  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+// NS1
+
+controls { /* empty */ };
+
+options {
+       query-source address 10.53.0.1;
+       notify-source 10.53.0.1;
+       transfer-source 10.53.0.1;
+       port 5300;
+       pid-file "named.pid";
+       listen-on { 10.53.0.1; };
+       listen-on-v6 { none; };
+       recursion no;
+       notify yes;
+       dnssec-enable yes;
+       dnssec-validation yes;
+};
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
+
+view unused {
+       match-clients { none; };
+
+       zone "duplicate.example" {
+               type master;
+               file "duplicate.db";
+       };
+};
+
+view primary {
+       match-clients { any; };
+
+       zone "master.example" {
+               type master;
+               file "master.db";
+               allow-update { any; };
+               allow-transfer { any; };
+               auto-dnssec maintain;
+       };
+
+       zone "reload.example" {
+               type master;
+               file "reload.db";
+       };
+
+       zone "duplicate.example" {
+               type master;
+               file "duplicate.db";
+       };
+};
diff --git a/bin/tests/system/zonechecks/setup.sh b/bin/tests/system/zonechecks/setup.sh
new file mode 100644 (file)
index 0000000..0a6c0f6
--- /dev/null
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# Copyright (C) 2012-2014  Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+SYSTEMTESTTOP=..
+. $SYSTEMTESTTOP/conf.sh
+
+$SHELL clean.sh
+
+test -r $RANDFILE || $GENRANDOM 400 $RANDFILE
+
+$SHELL ../genzone.sh 1 > ns1/master.db
+$SHELL ../genzone.sh 1 > ns1/duplicate.db
+cd ns1
+touch master.db.signed
+echo '$INCLUDE "master.db.signed"' >> master.db
+$KEYGEN -r $RANDFILE -3q master.example > /dev/null 2>&1
+$KEYGEN -r $RANDFILE -3qfk master.example > /dev/null 2>&1
+$SIGNER -SD -o master.example master.db > /dev/null 2>&1
+echo '$INCLUDE "soa.db"' > reload.db
+echo '@ 0 NS .' >> reload.db
+echo '@ 0 SOA . . 1 0 0 0 0' > soa.db
index d3c88232b22d4bbdd3bf3a0ef17a51d0e340fc6c..e49db56b56acb81d0d55abd7345424e4e898cd73 100644 (file)
@@ -14,8 +14,6 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id$
-
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
@@ -160,5 +158,17 @@ then
 else
        echo "I:failed (status)"; status=1
 fi
+
+echo "I: checking 'rdnc zonestatus' with duplicated zone name"
+ret=0 
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus duplicate.example > rndc.out.duplicate 2>&1
+checkfor "zone 'duplicate.example' was found in multiple views" rndc.out.duplicate
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus duplicate.example in primary > rndc.out.duplicate 2>&1
+checkfor "name: duplicate.example" rndc.out.duplicate
+$RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus nosuchzone.example > rndc.out.duplicate 2>&1
+checkfor "no matching zone 'nosuchzone.example' in any view" rndc.out.duplicate
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 exit $status
index ccb99fedf85cadf808480a47b651b35d2a4450bf..5417987c0f097424022b04af4d3c4b4f16b5c56a 100644 (file)
@@ -707,6 +707,7 @@ dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name, isc_boolean_t allc
  * Returns:
  *\li  #ISC_R_SUCCESS          A matching zone was found.
  *\li  #ISC_R_NOTFOUND         No matching zone was found.
+ *\li  #ISC_R_MULTIPLE         Multiple zones with the same name were found.
  */
 
 isc_result_t
index 7899a3f27ffc3367f7aff541ab8107fd8522eea9..4bfe203ccbddf43c1192b98debc4d18a908b01b2 100644 (file)
@@ -1441,7 +1441,7 @@ dns_viewlist_findzone(dns_viewlist_t *list, dns_name_t *name,
                if (zone2 != NULL) {
                        dns_zone_detach(&zone1);
                        dns_zone_detach(&zone2);
-                       return (ISC_R_NOTFOUND);
+                       return (ISC_R_MULTIPLE);
                }
        }
 
index dcd457b3d1b0cb648b63c98b6917e53ec7f90fcc..3a768fd08091aa5676d9da1aa4b3a5d46710fd6d 100644 (file)
 #define ISC_R_BADADDRESSFORM           59      /*%< invalid address format */
 #define ISC_R_BADBASE32                        60      /*%< bad base32 encoding */
 #define ISC_R_UNSET                    61      /*%< unset */
+#define ISC_R_MULTIPLE                 62      /*%< multiple */
 
 /*% Not a result code: the number of results. */
-#define ISC_R_NRESULTS                         62
+#define ISC_R_NRESULTS                         63
 
 ISC_LANG_BEGINDECLS
 
index a9405fddf0557bb56fb4d07597bc9497978e2705..e4f0ced99b4ca177d3ab5b7232b458effda94288 100644 (file)
@@ -103,6 +103,7 @@ static const char *text[ISC_R_NRESULTS] = {
        "invalid address format",               /*%< 59 */
        "bad base32 encoding",                  /*%< 60 */
        "unset",                                /*%< 61 */
+       "multiple",                             /*%< 62 */
 };
 
 #define ISC_RESULT_RESULTSET                   2