From: Matthijs Mekking Date: Tue, 24 Mar 2026 16:02:36 +0000 (+0100) Subject: Add the modified zone configuration to NZD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=98784ed75396f6c5a36d350aac9f2f8e2523ea2d;p=thirdparty%2Fbind9.git Add the modified zone configuration to NZD 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. --- diff --git a/bin/named/server.c b/bin/named/server.c index 35b5340173e..0ad94b76ac9 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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,