}
}
-static isc_result_t
-save_zoneconfig(dns_zone_t *zone, const cfg_obj_t *zconfig) {
- isc_result_t result;
- isc_buffer_t *text = NULL;
-
- isc_buffer_allocate(isc_g_mctx, &text, 256);
-
- ns_dzarg_t dzarg = {
- .magic = DZARG_MAGIC,
- .text = text,
- };
-
- cfg_printx(zconfig, CFG_PRINTER_ONELINE, emit_text, &dzarg);
- CHECK(putnull(text));
-
- dns_zone_setcfg(zone, isc_buffer_base(text));
-
-cleanup:
- isc_buffer_free(&text);
- return result;
-}
-
/*
* Configure or reconfigure a zone.
*/
}
CHECK(named_zone_configure(config, vconfig, zconfig, aclctx,
kasplist, zone, NULL));
- CHECK(save_zoneconfig(zone, zconfig));
dns_zone_attach(zone, &view->redirect);
goto cleanup;
}
*/
CHECK(named_zone_configure(config, vconfig, zconfig, aclctx, kasplist,
zone, raw));
- CHECK(save_zoneconfig(zone, zconfig));
/*
* Add the zone to its view in the new view list.
effective = cfg_effective_config(config, builtin);
/*
- * Save the user configuration in text format, to display with "rndc
- * showconf". (Text takes up less memory than an object tree.)
+ * Save the user configuration for later reference.
*/
- if (server->userconftext != NULL) {
- isc_buffer_free(&server->userconftext);
+ if (server->userconfig != NULL) {
+ cfg_obj_detach(&server->userconfig);
}
- isc_buffer_allocate(isc_g_mctx, &server->userconftext, BUFSIZ);
-
- dzarg = (ns_dzarg_t){
- .magic = DZARG_MAGIC,
- .text = server->userconftext,
- };
- cfg_printx(config, 0, emit_text, &dzarg);
+ cfg_obj_attach(config, &server->userconfig);
/*
* And finally we apply the effective configuration.
isc_tlsctx_cache_detach(&server->tlsctx_client_cache);
}
- if (server->userconftext != NULL) {
- isc_buffer_free(&server->userconftext);
+ if (server->userconfig != NULL) {
+ cfg_obj_detach(&server->userconfig);
}
if (server->effectivetext != NULL) {
isc_result_t result;
char zonename[DNS_NAME_FORMATSIZE];
dns_zone_t *zone = NULL;
- const char *zconfig = NULL;
+ const cfg_obj_t *zconfig = NULL;
+ ns_dzarg_t dzarg = {
+ .magic = DZARG_MAGIC,
+ .text = text,
+ };
REQUIRE(text != NULL);
}
CHECK(putstr(text, "zone "));
- CHECK(putstr(text, zconfig));
+ cfg_printx(zconfig, CFG_PRINTER_ONELINE, emit_text, &dzarg);
+ CHECK(dzarg.result);
CHECK(putstr(text, ";"));
result = ISC_R_SUCCESS;
}
if (strcasecmp(arg, "-user") == 0) {
- result = putmem(text, isc_buffer_base(server->userconftext),
- isc_buffer_usedlength(server->userconftext));
+ cfg_printx(server->userconfig, 0, emit_text, &dzarg);
+ result = dzarg.result;
} else if (strcasecmp(arg, "-effective") == 0) {
if (server->effectivetext != NULL) {
result = putmem(
*/
void
-dns_zone_setcfg(dns_zone_t *zone, const char *cfg);
+dns_zone_setcfg(dns_zone_t *zone, void *cfg, void (*cfg_detach)(void *));
/*%<
- * Save a copy of the configuration text for 'zone', which can be
+ * Set a pointer to the configuration object for 'zone', which can be
* used later to dump the configuration status.
*
* Requires:
* \li 'zone' to be a valid zone.
*/
-const char *
+void *
dns_zone_getcfg(dns_zone_t *zone);
/*%<
- * Return a pointer to the configuration text for 'zone', that was
- * previously saved using _setcfg().
+ * Return a pointer to the configuration object for 'zone', that was
+ * previously set using _setcfg().
*
* Requires:
* \li 'zone' to be a valid zone.
void *hooktable;
void (*hooktable_free)(isc_mem_t *, void **);
- /* Configuration text */
- char *cfg;
+ /* Configuration object */
+ void *cfg;
+ void (*cfg_detach)(void *);
};
#define zonediff_init(z, d) \
}
/* Detach the zone configuration pointer */
- dns_zone_setcfg(zone, NULL);
+ dns_zone_setcfg(zone, NULL, NULL);
LOCK_ZONE(zone);
INSIST(zone != zone->raw);
}
void
-dns_zone_setcfg(dns_zone_t *zone, const char *cfg) {
+dns_zone_setcfg(dns_zone_t *zone, void *cfg, void (*cfg_detach)(void *)) {
REQUIRE(DNS_ZONE_VALID(zone));
- if (zone->cfg != NULL) {
- isc_mem_free(zone->mctx, zone->cfg);
- }
- if (cfg != NULL) {
- zone->cfg = isc_mem_strdup(zone->mctx, cfg);
+ if (zone->cfg != NULL && zone->cfg_detach != NULL) {
+ zone->cfg_detach(zone->cfg);
+ zone->cfg = NULL;
}
+ zone->cfg = cfg;
+ zone->cfg_detach = cfg_detach;
}
-const char *
+void *
dns_zone_getcfg(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));