]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Test rndc modzone succeeds twice for a zone in named.conf
authorJINMEI Tatuya <jtatuya@infoblox.com>
Tue, 24 Mar 2026 15:57:49 +0000 (16:57 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 2 Apr 2026 12:35:54 +0000 (12:35 +0000)
If a zone is in named.conf, not originally added by rndc addzone,
rndc modzone for that zone succeeds once, but subsequent modzone
attempts fail. This is because do_modzone removes the zone config
from global or view options, but it would fail due to 'not found'
once the config is removed.

The test is copied from commit b737171ee215446701e7c8d4ac55d8a0e13426aa.

bin/tests/system/addzone/tests_rndc_modzone_without_add.py [new file with mode: 0644]

diff --git a/bin/tests/system/addzone/tests_rndc_modzone_without_add.py b/bin/tests/system/addzone/tests_rndc_modzone_without_add.py
new file mode 100644 (file)
index 0000000..b2a7335
--- /dev/null
@@ -0,0 +1,56 @@
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+import pytest
+
+pytestmark = pytest.mark.extra_artifacts(
+    [
+        "ns*/*.nzf*",
+        "ns*/*.nzd*",
+        "ns1/redirect.db",
+        "ns2/new-zones",
+        "ns2/redirect.db",
+        "ns3/redirect.db",
+    ]
+)
+
+
+def test_rndc_modzone_without_add(ns3):
+    """
+    Confirm "rndc modzone" works for a zone that was not added by "addzone".
+    """
+    # We begin with a zone that has a normal configuration, and then modify it
+    # by rndc modzone. This should succeed and shouldn't cause any disruption.
+    # Previously, it triggered an assertion failure unless LMDB was enabled.
+    cmd = ns3.rndc(
+        'modzone . {type primary; file "redirect.db"; allow-query {none;};};',
+        raise_on_exception=False,
+    )
+    assert cmd.rc == 0
+
+    # Confirm that the modzone took effect in 'rndc showzone'.
+    cmd = ns3.rndc("showzone .", raise_on_exception=False)
+    assert cmd.rc == 0
+    assert 'allow-query { "none"; }' in cmd.out
+
+    # Confirm that 'rndc modzone' still works after the first modzone.
+    # This was not the case before as the zone config was incorrectly
+    # removed in-memory after the first modzone.
+    cmd = ns3.rndc(
+        'modzone . {type primary; file "redirect.db"; allow-query {any;};};',
+        raise_on_exception=False,
+    )
+    assert cmd.rc == 0
+
+    # Confirm that the second modzone took effect in 'rndc showzone'.
+    cmd = ns3.rndc("showzone .", raise_on_exception=False)
+    assert cmd.rc == 0
+    assert 'allow-query { "any"; }' in cmd.out