return ISC_R_SUCCESS;
}
+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
+save_zoneconfig(dns_zone_t *zone, const cfg_obj_t *zconfig) {
+ isc_result_t result;
+ isc_buffer_t *text = NULL;
+ ns_dzarg_t dzarg = {
+ .magic = DZARG_MAGIC,
+ .text = &text,
+ };
+
+ isc_buffer_allocate(isc_g_mctx, &text, 256);
+
+ 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.
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;
named_server_showzone(named_server_t *server, isc_lex_t *lex,
isc_buffer_t **text) {
isc_result_t result;
- const cfg_obj_t *zconfig = NULL;
char zonename[DNS_NAME_FORMATSIZE];
dns_zone_t *zone = NULL;
- ns_dzarg_t dzarg;
+ const char *zconfig = NULL;
REQUIRE(text != NULL);
}
CHECK(putstr(text, "zone "));
- dzarg.magic = DZARG_MAGIC;
- dzarg.text = text;
- dzarg.result = ISC_R_SUCCESS;
- cfg_printx(zconfig, CFG_PRINTER_ONELINE, emit_text, &dzarg);
- CHECK(dzarg.result);
-
+ CHECK(putstr(text, zconfig));
CHECK(putstr(text, ";"));
result = ISC_R_SUCCESS;
return dns_notifytype_explicit;
}
-static void
-detach_cfg(void *arg) {
- cfg_obj_t *cfg = (cfg_obj_t *)arg;
- cfg_obj_detach(&cfg);
-}
-
isc_result_t
named_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
const cfg_obj_t *zconfig, cfg_aclconfctx_t *aclctx,
break;
}
- /* Save the configuration for later use */
- cfg_obj_t *cfg = UNCONST(zconfig);
- cfg_obj_ref(cfg);
- dns_zone_setcfg(zone, (void *)cfg, detach_cfg);
-
result = ISC_R_SUCCESS;
cleanup:
*/
void
-dns_zone_setcfg(dns_zone_t *zone, void *cfg, void (*cfg_detach)(void *));
+dns_zone_setcfg(dns_zone_t *zone, const char *cfg);
/*%<
- * Set a pointer to the configuration object for 'zone', which can be
+ * Save a copy of the configuration text for 'zone', which can be
* used later to dump the configuration status.
*
* Requires:
* \li 'zone' to be a valid zone.
*/
-void *
+
+const char *
dns_zone_getcfg(dns_zone_t *zone);
/*%<
- * Return a pointer to the configuration object for 'zone', that was
- * previously set using _setcfg().
+ * Return a pointer to the configuration text for 'zone', that was
+ * previously saved using _setcfg().
*
* Requires:
* \li 'zone' to be a valid zone.
void *hooktable;
void (*hooktable_free)(isc_mem_t *, void **);
- /* Configuration object */
- void *cfg;
- void (*cfg_detach)(void *);
+ /* Configuration text */
+ char *cfg;
};
#define zonediff_init(z, d) \
}
/* Detach the zone configuration pointer */
- dns_zone_setcfg(zone, NULL, NULL);
+ dns_zone_setcfg(zone, NULL);
LOCK_ZONE(zone);
INSIST(zone != zone->raw);
}
void
-dns_zone_setcfg(dns_zone_t *zone, void *cfg, void (*cfg_detach)(void *)) {
+dns_zone_setcfg(dns_zone_t *zone, const char *cfg) {
REQUIRE(DNS_ZONE_VALID(zone));
- if (zone->cfg != NULL && zone->cfg_detach != NULL) {
- zone->cfg_detach(zone->cfg);
- zone->cfg = NULL;
+ if (zone->cfg != NULL) {
+ isc_mem_free(zone->mctx, zone->cfg);
+ }
+ if (cfg != NULL) {
+ zone->cfg = isc_mem_strdup(zone->mctx, cfg);
}
- zone->cfg = cfg;
- zone->cfg_detach = cfg_detach;
}
-void *
+const char *
dns_zone_getcfg(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));