Commit 83fef99142 for bind
commit 83fef991425b909c748e1b02ec938a7a96a79f88
Author: Alessio Podda <alessio@isc.org>
Date: Thu Sep 10 17:07:22 2026 +0200
Revert "fix: dev: Save userconfig as text instead of a cfg_obj tree"
This reverts commit 9521f231694e0cecdb39be48945f0fe5177eaadc, reversing
changes made to 6451b08f4706e7003133aa9d366ed36a6568475b.
diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h
index 62e3da1268..3268779d63 100644
--- a/bin/named/include/named/server.h
+++ b/bin/named/include/named/server.h
@@ -107,7 +107,7 @@ struct named_server {
isc_signal_t *sigusr1;
cfg_aclconfctx_t *aclctx;
- isc_buffer_t *userconf;
+ cfg_obj_t *userconfig;
cfg_obj_t *effectiveconfig;
};
diff --git a/bin/named/server.c b/bin/named/server.c
index 011dbee480..2365b3d0c3 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -7767,8 +7767,9 @@ configure_kasplist(const cfg_obj_t *config, dns_kasplist_t *kasplist,
}
static isc_result_t
-apply_configuration(cfg_obj_t *effectiveconfig, cfg_obj_t *bindkeys,
- named_server_t *server, bool first_time) {
+apply_configuration(cfg_obj_t *effectiveconfig, cfg_obj_t *userconfig,
+ cfg_obj_t *bindkeys, named_server_t *server,
+ bool first_time) {
const cfg_obj_t *maps[3];
const cfg_obj_t *obj = NULL;
const cfg_obj_t *options = NULL;
@@ -8807,13 +8808,18 @@ apply_configuration(cfg_obj_t *effectiveconfig, cfg_obj_t *bindkeys,
named_g_defaultconfigtime = isc_time_now();
/*
- * Save the current effective configuration
+ * Set the current effective and user configuration
*/
if (server->effectiveconfig != NULL) {
cfg_obj_detach(&server->effectiveconfig);
}
cfg_obj_attach(effectiveconfig, &server->effectiveconfig);
+ if (server->userconfig != NULL) {
+ cfg_obj_detach(&server->userconfig);
+ }
+ cfg_obj_attach(userconfig, &server->userconfig);
+
isc_loopmgr_resume();
exclusive = false;
@@ -8932,28 +8938,11 @@ cleanup_aclctx:
return result;
}
-static void
-emit_text(void *arg, const char *buf, int len) {
- ns_dzarg_t *dzarg = arg;
- isc_result_t result;
-
- REQUIRE(dzarg != NULL && ISC_MAGIC_VALID(dzarg, DZARG_MAGIC));
- result = putmem(dzarg->text, buf, len);
- if (result != ISC_R_SUCCESS && dzarg->result == ISC_R_SUCCESS) {
- dzarg->result = result;
- }
-}
-
static isc_result_t
load_configuration(named_server_t *server, bool first_time) {
isc_result_t result;
cfg_obj_t *config = NULL, *effective = NULL;
cfg_obj_t *bindkeys = NULL, *builtin = NULL;
- ns_dzarg_t dzarg = {
- .magic = DZARG_MAGIC,
- .result = ISC_R_SUCCESS,
- .text = server->userconf,
- };
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_DEBUG(1), "load_configuration");
@@ -8993,20 +8982,8 @@ load_configuration(named_server_t *server, bool first_time) {
/* Merge and apply */
effective = cfg_effective_config(config, builtin);
-
- /*
- * Save the user configuration for later reference.
- * We keep it in text format to save space; we won't need
- * to access it as a tree again after this.
- */
- if (server->userconf != NULL) {
- isc_buffer_free(&server->userconf);
- }
- isc_buffer_allocate(isc_g_mctx, &server->userconf, BUFSIZ);
- dzarg.text = server->userconf;
- cfg_printx(config, 0, emit_text, &dzarg);
-
- result = apply_configuration(effective, bindkeys, server, first_time);
+ result = apply_configuration(effective, config, bindkeys, server,
+ first_time);
cleanup:
if (bindkeys != NULL) {
@@ -9616,8 +9593,8 @@ named_server_destroy(named_server_t **serverp) {
isc_tlsctx_cache_detach(&server->tlsctx_client_cache);
}
- if (server->userconf != NULL) {
- isc_buffer_free(&server->userconf);
+ if (server->userconfig != NULL) {
+ cfg_obj_detach(&server->userconfig);
}
if (server->effectiveconfig != NULL) {
@@ -12950,6 +12927,18 @@ cleanup:
return result;
}
+static void
+emit_text(void *arg, const char *buf, int len) {
+ ns_dzarg_t *dzarg = arg;
+ isc_result_t result;
+
+ REQUIRE(dzarg != NULL && ISC_MAGIC_VALID(dzarg, DZARG_MAGIC));
+ result = putmem(dzarg->text, buf, len);
+ if (result != ISC_R_SUCCESS && dzarg->result == ISC_R_SUCCESS) {
+ dzarg->result = result;
+ }
+}
+
/*
* Act on a "showzone" command from the command channel.
*/
@@ -12999,7 +12988,7 @@ cleanup:
isc_result_t
named_server_showconf(named_server_t *server, isc_lex_t *lex,
isc_buffer_t *text) {
- isc_result_t result;
+ isc_result_t result, tresult;
const char *arg = NULL;
cfg_obj_t *config = NULL;
ns_dzarg_t dzarg = {
@@ -13018,10 +13007,7 @@ named_server_showconf(named_server_t *server, isc_lex_t *lex,
return ISC_R_UNEXPECTEDEND;
}
if (strcasecmp(arg, "-user") == 0) {
- putmem(text, isc_buffer_base(server->userconf),
- isc_buffer_usedlength(server->userconf));
- result = ISC_R_SUCCESS;
- goto cleanup;
+ cfg_obj_attach(server->userconfig, &config);
} else if (strcasecmp(arg, "-builtin") == 0) {
named_config_parsedefaults(&config);
} else if (strcasecmp(arg, "-effective") == 0) {