]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Disallow configuration of user-defined non-IN class views 12163/head
authorOndřej Surý <ondrej@isc.org>
Wed, 4 Mar 2026 12:24:53 +0000 (13:24 +0100)
committerOndřej Surý <ondrej@isc.org>
Mon, 8 Jun 2026 15:50:15 +0000 (17:50 +0200)
Only class IN is allowed for user-defined views; the internally
generated `_bind` view stays in the CH class. Both `named` and the
shared checker in `lib/isccfg/check.c` now reject non-IN views, so a
config can no longer pass `named-checkconf` yet fail to start in
`named`.

Tests, configs, and catalog zones using CH or arbitrary classes
(e.g. `class10`) are removed accordingly.

30 files changed:
bin/named/server.c
bin/tests/system/auth/ns1/chaos.db [deleted file]
bin/tests/system/auth/ns1/named.conf.j2
bin/tests/system/auth/tests.sh
bin/tests/system/catz/ns1/catalog-bad5.example.db [deleted file]
bin/tests/system/catz/ns1/named.conf.j2
bin/tests/system/checkconf/altdb.conf [deleted file]
bin/tests/system/checkconf/bad-chaos-view.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-class.conf [moved from bin/tests/system/checkconf/good-class.conf with 100% similarity]
bin/tests/system/checkconf/good.conf.j2
bin/tests/system/checkconf/good.zonelist
bin/tests/system/checkconf/tests.sh
bin/tests/system/checkconf/warn-chaos-recursion.conf [deleted file]
bin/tests/system/class/ns1/chaos.db.in [deleted file]
bin/tests/system/class/ns1/named.conf.j2
bin/tests/system/class/ns2/example.db.in [deleted file]
bin/tests/system/class/ns2/named.conf.j2
bin/tests/system/class/ns3/named.conf.j2
bin/tests/system/class/setup.sh
bin/tests/system/class/tests_class_chaos.py
bin/tests/system/class/tests_class_update.py
bin/tests/system/pipelined/pipequeries.c
bin/tests/system/resolver/ns1/chaostest.db [deleted file]
bin/tests/system/resolver/ns1/named.conf.j2
bin/tests/system/resolver/tests.sh
bin/tests/system/unknown/ns1/named.conf.j2
bin/tools/mdig.c
doc/arm/reference.rst
lib/dns/view.c
lib/isccfg/check.c

index 0a1992d658aea507ecbb6bdddabebfe4e5ad511e..fc53de5249482be08bca28623fa07bca5d75b573 100644 (file)
@@ -5806,10 +5806,26 @@ get_viewinfo(const cfg_obj_t *vconfig, const char **namep,
                classobj = cfg_tuple_get(vconfig, "class");
                CHECK(named_config_getclass(classobj, dns_rdataclass_in,
                                            &viewclass));
-               if (dns_rdataclass_ismeta(viewclass)) {
+               switch (viewclass) {
+               case dns_rdataclass_in:
+                       break;
+               case dns_rdataclass_chaos:
+                       /* allow the builtin _bind view */
+                       if (strcmp(viewname, "_bind") != 0) {
+                               isc_log_write(
+                                       NAMED_LOGCATEGORY_GENERAL,
+                                       NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
+                                       "view '%s': only builtin _bind view is "
+                                       "allowed in Chaos (CH) class",
+                                       viewname);
+                               CLEANUP(ISC_R_FAILURE);
+                       }
+                       break;
+               default:
                        isc_log_write(NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                                     "view '%s': class must not be meta",
+                                     "view '%s': only Internet (IN) class is "
+                                     "allowed",
                                      viewname);
                        CLEANUP(ISC_R_FAILURE);
                }
diff --git a/bin/tests/system/auth/ns1/chaos.db b/bin/tests/system/auth/ns1/chaos.db
deleted file mode 100644 (file)
index 6657442..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-$TTL 300       ; 5 minutes
-@                      CH SOA  ns root (
-                               2018010100 ; serial
-                               1800       ; refresh (30 minutes)
-                               1800       ; retry (30 minutes)
-                               1814400    ; expire (3 weeks)
-                               3600       ; minimum (1 hour)
-                               )
-                       NS      ns
-ns                     A       ch-addr.example. 1001
-test                   A       ch-addr.example. 1002
-                       A       ch-addr.example. 1003
index 341ffefc557bf7e866ef73b6f5710cfab393728a..88a54c7d51e528811826b9eb5d95650a77222c53 100644 (file)
@@ -37,10 +37,3 @@ view main in {
                log-report-channel yes;
        };
 };
-
-view alt chaos {
-       zone example.chaos chaos {
-               type primary;
-               file "chaos.db";
-       };
-};
index 27399f512dc294c54f3c21a5d1ccfecf9882228d..b0aef293d5b042f78f0c73eb60951534de74d6c5 100644 (file)
@@ -177,15 +177,6 @@ grep 'a\.example\.com.*A.10\.53\.0\.1' dig.out.test$n >/dev/null && ret=1
 [ $ret -eq 0 ] || echo_i "failed"
 status=$((status + ret))
 
-n=$((n + 1))
-echo_i "check that CHAOS addresses are compared correctly ($n)"
-ret=0
-$DIG $DIGOPTS @10.53.0.1 +noall +answer ch test.example.chaos >dig.out.test$n || ret=1
-lines=$(wc -l <dig.out.test$n)
-[ ${lines:-0} -eq 2 ] || ret=1
-[ $ret -eq 0 ] || echo_i "failed"
-status=$((status + ret))
-
 n=$((n + 1))
 echo_i "check that a Report-Channel EDNS option is added to responses ($n)"
 ret=0
diff --git a/bin/tests/system/catz/ns1/catalog-bad5.example.db b/bin/tests/system/catz/ns1/catalog-bad5.example.db
deleted file mode 100644 (file)
index 3af97fd..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@ 3600 SOA . . 1 86400 3600 86400 3600
-@ 3600 CH NS invalid.
-version CH TXT "2"
index 703060d596da39f95cf03bc94cca08524da918db..b702e09f4ad76dddcd65b53e1ba0249b32111aa1 100644 (file)
@@ -146,20 +146,6 @@ view "default" {
        };
 };
 
-view "ch" ch {
-
-       # Non-IN class catalog zone
-       zone "catalog-bad5.example" ch {
-               type primary;
-               file "catalog-bad5.example.db";
-               allow-transfer { any; };
-               allow-update { any; };
-               also-notify { 10.53.0.2; };
-               notify explicit;
-       };
-
-};
-
 key tsig_key. {
        secret "LSAnCU+Z";
        algorithm @DEFAULT_HMAC@;
diff --git a/bin/tests/system/checkconf/altdb.conf b/bin/tests/system/checkconf/altdb.conf
deleted file mode 100644 (file)
index 32e6a80..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-view override_bind chaos {
-       zone "version.bind" chaos {
-               type primary;
-               database "_builtin version";
-       };
-};
diff --git a/bin/tests/system/checkconf/bad-chaos-view.conf b/bin/tests/system/checkconf/bad-chaos-view.conf
new file mode 100644 (file)
index 0000000..8f9cf35
--- /dev/null
@@ -0,0 +1,3 @@
+view chaos ch {
+       match-clients { any; };
+};
index 7ba3fa0c98ac990860e69f4922f751a97129b0ee..412204e7ff3f4afd74ffcc70069aa35afb233e96 100644 (file)
@@ -267,12 +267,6 @@ view "fifth" {
        };
        key-directory ".";
 };
-view "chaos" chaos {
-       zone "hostname.bind" chaos {
-               type primary;
-               database "_builtin hostname";
-       };
-};
 dyndb "name" "library.so" {
        this;
        \};
index f53696d8eb442c70615318a0aea0e18622ec3aad..5ade266edbf65d2da9cc78c8a1fcc48c2626f360 100644 (file)
@@ -22,4 +22,3 @@ dnssec-view1 IN fifth primary
 dnssec-view2 IN fifth primary
 dnssec-view3 IN fifth primary
 dnssec-view4 IN fifth primary
-hostname.bind chaos chaos primary
index 539afaf56a6e1214a6b50e6960acbf0ecb6c079b..ff976d842b64d9bfb78e5c2361fe4d3f68066450 100644 (file)
@@ -345,16 +345,6 @@ if [ $ret -ne 0 ]; then
 fi
 status=$((status + ret))
 
-n=$((n + 1))
-echo_i "checking that named-checkconf -z skips zone check with alternate databases ($n)"
-ret=0
-$CHECKCONF -z altdb.conf >checkconf.out$n 2>&1 || ret=1
-if [ $ret -ne 0 ]; then
-  echo_i "failed"
-  ret=1
-fi
-status=$((status + ret))
-
 n=$((n + 1))
 echo_i "checking that named-checkconf -z skips zone check with DLZ ($n)"
 ret=0
@@ -742,16 +732,5 @@ if [ $ret != 0 ]; then
 fi
 status=$((status + ret))
 
-n=$((n + 1))
-echo_i "check 'recursion yes;' is warned and disabled in a non-IN view ($n)"
-ret=0
-$CHECKCONF warn-chaos-recursion.conf >checkconf.out$n 2>&1 || ret=1
-grep -F "recursion will be disabled" checkconf.out$n >/dev/null || ret=1
-if [ $ret != 0 ]; then
-  echo_i "failed"
-  ret=1
-fi
-status=$((status + ret))
-
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
diff --git a/bin/tests/system/checkconf/warn-chaos-recursion.conf b/bin/tests/system/checkconf/warn-chaos-recursion.conf
deleted file mode 100644 (file)
index 0196510..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-options {
-       directory ".";
-};
-
-view chaos ch {
-        match-clients { any; };
-        recursion yes;
-        zone "." {
-                type hint;
-                file "chaos.hints";
-        };
-};
diff --git a/bin/tests/system/class/ns1/chaos.db.in b/bin/tests/system/class/ns1/chaos.db.in
deleted file mode 100644 (file)
index 43ca58f..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-.                  CH NS ns.root.
-ns.root.           CH A ns.root. 1
-ns.root.           CH AAAA \# 1 00
-
index 76f85fc6c997d3aea57e85afe05c7dad5885f60c..cdf9f2de332c1cb0ffed70d1ea4018643195310d 100644 (file)
@@ -16,16 +16,3 @@ key rndc_key {
 controls {
        inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
-
-view chaos ch {
-       match-clients { any; };
-       recursion yes;
-       zone "." {
-               type hint;
-               file "chaos.db";
-       };
-       zone "version.bind" {
-               type primary;
-               database "_builtin version";
-       };
-};
diff --git a/bin/tests/system/class/ns2/example.db.in b/bin/tests/system/class/ns2/example.db.in
deleted file mode 100644 (file)
index a658ddb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-$TTL 300
-@ CH SOA ns.example. hostmaster.example. 1 3600 1200 604800 300
-@ CH NS ns.example.
-ns CH TXT "ns"
-a CH A target.example. 1
-target CH TXT "target"
index 5618c152164f88c6894eae437d2e1d714f61a7d0..08fe4fced47b57df168080e36d898ba3cc5c9de2 100644 (file)
@@ -30,13 +30,3 @@ view default {
                };
        };
 };
-
-view chaos ch {
-       match-clients { any; };
-       recursion no;
-       zone example {
-               type primary;
-               file "example.db";
-               allow-update { any; };
-       };
-};
index 3016333aad602afc4040b7cb7fbc3d320c146fdf..98b955162b5d4e2db1038c6650fd736e1be79107 100644 (file)
@@ -17,12 +17,3 @@ key rndc_key {
 controls {
        inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
-
-view chaos ch {
-       match-clients { any; };
-       recursion yes;
-        dnssec-validation no;
-        forward only;
-        forwarders port @PORT@ { 10.53.0.2; };
-        deny-answer-addresses { 0.0.0.0/0; ::/0; };
-};
index c70a2f8290cb97bf7ac149df47ca365e2806a178..7e1d1d934a5cec8ae05d34e112d57bfdf51191b8 100644 (file)
@@ -14,6 +14,4 @@
 # shellcheck source=conf.sh
 . ../conf.sh
 
-cp ns1/chaos.db.in ns1/chaos.db
-cp ns2/example.db.in ns2/example.db
 cp ns2/localhost.db.in ns2/localhost.db
index 5b4fef9ae46cca23cc54745d90c92937616b35d1..fa5817ea42595672e9850c3431ac6dc9b0db2a07 100644 (file)
@@ -18,6 +18,7 @@ import isctest
 pytestmark = pytest.mark.extra_artifacts(
     [
         "*/*.db",
+        "*/*.jnl",
     ]
 )
 
@@ -31,7 +32,7 @@ def test_chaos_recursion():
 def test_chaos_auth():
     msg = isctest.query.create("a.example.", "A", qclass="CH")
     res = isctest.query.udp(msg, "10.53.0.2")
-    isctest.check.noerror(res)
+    isctest.check.refused(res)
 
 
 def test_chaos_forward():
index 30e3ba6d2ae80b017dabd075357958bbb28827e5..925d1791a8dc294a8794ab7799592013d2bfe2db 100644 (file)
@@ -21,6 +21,7 @@ import isctest
 pytestmark = pytest.mark.extra_artifacts(
     [
         "*/*.db",
+        "*/*.jnl",
     ]
 )
 
index 3d6c26211b0b80525c92fcbffdcad91471815e46..7255adbfed062a87798002d4e1305cdd5e1180b0 100644 (file)
@@ -277,7 +277,7 @@ main(int argc, char *argv[]) {
        RUNCHECK(dns_requestmgr_create(isc_g_mctx, dispatchmgr, dispatchv4,
                                       NULL, &requestmgr));
 
-       dns_view_create(isc_g_mctx, NULL, 0, "_test", &view);
+       dns_view_create(isc_g_mctx, NULL, dns_rdataclass_in, "_test", &view);
 
        isc_loopmgr_setup(sendqueries, NULL);
        isc_loopmgr_teardown(teardown_view, view);
diff --git a/bin/tests/system/resolver/ns1/chaostest.db b/bin/tests/system/resolver/ns1/chaostest.db
deleted file mode 100644 (file)
index 4c967b9..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-$TTL           3600
-@              CHAOS SOA       @ @ 1970010100 86400 600 86400 300
-@              CHAOS NS        @
-version         CHAOS TXT       "CH 1.0"
-hostname        CHAOS TXT       "unknown"
index 1fb6ea8e274d346b45b5f7bea1b3b4259921407e..4a4e50dc5ed1d7c909a0b687c73e5ad775b9e09b 100644 (file)
@@ -39,21 +39,6 @@ server fd92:7065:b8e:ffff::1000 {
      transfer-source-v6 fd92:7065:b8e:ffff::1001;
 };
 
-/*
- * Must be first view so that there is a CH cache with name
- * "globalcache" before the recursive "default"/IN view is configured.
- */
-view "class" chaos {
-       zone "chaostest" CHAOS {
-                type primary;
-                file "chaostest.db";
-        };
-};
-
-/*
- * Must be second view so that so that we can check we don't attach to the
- * "globalcache"/CH cache.
- */
 view "default" {
        zone "." {
                type hint;
index 06ef98f69766422898a87d53e23092b68596f5d0..ead3d7362c13a0d8612568efb080f93ee1ab729e 100755 (executable)
@@ -783,12 +783,10 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
 n=$((n + 1))
-echo_i "checking REFUSED is returned when querying non existing domain in CH class ($n)"
+echo_i "checking REFUSED is returned when querying name in CH class ($n)"
 ret=0
-dig_with_opts @10.53.0.1 hostname.chaostest txt ch >dig.ns1.out.1.${n} || ret=1
-grep "status: NOERROR" dig.ns1.out.1.${n} >/dev/null || ret=1
-dig_with_opts @10.53.0.1 id.hostname txt ch >dig.ns1.out.2.${n} || ret=1
-grep "status: REFUSED" dig.ns1.out.2.${n} >/dev/null || ret=1
+dig_with_opts @10.53.0.1 id.hostname txt ch >dig.ns1.out.${n} || ret=1
+grep "status: REFUSED" dig.ns1.out.${n} >/dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
index 434c56edbaf40f399ed4103804f249a06ea8ed38..c5b17c2a27c75ad4472a7dbffc6d809315c8f631 100644 (file)
@@ -44,15 +44,3 @@ view "in" {
                file "broken5.db";
        };
 };
-
-view "class10" class10 {
-       zone "." class10 {
-               type hint;
-               file "class10.hints";
-       };
-
-       zone "example." class10 {
-               type primary;
-               file "example-class10.db";
-       };
-};
index e43c87e7cee0aa601591263a09b058a73e7542dd..1ba53795f63412b9575d682da74ea6b65d5c1a3f 100644 (file)
@@ -2046,7 +2046,7 @@ setup(void *arg ISC_ATTR_UNUSED) {
                isc_g_mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
                have_ipv6 ? dispatchvx : NULL, &requestmgr));
 
-       dns_view_create(isc_g_mctx, NULL, 0, "_mdig", &view);
+       dns_view_create(isc_g_mctx, NULL, dns_rdataclass_in, "_mdig", &view);
 }
 
 /*% Main processing routine for mdig */
index 10ba133ef1c4a792122a242d5df14c424ce631df..86ae19f5ccf10168c8b04cb066cb1e56671083fc 100644 (file)
@@ -6742,9 +6742,8 @@ with that view. When no view-specific value is given, the value in the
 default values specified in the :any:`view` statement; these view-specific
 defaults take precedence over those in the :namedconf:ref:`options` statement.
 
-Views are class-specific. If no class is given, class IN is assumed.
-Note that all non-IN views must contain a hint zone, since only the IN
-class has compiled-in default hints.
+Only class IN can be used for the views.  If no class is given, class IN is
+assumed.
 
 If there are no :any:`view` statements in the config file, a default view
 that matches any client is automatically created in class IN. Any
index f4f6daf9fe495fdee564f991ce6750a5ec94b425..f5fcf239ed95874d5da9ed6da3eb683d8a811810 100644 (file)
@@ -118,6 +118,19 @@ dns_view_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispatchmgr,
        REQUIRE(name != NULL);
        REQUIRE(viewp != NULL && *viewp == NULL);
 
+       switch (rdclass) {
+       case dns_rdataclass_in:
+               break;
+       case dns_rdataclass_chaos:
+               if (strcmp(name, "_bind") == 0) {
+                       /* allowed */
+                       break;
+               }
+               FALLTHROUGH;
+       default:
+               UNREACHABLE();
+       }
+
        result = isc_file_sanitize(NULL, name, "nta", buffer, sizeof(buffer));
        RUNTIME_CHECK(result == ISC_R_SUCCESS);
 
index 35432b116e14582740ba1482c5bd09e3735ca481..edcf039ab531284d961096963901aeeaf5895786 100644 (file)
@@ -6303,6 +6303,18 @@ isccfg_check_namedconf(const cfg_obj_t *config, unsigned int flags,
                        }
                }
                symtype = vclass + 1;
+               /*
+                * Only the Internet (IN) class is allowed for user-defined
+                * views.  The builtin "_bind" view (Chaos) is generated
+                * internally and never appears in the configuration here.
+                */
+               if (tresult == ISC_R_SUCCESS && vclass != dns_rdataclass_in) {
+                       cfg_obj_log(view, ISC_LOG_ERROR,
+                                   "view '%s': only Internet (IN) class is "
+                                   "allowed",
+                                   key);
+                       tresult = ISC_R_FAILURE;
+               }
                if (tresult == ISC_R_SUCCESS && symtab != NULL) {
                        symvalue.as_cpointer = view;
                        tresult = isc_symtab_define(symtab, key, symtype,