]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2959. [func] Check that named starts with a missing masterfile.
authorMark Andrews <marka@isc.org>
Wed, 15 Sep 2010 03:42:59 +0000 (03:42 +0000)
committerMark Andrews <marka@isc.org>
Wed, 15 Sep 2010 03:42:59 +0000 (03:42 +0000)
                        [RT #22076]

2958.   [bug]           named failed to start with a missing master file.
                        [RT #22076]

CHANGES
bin/named/zoneconf.c
bin/tests/system/addzone/clean.sh
bin/tests/system/addzone/tests.sh
bin/tests/system/masterfile/clean.sh
bin/tests/system/masterfile/ns2/example.db [new file with mode: 0644]
bin/tests/system/masterfile/ns2/named.conf [new file with mode: 0644]
bin/tests/system/masterfile/tests.sh

diff --git a/CHANGES b/CHANGES
index fa66566c13635082ba3da61263c4e6209a4e2fb6..d318569827df1547cdd90d31c6933c0289dfeea5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+2959.  [func]          Check that named starts with a missing masterfile.
+                       [RT #22076]
+
+2958.  [bug]           named failed to start with a missing master file.
+                       [RT #22076]
+
 2928.  [bug]           Be more selective about the non-authoritative
                        answer we apply change 2748 to. [RT #21594]
 
index 649eb2f0d0720c69b95791732488284dc3a6ae3c..d2184f51e82a703ea8ccaee44c6780b6b93f5ce8 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: zoneconf.c,v 1.161.4.3 2010/08/11 18:19:55 each Exp $ */
+/* $Id: zoneconf.c,v 1.161.4.3.6.1 2010/09/15 03:42:58 marka Exp $ */
 
 /*% */
 
@@ -565,22 +565,13 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
         * Unless we're using some alternative database, a master zone
         * will be needing a master file.
         */
-       if (ztype == dns_zone_master && cpval == default_dbtype) {
-               if (filename == NULL) {
-                       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
-                                     NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "zone '%s': 'file' not specified",
-                                     zname);
-                       return (ISC_R_FAILURE);
-               }
-
-               if (!isc_file_exists(filename)) {
-                       isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
-                                     NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "zone '%s': master file not found",
-                                     zname);
-                       return (ISC_R_NOTFOUND);
-               }
+       if (ztype == dns_zone_master && cpval == default_dbtype &&
+           filename == NULL) {
+               isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
+                             NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
+                             "zone '%s': 'file' not specified",
+                             zname);
+               return (ISC_R_FAILURE);
        }
 
        masterformat = dns_masterformat_text;
index f9e36f42ee4de682df76bc3e69ad197bd406650b..1cf94bdc69a9b32f60ad36052a25ef1da3be8aa0 100644 (file)
 # 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 2010/08/11 18:19:55 each Exp $
+# $Id: clean.sh,v 1.2.2.2.6.1 2010/09/15 03:42:59 marka Exp $
 
 rm -f dig.out.*
+rm -f rndc.out.*
 rm -f ns2/named.conf
 rm -f */named.memstats
 rm -f ns2/*.nzf
index 2e6bbf466d0f725ba5f46410e91ed3761ff723df..3b89399251d73151cef45dd7e37ff48d9b8e1174 100644 (file)
@@ -14,7 +14,7 @@
 # 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 2010/08/11 18:19:55 each Exp $
+# $Id: tests.sh,v 1.2.2.2.6.1 2010/09/15 03:42:59 marka Exp $
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
@@ -51,6 +51,19 @@ n=`expr $n + 1`
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
+echo "I:adding new zone with missing master file ($n)"
+ret=0
+$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.pre.$n || ret=1
+grep "status: NOERROR" dig.out.ns2.pre.$n > /dev/null || ret=1
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'missing.example { type master; file "missing.db"; };' 2> rndc.out.ns2.$n
+grep "file not found" rndc.out.ns2.$n > /dev/null || ret=1
+$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.post.$n || ret=1
+grep "status: NOERROR" dig.out.ns2.post.$n > /dev/null || ret=1
+$PERL ../digcomp.pl dig.out.ns2.pre.$n dig.out.ns2.post.$n || ret=1
+n=`expr $n + 1`
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
 echo "I:deleting previously added zone ($n)"
 ret=0
 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /'
@@ -71,9 +84,10 @@ n=`expr $n + 1`
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
-echo "I:attempt to delete a normally-loaded zone (should fail) ($n)"
+echo "I:attempt to delete a normally-loaded zone ($n)"
 ret=0
-$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2>&1 | sed 's/^/I:ns2 /'
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2> rndc.out.ns2.$n
+grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
 $DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n
 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
 grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
@@ -109,9 +123,10 @@ n=`expr $n + 1`
 if [ $ret != 0 ]; then echo "I:failed"; fi
 status=`expr $status + $ret`
 
-echo "I:attempting to add zone to internal view (should fail) ($n)"
+echo "I:attempting to add zone to internal view ($n)"
 ret=0
-$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in internal { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
+$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in internal { type master; file "added.db"; };' 2> rndc.out.ns2.$n
+grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
 $DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.$n || ret=1
 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
 n=`expr $n + 1`
index d90a65dc6724b7a170e395c3bbc7412323e7893b..67e9b62dfa476e0479f3a0c10c551fdf00f145c8 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: clean.sh,v 1.5 2007/09/26 03:22:44 marka Exp $
+# $Id: clean.sh,v 1.5.658.1 2010/09/15 03:42:59 marka Exp $
 
-rm -f dig.out
+rm -f dig.out.*
 rm -f */named.memstats
diff --git a/bin/tests/system/masterfile/ns2/example.db b/bin/tests/system/masterfile/ns2/example.db
new file mode 100644 (file)
index 0000000..7c3dbf1
--- /dev/null
@@ -0,0 +1,26 @@
+; 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: example.db,v 1.2.4.2 2010/09/15 03:42:59 marka Exp $
+
+$TTL 300       ; 5 minutes
+@                      IN SOA  mname1. . (
+                               2010042407 ; serial
+                               20         ; refresh (20 seconds)
+                               20         ; retry (20 seconds)
+                               1814400    ; expire (3 weeks)
+                               3600       ; minimum (1 hour)
+                               )
+                       NS      ns2
+ns2                    A       10.53.0.2
diff --git a/bin/tests/system/masterfile/ns2/named.conf b/bin/tests/system/masterfile/ns2/named.conf
new file mode 100644 (file)
index 0000000..0203c09
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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.conf,v 1.2.4.2 2010/09/15 03:42:59 marka Exp $ */
+
+// NS2
+
+controls { /* empty */ };
+
+options {
+       query-source address 10.53.0.2;
+       notify-source 10.53.0.2;
+       transfer-source 10.53.0.2;
+       port 5300;
+       pid-file "named.pid";
+       listen-on { 10.53.0.2; };
+       listen-on-v6 { none; };
+       recursion no;
+       notify yes;
+       dnssec-enable yes;
+       dnssec-validation yes;
+};
+
+zone "." {
+       type hint;
+       file "../../common/root.hint";
+};
+
+zone "example" {
+       type master;
+       file "example.db";
+};
+
+zone "missing" {
+       type master;
+       file "missing.db";
+};
+
index beebcdca6ad53e4c895b261abb55588f34fbba50..e9bbf2f338ef032a30e79b8b080c2cc56a10754a 100644 (file)
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: tests.sh,v 1.5 2007/06/19 23:47:04 tbox Exp $
+# $Id: tests.sh,v 1.5.740.1 2010/09/15 03:42:59 marka Exp $
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
 
 status=0
-
-echo "I:test master file \$INCLUDE semantics"
-$DIG +nostats +nocmd include. axfr @10.53.0.1 -p 5300 >dig.out
-
-echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics"
-$DIG +nostats +nocmd ttl2. axfr @10.53.0.1 -p 5300 >>dig.out
-
-echo "I:test of master file RFC1035 TTL and \$TTL semantics"
-$DIG +nostats +nocmd ttl2. axfr @10.53.0.1 -p 5300 >>dig.out
-
-diff dig.out knowngood.dig.out || status=1
+n=0
+
+ret=0
+n=`expr $n + 1`
+echo "I:test master file \$INCLUDE semantics ($n)"
+$DIG +nostats +nocmd include. axfr @10.53.0.1 -p 5300 >dig.out.$n
+
+echo "I:test master file BIND 8 compatibility TTL and \$TTL semantics ($n)"
+$DIG +nostats +nocmd ttl2. axfr @10.53.0.1 -p 5300 >>dig.out.$n
+
+echo "I:test of master file RFC1035 TTL and \$TTL semantics ($n)"
+$DIG +nostats +nocmd ttl2. axfr @10.53.0.1 -p 5300 >>dig.out.$n
+
+diff dig.out.$n knowngood.dig.out || status=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+ret=0
+n=`expr $n + 1`
+echo "I:test that the nameserver is running with a missing master file ($n)"
+$DIG +tcp +noall +answer example soa @10.53.0.2 -p 5300 > dig.out.$n 
+grep SOA dig.out.$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
+
+ret=0
+n=`expr $n + 1`
+echo "I:test that the nameserver returns SERVFAIL for a missing master file ($n)"
+$DIG +tcp +all missing soa @10.53.0.2 -p 5300 > dig.out.$n 
+grep "status: SERVFAIL" dig.out.$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo "I:failed"; fi
+status=`expr $status + $ret`
 
 echo "I:exit status: $status"
 exit $status