]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2036. [bug] Check built-in zone arguments to see if the zone
authorMark Andrews <marka@isc.org>
Tue, 22 Feb 2011 04:25:57 +0000 (04:25 +0000)
committerMark Andrews <marka@isc.org>
Tue, 22 Feb 2011 04:25:57 +0000 (04:25 +0000)
                        is re-usable or not. [RT #21914]

CHANGES
bin/tests/system/conf.sh.in
bin/tests/system/database/clean.sh [new file with mode: 0644]
bin/tests/system/database/ns1/named.conf1 [new file with mode: 0644]
bin/tests/system/database/ns1/named.conf2 [new file with mode: 0644]
bin/tests/system/database/setup.sh [new file with mode: 0644]
bin/tests/system/database/tests.sh [new file with mode: 0644]
lib/dns/zone.c

diff --git a/CHANGES b/CHANGES
index db26196a7ba5930770d817b38be91ac153c1505e..b22444ec2917beb46bd9fd28485d42a4078314ad 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+2036.  [bug]           Check built-in zone arguments to see if the zone
+                       is re-usable or not. [RT #21914]
+
 3035.  [cleanup]       Simplify by using strlcpy. [RT #22521] 
 
 3034.  [cleanup]       nslookup: use strlcpy instead of safecopy. [RT #22521]
index c510da744579abb6769f6e4f8a647228ddd5ff23..168bab153a207cbd9783566dc890b49a21016e06 100644 (file)
@@ -15,7 +15,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: conf.sh.in,v 1.59 2011/01/13 04:59:24 tbox Exp $
+# $Id: conf.sh.in,v 1.59.8.1 2011/02/22 04:25:55 marka Exp $
 
 #
 # Common configuration data for system tests, to be sourced into
@@ -53,10 +53,11 @@ JOURNALPRINT=$TOP/bin/tools/named-journalprint
 # load on the machine to make it unusable to other users.
 # v6synth
 SUBDIRS="acl allow_query addzone autosign cacheclean checkconf checknames
-    dlv @DLZ_SYSTEM_TEST@ dlzexternal dns64 dnssec forward glue gost ixfr limits
-    lwresd masterfile masterformat metadata notify nsupdate pending pkcs11
-    resolver rpz rrsetorder sortlist smartsign staticstub stub tkey
-    tsig tsiggss unknown upforwd views xfer xferquota zonechecks"
+         database dlv @DLZ_SYSTEM_TEST@ dlzexternal dns64 dnssec forward
+        glue gost ixfr limits lwresd masterfile masterformat metadata
+        notify nsupdate pending pkcs11 resolver rpz rrsetorder
+        sortlist smartsign staticstub stub tkey tsig tsiggss
+        unknown upforwd views xfer xferquota zonechecks"
 
 # PERL will be an empty string if no perl interpreter was found.
 PERL=@PERL@
diff --git a/bin/tests/system/database/clean.sh b/bin/tests/system/database/clean.sh
new file mode 100644 (file)
index 0000000..27144dd
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+#
+# Copyright (C) 2010  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.
+
+# $Id: clean.sh,v 1.2.2.2 2011/02/22 04:25:56 marka Exp $
+
+rm -f ns1/named.conf ns1/named.run ns1/named.memstats
+rm -f dig.out.*
diff --git a/bin/tests/system/database/ns1/named.conf1 b/bin/tests/system/database/ns1/named.conf1
new file mode 100644 (file)
index 0000000..5705a83
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010  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.
+ */
+
+/* $Id: named.conf1,v 1.2.2.2 2011/02/22 04:25:56 marka Exp $ */
+
+// NS1
+
+key rndc_key {
+        secret "1234abcd8765";
+        algorithm hmac-md5;
+};
+
+controls {
+        inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
+
+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;
+};
+
+zone "database" {
+       type master;
+       database "_builtin empty localhost. hostmaster.isc.org.";
+};
diff --git a/bin/tests/system/database/ns1/named.conf2 b/bin/tests/system/database/ns1/named.conf2
new file mode 100644 (file)
index 0000000..1073c0b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010  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.
+ */
+
+/* $Id: named.conf2,v 1.2.2.2 2011/02/22 04:25:56 marka Exp $ */
+
+// NS1
+
+key rndc_key {
+        secret "1234abcd8765";
+        algorithm hmac-md5;
+};
+
+controls {
+        inet 10.53.0.1 port 9953 allow { any; } keys { rndc_key; };
+};
+
+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;
+};
+
+zone "database" {
+       type master;
+       database "_builtin empty localhost. marka.isc.org.";
+};
diff --git a/bin/tests/system/database/setup.sh b/bin/tests/system/database/setup.sh
new file mode 100644 (file)
index 0000000..c1aab9e
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+#
+# Copyright (C) 2010  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.
+
+# $Id: setup.sh,v 1.2.2.2 2011/02/22 04:25:56 marka Exp $
+
+cp ns1/named.conf1 ns1/named.conf
diff --git a/bin/tests/system/database/tests.sh b/bin/tests/system/database/tests.sh
new file mode 100644 (file)
index 0000000..7be97be
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# Copyright (C) 2010  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.
+
+# $Id: tests.sh,v 1.2.2.2 2011/02/22 04:25:56 marka Exp $
+
+SYSTEMTESTTOP=..
+. $SYSTEMTESTTOP/conf.sh
+
+status=0
+n=0
+
+rm -f dig.out.*
+
+DIGOPTS="+tcp +noadd +nosea +nostat +nocmd +dnssec -p 5300"
+RNDCCMD="$RNDC -s 10.53.0.1 -p 9953 -c ../common/rndc.conf"
+
+# Check the example. domain
+
+echo "I:checking pre reload zone ($n)"
+ret=0
+$DIG $DIGOPTS soa database. @10.53.0.1 > dig.out.ns1.test$n || ret=1
+grep "hostmaster\.isc\.org" dig.out.ns1.test$n > /dev/null || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+cp ns1/named.conf2 ns1/named.conf
+$RNDCCMD reload 2>&1 >/dev/null
+
+echo "I:checking post reload zone ($n)"
+ret=1
+try=0
+while test $try -lt 6
+do
+       sleep 1
+       ret=0
+       $DIG $DIGOPTS soa database. @10.53.0.1 > dig.out.ns1.test$n || ret=1
+       grep "marka\.isc\.org" dig.out.ns1.test$n > /dev/null || ret=1
+       try=`expr $try + 1`
+       test $ret -eq 0 && break
+done
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+echo "I:exit status: $status"
+exit $status
index a92b04032fefb6c97f49855fdca6376ef1c68edf..588bce889053337b192610daa569cade3b2d46d5 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: zone.c,v 1.582.8.7 2011/02/18 23:23:08 each Exp $ */
+/* $Id: zone.c,v 1.582.8.8 2011/02/22 04:25:56 marka Exp $ */
 
 /*! \file */
 
@@ -1379,6 +1379,7 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
        isc_time_t now;
        isc_time_t loadtime, filetime;
        dns_db_t *db = NULL;
+       isc_boolean_t rbt;
 
        REQUIRE(DNS_ZONE_VALID(zone));
 
@@ -1394,14 +1395,15 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
                goto cleanup;
        }
 
-       if (zone->db != NULL && zone->masterfile == NULL) {
+
+       INSIST(zone->db_argc >= 1);
+
+       rbt = strcmp(zone->db_argv[0], "rbt") == 0 ||
+             strcmp(zone->db_argv[0], "rbt64") == 0;
+
+       if (zone->db != NULL && zone->masterfile == NULL && rbt) {
                /*
-                * The zone has no master file configured, but it already
-                * has a database.  It could be the built-in
-                * version.bind. CH zone, a zone with a persistent
-                * database being reloaded, or maybe a zone that
-                * used to have a master file but whose configuration
-                * was changed so that it no longer has one.  Do nothing.
+                * The zone has no master file configured.
                 */
                result = ISC_R_SUCCESS;
                goto cleanup;
@@ -1420,7 +1422,6 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
                goto cleanup;
        }
 
-
        /*
         * Store the current time before the zone is loaded, so that if the
         * file changes between the time of the load and the time that
@@ -1463,21 +1464,20 @@ zone_load(dns_zone_t *zone, unsigned int flags) {
                }
        }
 
-       INSIST(zone->db_argc >= 1);
-
        /*
-        * Built in zones don't need to be reloaded.
+        * Built in zones (with the exception of empty zones) don't need
+        * to be reloaded.
         */
        if (zone->type == dns_zone_master &&
            strcmp(zone->db_argv[0], "_builtin") == 0 &&
+           (zone->db_argc < 2 || strcmp(zone->db_argv[1], "empty") != 0) &&
            DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADED)) {
                result = ISC_R_SUCCESS;
                goto cleanup;
        }
 
        if ((zone->type == dns_zone_slave || zone->type == dns_zone_stub) &&
-           (strcmp(zone->db_argv[0], "rbt") == 0 ||
-            strcmp(zone->db_argv[0], "rbt64") == 0)) {
+           rbt) {
                if (zone->masterfile == NULL ||
                    !isc_file_exists(zone->masterfile)) {
                        if (zone->masterfile != NULL) {