]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add the modified zone configuration to NZD
authorMatthijs Mekking <matthijs@isc.org>
Tue, 24 Mar 2026 16:02:36 +0000 (17:02 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 2 Apr 2026 12:35:54 +0000 (12:35 +0000)
When a zone that is configured in named.conf is modified with
'rndc modzone', the zone configuration is deleted from the effective
config. Store the new configuration in the NZD. Mark the zone
as 'modified by rndc modzone'. Otherwise, subsequent calls to
'rndc modzone' would fail because the zone configuration cannot be
found.

bin/named/server.c

index 35b5340173ec47f84db4389ec10bbcede5d540da..0ad94b76ac9b5743f602ec863764a838ba40f780 100644 (file)
@@ -12332,7 +12332,8 @@ do_modzone(named_server_t *server, dns_view_t *view, dns_name_t *name,
        isc_result_t result, tresult;
        dns_zone_t *zone = NULL;
        const cfg_obj_t *voptions = NULL;
-       bool added;
+       const cfg_obj_t *options = NULL;
+       bool added, modded;
        MDB_txn *txn = NULL;
        MDB_dbi dbi;
 
@@ -12358,6 +12359,7 @@ do_modzone(named_server_t *server, dns_view_t *view, dns_name_t *name,
        }
 
        added = dns_zone_getadded(zone);
+       modded = dns_zone_getmodded(zone);
        dns_zone_detach(&zone);
 
        isc_loopmgr_pause();
@@ -12413,17 +12415,16 @@ do_modzone(named_server_t *server, dns_view_t *view, dns_name_t *name,
                CHECK(dns_view_findzone(view, name, DNS_ZTFIND_EXACT, &zone));
        }
 
-       if (!added) {
+       if (!added && !modded) {
                if (view->newzone.vconfig == NULL) {
-                       result = delete_zoneconf(view, server->effectiveconfig,
-                                                dns_zone_getorigin(zone));
+                       options = server->effectiveconfig;
                } else {
-                       voptions = cfg_tuple_get(server->effectiveconfig,
-                                                "options");
-                       result = delete_zoneconf(view, voptions,
-                                                dns_zone_getorigin(zone));
+                       options = cfg_tuple_get(server->effectiveconfig,
+                                               "options");
                }
 
+               result = delete_zoneconf(view, options,
+                                        dns_zone_getorigin(zone));
                if (result != ISC_R_SUCCESS) {
                        TCHECK(putstr(text, "former zone configuration "
                                            "not deleted: "));
@@ -12475,12 +12476,17 @@ do_modzone(named_server_t *server, dns_view_t *view, dns_name_t *name,
                TCHECK(putstr(text, zname));
                TCHECK(putstr(text, "' reconfigured."));
        } else {
+               CHECK(nzd_open(view, 0, &txn, &dbi));
+               CHECK(nzd_save(&txn, dbi, zone, zoneobj));
+
                TCHECK(putstr(text, "zone '"));
                TCHECK(putstr(text, zname));
                TCHECK(putstr(text, "' must also be reconfigured in\n"));
                TCHECK(putstr(text, "named.conf to make changes permanent."));
        }
 
+       dns_zone_setmodded(zone, true);
+
 cleanup:
        if (txn != NULL) {
                (void)nzd_close(&txn, false);
@@ -12659,17 +12665,17 @@ rmzone(void *arg) {
        }
 
        if (!added) {
+               const cfg_obj_t *voptions;
+
                if (view->newzone.vconfig != NULL) {
-                       const cfg_obj_t *voptions =
-                               cfg_tuple_get(view->newzone.vconfig, "options");
-                       result = delete_zoneconf(view, voptions,
-                                                dns_zone_getorigin(zone));
+                       voptions = cfg_tuple_get(view->newzone.vconfig,
+                                                "options");
                } else {
-                       result = delete_zoneconf(view,
-                                                dz->server->effectiveconfig,
-                                                dns_zone_getorigin(zone));
+                       voptions = dz->server->effectiveconfig;
                }
 
+               result = delete_zoneconf(view, voptions,
+                                        dns_zone_getorigin(zone));
                if (result != ISC_R_SUCCESS) {
                        isc_log_write(NAMED_LOGCATEGORY_GENERAL,
                                      NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,