*/
typedef struct ns_cfgctx {
isc_mem_t *mctx;
- cfg_parser_t *conf_parser;
- cfg_parser_t *add_parser;
cfg_obj_t *config;
cfg_obj_t *vconfig;
cfg_obj_t *nzf_config;
cfg_obj_t *zoneobj = NULL;
ns_cfgctx_t *cfg = NULL;
dns_zone_t *zone = NULL;
+ cfg_parser_t *parser = NULL;
if (isc_loop_shuttingdown(isc_loop_get(isc_tid()))) {
goto cleanup;
confbuf = NULL;
result = dns_catz_generate_zonecfg(cz->origin, cz->entry, &confbuf);
if (result == ISC_R_SUCCESS) {
- cfg_parser_reset(cfg->add_parser);
- result = cfg_parse_buffer(cfg->add_parser, confbuf, "catz", 0,
+ CHECK(cfg_parser_create(cfg->mctx, &parser));
+ result = cfg_parse_buffer(parser, confbuf, "catz", 0,
&cfg_type_addzoneconf, 0, &zoneconf);
+ cfg_parser_destroy(&parser);
isc_buffer_free(&confbuf);
}
/*
ns_cfgctx_t *cfg = NULL;
dns_zone_t *zone = NULL;
isc_result_t result;
+ cfg_parser_t *parser = NULL;
isc_buffer_init(&namebuf, nameb, DNS_NAME_FORMATSIZE);
dns_name_totext(dns_catz_entry_getname(entry), DNS_NAME_OMITFINALDOT,
result = dns_catz_generate_zonecfg(data->catz, entry, &confbuf);
if (result == ISC_R_SUCCESS) {
- cfg_parser_reset(cfg->add_parser);
- result = cfg_parse_buffer(cfg->add_parser, confbuf, "catz", 0,
+ CHECK(cfg_parser_create(cfg->mctx, &parser));
+ result = cfg_parse_buffer(parser, confbuf, "catz", 0,
&cfg_type_addzoneconf, 0, &zoneconf);
+ cfg_parser_destroy(&parser);
isc_buffer_free(&confbuf);
}
/*
static isc_result_t
setup_newzones(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
- cfg_parser_t *config_parser, cfg_aclconfctx_t *aclctx) {
+ cfg_aclconfctx_t *aclctx) {
isc_result_t result = ISC_R_SUCCESS;
bool allow = false;
ns_cfgctx_t *nzcfg = NULL;
* a shutdown race later.
*/
isc_mem_attach(view->mctx, &nzcfg->mctx);
- cfg_parser_attach(config_parser, &nzcfg->conf_parser);
- cfg_parser_attach(named_g_addparser, &nzcfg->add_parser);
cfg_aclconfctx_attach(aclctx, &nzcfg->aclctx);
result = dns_view_setnewzones(view, true, nzcfg, newzone_cfgctx_destroy,
mapsize);
if (result != ISC_R_SUCCESS) {
cfg_aclconfctx_detach(&nzcfg->aclctx);
- cfg_parser_destroy(&nzcfg->conf_parser);
- cfg_parser_destroy(&nzcfg->add_parser);
isc_mem_putanddetach(&nzcfg->mctx, nzcfg, sizeof(*nzcfg));
dns_view_setnewzones(view, false, NULL, NULL, 0ULL);
return result;
size_t zone_config_len;
cfg_obj_t *zoneconf = NULL;
char bufname[DNS_NAME_FORMATSIZE];
+ cfg_parser_t *parser = NULL;
REQUIRE(view != NULL);
REQUIRE(key != NULL);
snprintf(bufname, sizeof(bufname), "%.*s", (int)zone_name_len,
zone_name);
- cfg_parser_reset(named_g_addparser);
- result = cfg_parse_buffer(named_g_addparser, *text, bufname, 0,
+ CHECK(cfg_parser_create(view->mctx, &parser));
+ result = cfg_parse_buffer(parser, *text, bufname, 0,
&cfg_type_addzoneconf, 0, &zoneconf);
+ cfg_parser_destroy(&parser);
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_ERROR,
ISC_LOG_DEBUG(1), "apply_configuration: %s", __func__);
static isc_result_t
-create_views(cfg_obj_t *config, cfg_parser_t *parser, cfg_aclconfctx_t *aclctx,
+create_views(cfg_obj_t *config, cfg_aclconfctx_t *aclctx,
dns_viewlist_t *viewlist) {
isc_result_t result = ISC_R_SUCCESS;
const cfg_obj_t *views = NULL;
}
INSIST(view != NULL);
- result = setup_newzones(view, config, vconfig, parser, aclctx);
+ result = setup_newzones(view, config, vconfig, aclctx);
dns_view_detach(&view);
if (result != ISC_R_SUCCESS) {
}
INSIST(view != NULL);
- result = setup_newzones(view, config, NULL, parser, aclctx);
+ result = setup_newzones(view, config, NULL, aclctx);
dns_view_detach(&view);
}
}
static isc_result_t
-apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
- cfg_obj_t *bindkeys, named_server_t *server,
- bool first_time) {
+apply_configuration(cfg_obj_t *config, 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;
goto cleanup_kasplist;
}
- result = create_views(config, configparser, aclctx, &viewlist);
+ result = create_views(config, aclctx, &viewlist);
if (result != ISC_R_SUCCESS) {
goto cleanup_viewlist;
}
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_DEBUG(1), "load_configuration");
- result = cfg_parser_create(isc_g_mctx, &parser);
- if (result != ISC_R_SUCCESS) {
- goto out;
- }
-
- result = named_config_parsefile(parser, &config);
- if (result != ISC_R_SUCCESS) {
- goto cleanup;
- }
+ CHECK(cfg_parser_create(isc_g_mctx, &parser));
+ CHECK(named_config_parsefile(parser, &config));
if (named_g_bindkeysfile != NULL) {
/*
}
}
- result = apply_configuration(parser, config, bindkeys, server,
- first_time);
+ result = apply_configuration(config, bindkeys, server, first_time);
cleanup:
+ if (parser != NULL) {
+ cfg_parser_destroy(&parser);
+ }
if (bindkeys != NULL) {
cfg_obj_destroy(&bindkeys);
}
if (config != NULL) {
cfg_obj_destroy(&config);
}
- cfg_parser_destroy(&parser);
-out:
return result;
}
&named_g_defaultoptions),
"missing 'options' in default config");
- CHECKFATAL(cfg_parser_create(isc_g_mctx, &named_g_addparser),
- "creating additional configuration parser");
-
CHECKFATAL(load_configuration(server, true), "loading configuration");
CHECKFATAL(load_zones(server, false), "loading zones");
}
cfg_obj_destroy(&named_g_defaultconfig);
- cfg_parser_destroy(&named_g_addparser);
(void)named_server_saventa(server);
MDB_dbi dbi;
MDB_val key, data;
ns_dzarg_t dzarg;
+ cfg_parser_t *parser = NULL;
UNUSED(nzcfg);
* config type, giving us a guarantee that valid configuration
* will be written to DB.
*/
- cfg_parser_reset(named_g_addparser);
- result = cfg_parse_file(named_g_addparser, view->new_zone_file,
+ CHECK(cfg_parser_create(nzcfg->mctx, &parser));
+ result = cfg_parse_file(parser, view->new_zone_file,
&cfg_type_addzoneconf, &nzf_config);
+ cfg_parser_destroy(&parser);
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_ERROR, "Error parsing NZF file '%s': %s",
dns_rdataclass_t rdclass;
dns_view_t *view = NULL;
const char *bn = NULL;
+ cfg_parser_t *parser = NULL;
REQUIRE(viewp != NULL && *viewp == NULL);
REQUIRE(zoneobjp != NULL && *zoneobjp == NULL);
*/
isc_buffer_forward(&argbuf, 3);
- cfg_parser_reset(named_g_addparser);
- CHECK(cfg_parse_buffer(named_g_addparser, &argbuf, bn, 0,
- &cfg_type_addzoneconf, 0, &zoneconf));
+ CHECK(cfg_parser_create(server->mctx, &parser));
+ CHECK(cfg_parse_buffer(parser, &argbuf, bn, 0, &cfg_type_addzoneconf, 0,
+ &zoneconf));
+ cfg_parser_destroy(&parser);
+
CHECK(cfg_map_get(zoneconf, "zone", &zlist));
if (!cfg_obj_islist(zlist)) {
CHECK(ISC_R_FAILURE);
return ISC_R_SUCCESS;
cleanup:
+ if (parser != NULL) {
+ cfg_parser_destroy(&parser);
+ }
+
if (zoneconf != NULL) {
cfg_obj_destroy(&zoneconf);
}
dns_zone_t *zone = NULL;
const cfg_obj_t *voptions = NULL;
bool added;
+ cfg_parser_t *parser = NULL;
#ifndef HAVE_LMDB
FILE *fp = NULL;
cfg_obj_t *z;
#endif /* HAVE_LMDB */
if (!added) {
+ TCHECK(cfg_parser_create(cfg->mctx, &parser));
if (cfg->vconfig == NULL) {
- result = delete_zoneconf(
- view, cfg->conf_parser, cfg->config,
- dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, parser, cfg->config,
+ dns_zone_getorigin(zone),
+ NULL);
} else {
voptions = cfg_tuple_get(cfg->vconfig, "options");
- result = delete_zoneconf(
- view, cfg->conf_parser, voptions,
- dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, parser, voptions,
+ dns_zone_getorigin(zone),
+ NULL);
}
+ cfg_parser_destroy(&parser);
if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "former zone configuration "
}
cleanup:
-
#ifndef HAVE_LMDB
if (fp != NULL) {
(void)isc_stdio_close(fp);
dns_db_t *dbp = NULL;
bool added;
isc_result_t result;
+ cfg_parser_t *parser = NULL;
#ifdef HAVE_LMDB
MDB_txn *txn = NULL;
MDB_dbi dbi;
}
if (!added && cfg != NULL) {
+ result = cfg_parser_create(cfg->mctx, &parser);
+ INSIST(result == ISC_R_SUCCESS); /* colin: this is just a
+ shortcut until the
+ initialization function of
+ the parser can't fails */
+
if (cfg->vconfig != NULL) {
const cfg_obj_t *voptions = cfg_tuple_get(cfg->vconfig,
"options");
- result = delete_zoneconf(
- view, cfg->conf_parser, voptions,
- dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, parser, voptions,
+ dns_zone_getorigin(zone),
+ NULL);
} else {
- result = delete_zoneconf(
- view, cfg->conf_parser, cfg->config,
- dns_zone_getorigin(zone), NULL);
+ result = delete_zoneconf(view, parser, cfg->config,
+ dns_zone_getorigin(zone),
+ NULL);
}
+ cfg_parser_destroy(&parser);
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
cfg = *cfgp;
- if (cfg->conf_parser != NULL) {
- if (cfg->config != NULL) {
- cfg_obj_destroy(&cfg->config);
- }
- if (cfg->vconfig != NULL) {
- cfg_obj_destroy(&cfg->vconfig);
- }
- cfg_parser_destroy(&cfg->conf_parser);
+ if (cfg->config != NULL) {
+ cfg_obj_destroy(&cfg->config);
}
- if (cfg->add_parser != NULL) {
- if (cfg->nzf_config != NULL) {
- cfg_obj_destroy(&cfg->nzf_config);
- }
- cfg_parser_destroy(&cfg->add_parser);
+ if (cfg->vconfig != NULL) {
+ cfg_obj_destroy(&cfg->vconfig);
+ }
+ if (cfg->nzf_config != NULL) {
+ cfg_obj_destroy(&cfg->nzf_config);
}
if (cfg->aclctx != NULL) {