return (result);
}
+static void
+configure_zone_setviewcommit(isc_result_t result, const cfg_obj_t *zconfig,
+ dns_view_t *view)
+{
+ const char *zname;
+ dns_fixedname_t fixorigin;
+ dns_name_t *origin;
+ isc_result_t result2;
+ dns_view_t *pview = NULL;
+ dns_zone_t *zone = NULL;
+ dns_zone_t *raw = NULL;
+
+ zname = cfg_obj_asstring(cfg_tuple_get(zconfig, "name"));
+ dns_fixedname_init(&fixorigin);
+ origin = dns_fixedname_name(&fixorigin);
+
+ result2 = dns_name_fromstring(origin, zname, 0, NULL);
+ if (result2 != ISC_R_SUCCESS) {
+ return;
+ }
+
+ result2 = dns_viewlist_find(&named_g_server->viewlist, view->name,
+ view->rdclass, &pview);
+ if (result2 != ISC_R_SUCCESS) {
+ return;
+ }
+
+ result2 = dns_view_findzone(pview, origin, &zone);
+ if (result2 != ISC_R_SUCCESS) {
+ dns_view_detach(&pview);
+ return;
+ }
+
+ dns_zone_getraw(zone, &raw);
+
+ if (result == ISC_R_SUCCESS) {
+ dns_zone_setviewcommit(zone);
+ if (raw != NULL)
+ dns_zone_setviewcommit(raw);
+ } else {
+ dns_zone_setviewrevert(zone);
+ if (raw != NULL)
+ dns_zone_setviewrevert(raw);
+ }
+
+ if (raw != NULL) {
+ dns_zone_detach(&raw);
+ }
+
+ dns_zone_detach(&zone);
+ dns_view_detach(&pview);
+}
+
#ifndef HAVE_LMDB
static isc_result_t
const cfg_listelt_t *element;
nzctx = view->new_zone_config;
- if (nzctx == NULL || nzctx->nzf_config == NULL)
+ if (nzctx == NULL || nzctx->nzf_config == NULL) {
return (ISC_R_SUCCESS);
+ }
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
result = ISC_R_SUCCESS;
cleanup:
+ for (element = cfg_list_first(zonelist);
+ element != NULL;
+ element = cfg_list_next(element))
+ {
+ const cfg_obj_t *zconfig = cfg_listelt_value(element);
+ configure_zone_setviewcommit(result, zconfig, view);
+ }
+
return (result);
}
/* zone zonename { config; }; */
result = isc_buffer_reserve(text, 5 + zone_name_len + 1 +
zone_config_len + 2);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
+ }
putstr(text, "zone ");
putmem(text, (const void *) zone_name, zone_name_len);
result = ISC_R_SUCCESS;
cleanup:
- if (zoneconf != NULL)
+ if (zoneconf != NULL) {
cfg_obj_destroy(named_g_addparser, &zoneconf);
+ }
return (result);
}
MDB_dbi dbi;
MDB_val key, data;
- if (view->new_zone_config == NULL)
+ if (view->new_zone_config == NULL) {
return (ISC_R_SUCCESS);
+ }
result = nzd_open(view, MDB_RDONLY, &txn, &dbi);
if (result != ISC_R_SUCCESS) {
- result = ISC_R_SUCCESS;
- goto cleanup;
+ return (ISC_R_SUCCESS);
}
isc_log_write(named_g_lctx,
const cfg_obj_t *zoneobj = NULL;
result = data_to_cfg(view, &key, &data, &text, &zoneconf);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
+ }
CHECK(cfg_map_get(zoneconf, "zone", &zlist));
- if (!cfg_obj_islist(zlist))
+ if (!cfg_obj_islist(zlist)) {
CHECK(ISC_R_FAILURE);
+ }
zoneobj = cfg_listelt_value(cfg_list_first(zlist));
CHECK(configure_zone(config, zoneobj, vconfig, mctx,
result = ISC_R_SUCCESS;
cleanup:
- if (cursor != NULL)
- mdb_cursor_close(cursor);
- (void) nzd_close(&txn, ISC_FALSE);
- if (zoneconf != NULL)
+ if (zoneconf != NULL) {
cfg_obj_destroy(named_g_addparser, &zoneconf);
- if (text != NULL)
- isc_buffer_free(&text);
+ }
+ if (cursor != NULL) {
+ mdb_cursor_close(cursor);
+ cursor = NULL;
+ }
+ if (result != ISC_R_SUCCESS) {
+ status = mdb_cursor_open(txn, dbi, &cursor);
+ if (status != 0) {
+ goto cleanup2;
+ }
+ while (mdb_cursor_get(cursor, &key, &data, MDB_NEXT) == 0) {
+ const cfg_obj_t *zlist = NULL;
+ const cfg_obj_t *zconfig = NULL;
+ isc_result_t result2;
+
+ result2 = data_to_cfg(view, &key, &data, &text,
+ &zoneconf);
+ if (result2 != ISC_R_SUCCESS) {
+ goto cleanup2;
+ }
+
+ result2 = cfg_map_get(zoneconf, "zone", &zlist);
+ if (result2 != ISC_R_SUCCESS) {
+ goto cleanup2;
+ }
+
+ zconfig = cfg_listelt_value(cfg_list_first(zlist));
+ configure_zone_setviewcommit(result, zconfig, view);
+
+ cfg_obj_destroy(named_g_addparser, &zoneconf);
+ }
+ }
+ cleanup2:
+ if (text != NULL) {
+ isc_buffer_free(&text);
+ }
+ if (zoneconf != NULL) {
+ cfg_obj_destroy(named_g_addparser, &zoneconf);
+ }
+ if (cursor != NULL) {
+ mdb_cursor_close(cursor);
+ }
+ (void) nzd_close(&txn, ISC_FALSE);
return (result);
}
ISC_LIST_INIT(altsecrets);
/* Create the ACL configuration context */
- if (named_g_aclconfctx != NULL)
+ if (named_g_aclconfctx != NULL) {
cfg_aclconfctx_detach(&named_g_aclconfctx);
+ }
CHECK(cfg_aclconfctx_create(named_g_mctx, &named_g_aclconfctx));
/*
if (first_time) {
result = named_config_parsedefaults(named_g_parser,
&named_g_config);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
named_main_earlyfatal("unable to load "
"internal defaults: %s",
isc_result_totext(result));
+ }
RUNTIME_CHECK(cfg_map_get(named_g_config, "options",
&named_g_defaults) == ISC_R_SUCCESS);
}
i = 0;
options = NULL;
result = cfg_map_get(config, "options", &options);
- if (result == ISC_R_SUCCESS)
+ if (result == ISC_R_SUCCESS) {
maps[i++] = options;
+ }
maps[i++] = named_g_defaults;
maps[i] = NULL;
* server.
*/
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &maxsocks);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
maxsocks = 0;
+ }
result = isc_resource_getcurlimit(isc_resource_openfiles, &nfiles);
if (result == ISC_R_SUCCESS && (isc_resourcevalue_t)maxsocks > nfiles) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
INSIST(result == ISC_R_SUCCESS);
reserved = cfg_obj_asuint32(obj);
if (maxsocks != 0) {
- if (maxsocks < 128U) /* Prevent underflow. */
+ if (maxsocks < 128U) { /* Prevent underflow. */
reserved = 0;
- else if (reserved > maxsocks - 128U) /* Minimum UDP space. */
+ } else if (reserved > maxsocks - 128U) { /* Minimum UDP space. */
reserved = maxsocks - 128;
+ }
}
/* Minimum TCP/stdio space. */
- if (reserved < 128U)
+ if (reserved < 128U) {
reserved = 128;
+ }
if (reserved + 128U > maxsocks && maxsocks != 0) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
char *dir;
DE_CONST(cfg_obj_asstring(obj), dir);
named_geoip_load(dir);
- } else
+ } else {
named_geoip_load(NULL);
+ }
named_g_aclconfctx->geoip = named_g_geoip;
obj = NULL;
CHECK(ISC_R_RANGE);
}
softquota = server->sctx->recursionquota.max - margin;
- } else
+ } else {
softquota = (server->sctx->recursionquota.max * 90) / 100;
+ }
isc_quota_soft(&server->sctx->recursionquota, softquota);
CHECK(configure_view_acl(NULL, config, "blackhole", NULL,
named_g_aclconfctx, named_g_mctx,
&server->sctx->blackholeacl));
- if (server->sctx->blackholeacl != NULL)
+ if (server->sctx->blackholeacl != NULL) {
dns_dispatchmgr_setblackhole(named_g_dispatchmgr,
server->sctx->blackholeacl);
+ }
CHECK(configure_view_acl(NULL, config, "keep-response-order", NULL,
named_g_aclconfctx, named_g_mctx,
avoidv6ports = NULL;
(void)named_config_get(maps, "use-v4-udp-ports", &usev4ports);
- if (usev4ports != NULL)
+ if (usev4ports != NULL) {
portset_fromconf(v4portset, usev4ports, ISC_TRUE);
- else {
+ } else {
CHECKM(isc_net_getudpportrange(AF_INET, &udpport_low,
&udpport_high),
"get the default UDP/IPv4 port range");
- if (udpport_low == udpport_high)
+ if (udpport_low == udpport_high) {
isc_portset_add(v4portset, udpport_low);
- else {
+ } else {
isc_portset_addrange(v4portset, udpport_low,
udpport_high);
}
}
}
(void)named_config_get(maps, "avoid-v4-udp-ports", &avoidv4ports);
- if (avoidv4ports != NULL)
+ if (avoidv4ports != NULL) {
portset_fromconf(v4portset, avoidv4ports, ISC_FALSE);
+ }
(void)named_config_get(maps, "use-v6-udp-ports", &usev6ports);
- if (usev6ports != NULL)
+ if (usev6ports != NULL) {
portset_fromconf(v6portset, usev6ports, ISC_TRUE);
- else {
+ } else {
CHECKM(isc_net_getudpportrange(AF_INET6, &udpport_low,
&udpport_high),
"get the default UDP/IPv6 port range");
- if (udpport_low == udpport_high)
+ if (udpport_low == udpport_high) {
isc_portset_add(v6portset, udpport_low);
- else {
+ } else {
isc_portset_addrange(v6portset, udpport_low,
udpport_high);
}
}
}
(void)named_config_get(maps, "avoid-v6-udp-ports", &avoidv6ports);
- if (avoidv6ports != NULL)
+ if (avoidv6ports != NULL) {
portset_fromconf(v6portset, avoidv6ports, ISC_FALSE);
+ }
dns_dispatchmgr_setavailports(named_g_dispatchmgr, v4portset,
v6portset);
result = named_config_get(maps, "edns-udp-size", &obj);
INSIST(result == ISC_R_SUCCESS);
udpsize = cfg_obj_asuint32(obj);
- if (udpsize < 512)
+ if (udpsize < 512) {
udpsize = 512;
- if (udpsize > 4096)
+ }
+ if (udpsize > 4096) {
udpsize = 4096;
+ }
server->sctx->udpsize = (isc_uint16_t)udpsize;
/* Set the transfer message size for TCP */
result = named_config_get(maps, "transfer-message-size", &obj);
INSIST(result == ISC_R_SUCCESS);
transfer_message_size = cfg_obj_asuint32(obj);
- if (transfer_message_size < 512)
+ if (transfer_message_size < 512) {
transfer_message_size = 512;
- else if (transfer_message_size > 65535)
+ } else if (transfer_message_size > 65535) {
transfer_message_size = 65535;
+ }
server->sctx->transfer_tcp_message_size =
(isc_uint16_t) transfer_message_size;
/*
* Determine which port to use for listening for incoming connections.
*/
- if (named_g_port != 0)
+ if (named_g_port != 0) {
listen_port = named_g_port;
- else
+ } else {
CHECKM(named_config_getport(config, &listen_port), "port");
+ }
/*
* Determing the default DSCP code point.
result = named_config_get(maps, "tcp-listen-queue", &obj);
INSIST(result == ISC_R_SUCCESS);
backlog = cfg_obj_asuint32(obj);
- if ((backlog > 0) && (backlog < 10))
+ if ((backlog > 0) && (backlog < 10)) {
backlog = 10;
+ }
ns_interfacemgr_setbacklog(server->interfacemgr, backlog);
/*
* Even though listen-on is present in the default
* configuration, this way is easier.
*/
- if (options != NULL)
+ if (options != NULL) {
(void)cfg_map_get(options, "listen-on", &clistenon);
+ }
if (clistenon != NULL) {
/* check return code? */
(void)ns_listenlist_fromconfig(clistenon, config,
const cfg_obj_t *clistenon = NULL;
ns_listenlist_t *listenon = NULL;
- if (options != NULL)
+ if (options != NULL) {
(void)cfg_map_get(options, "listen-on-v6", &clistenon);
+ }
if (clistenon != NULL) {
/* check return code? */
(void)ns_listenlist_fromconfig(clistenon, config,
*/
obj = NULL;
if (named_config_get(maps, "pid-file", &obj) == ISC_R_SUCCESS) {
- if (cfg_obj_isvoid(obj))
+ if (cfg_obj_isvoid(obj)) {
named_os_writepidfile(NULL, first_time);
- else
+ } else {
named_os_writepidfile(cfg_obj_asstring(obj),
first_time);
+ }
} else {
named_os_writepidfile(named_g_defaultpidfile, first_time);
}
/* Now combine the two viewlists into one */
ISC_LIST_APPENDLIST(viewlist, builtin_viewlist, link);
+ /*
+ * Commit any dns_zone_setview() calls on all zones in the new
+ * view.
+ */
+ for (view = ISC_LIST_HEAD(viewlist);
+ view != NULL;
+ view = ISC_LIST_NEXT(view, link))
+ {
+ dns_view_setviewcommit(view);
+ }
+
/* Swap our new view list with the production one. */
tmpviewlist = server->viewlist;
server->viewlist = viewlist;
CHECKM(named_tkeyctx_fromconfig(options, named_g_mctx,
named_g_entropy, &t),
"configuring TKEY");
- if (server->sctx->tkeyctx != NULL)
+ if (server->sctx->tkeyctx != NULL) {
dns_tkeyctx_destroy(&server->sctx->tkeyctx);
+ }
server->sctx->tkeyctx = t;
}
/*
* Relinquish root privileges.
*/
- if (first_time)
+ if (first_time) {
named_os_changeuser();
+ }
/*
* Check that the working directory is writable.
obj = NULL;
if (options != NULL &&
cfg_map_get(options, "memstatistics", &obj) == ISC_R_SUCCESS)
+ {
named_g_memstatistics = cfg_obj_asboolean(obj);
- else
+ } else {
named_g_memstatistics =
ISC_TF((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0);
+ }
obj = NULL;
if (named_config_get(maps, "memstatistics-file", &obj) == ISC_R_SUCCESS)
+ {
named_main_setmemstats(cfg_obj_asstring(obj));
- else if (named_g_memstatistics)
+ } else if (named_g_memstatistics) {
named_main_setmemstats("named.memstats");
- else
+ } else {
named_main_setmemstats(NULL);
+ }
obj = NULL;
result = named_config_get(maps, "statistics-file", &obj);
obj = NULL;
result = named_config_get(maps, "cookie-algorithm", &obj);
INSIST(result == ISC_R_SUCCESS);
- if (strcasecmp(cfg_obj_asstring(obj), "aes") == 0)
+ if (strcasecmp(cfg_obj_asstring(obj), "aes") == 0) {
#if defined(HAVE_OPENSSL_AES) || defined(HAVE_OPENSSL_EVP_AES)
server->sctx->cookiealg = ns_cookiealg_aes;
#else
INSIST(0);
#endif
- else if (strcasecmp(cfg_obj_asstring(obj), "sha1") == 0)
+ } else if (strcasecmp(cfg_obj_asstring(obj), "sha1") == 0) {
server->sctx->cookiealg = ns_cookiealg_sha1;
- else if (strcasecmp(cfg_obj_asstring(obj), "sha256") == 0)
+ } else if (strcasecmp(cfg_obj_asstring(obj), "sha256") == 0) {
server->sctx->cookiealg = ns_cookiealg_sha256;
- else
+ } else {
INSIST(0);
+ }
obj = NULL;
result = named_config_get(maps, "cookie-secret", &obj);
result = isc_hex_decodestring(str, &b);
if (result != ISC_R_SUCCESS &&
result != ISC_R_NOSPACE)
+ {
goto cleanup;
+ }
first = ISC_FALSE;
} else {
altsecret = isc_mem_get(server->sctx->mctx,
sizeof(altsecret->secret));
result = isc_hex_decodestring(str, &b);
if (result != ISC_R_SUCCESS &&
- result != ISC_R_NOSPACE) {
+ result != ISC_R_NOSPACE)
+ {
isc_mem_put(server->sctx->mctx,
altsecret,
sizeof(*altsecret));
sizeof(server->sctx->secret),
NULL,
0);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
+ }
}
/*
result = ISC_R_SUCCESS;
cleanup:
- if (logc != NULL)
+ if (logc != NULL) {
isc_logconfig_destroy(&logc);
+ }
- if (v4portset != NULL)
+ if (v4portset != NULL) {
isc_portset_destroy(named_g_mctx, &v4portset);
+ }
- if (v6portset != NULL)
+ if (v6portset != NULL) {
isc_portset_destroy(named_g_mctx, &v6portset);
+ }
if (conf_parser != NULL) {
- if (config != NULL)
+ if (config != NULL) {
cfg_obj_destroy(conf_parser, &config);
+ }
cfg_parser_destroy(&conf_parser);
}
if (bindkeys_parser != NULL) {
- if (bindkeys != NULL)
+ if (bindkeys != NULL) {
cfg_obj_destroy(bindkeys_parser, &bindkeys);
+ }
cfg_parser_destroy(&bindkeys_parser);
}
- if (view != NULL)
+ if (view != NULL) {
dns_view_detach(&view);
+ }
ISC_LIST_APPENDLIST(viewlist, builtin_viewlist, link);
ISC_LIST_UNLINK(viewlist, view, link);
if (result == ISC_R_SUCCESS &&
strcmp(view->name, "_bind") != 0)
+ {
+ dns_view_setviewrevert(view);
(void)dns_zt_apply(view->zonetable, ISC_FALSE,
removed, view);
+ }
dns_view_detach(&view);
}
* Adjust the listening interfaces in accordance with the source
* addresses specified in views and zones.
*/
- if (isc_net_probeipv6() == ISC_R_SUCCESS)
+ if (isc_net_probeipv6() == ISC_R_SUCCESS) {
adjust_interfaces(server, named_g_mctx);
+ }
/*
* Record the time of most recent configuration
*/
tresult = isc_time_now(&named_g_configtime);
- if (tresult != ISC_R_SUCCESS)
+ if (tresult != ISC_R_SUCCESS) {
named_main_earlyfatal("isc_time_now() failed: %s",
isc_result_totext(result));
+ }
/* Relinquish exclusive access to configuration data. */
- if (exclusive)
+ if (exclusive) {
isc_task_endexclusive(server->task);
+ }
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_DEBUG(1),
isc_uint32_t sigvalidityinterval;
isc_uint32_t sigresigninginterval;
dns_view_t *view;
+ dns_view_t *prev_view;
dns_checkmxfunc_t checkmx;
dns_checksrvfunc_t checksrv;
dns_checknsfunc_t checkns;
TIME_NOW(&now);
zone = isc_mem_get(mctx, sizeof(*zone));
- if (zone == NULL)
+ if (zone == NULL) {
return (ISC_R_NOMEMORY);
+ }
zone->mctx = NULL;
isc_mem_attach(mctx, &zone->mctx);
result = isc_mutex_init(&zone->lock);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto free_zone;
+ }
result = ZONEDB_INITLOCK(&zone->dblock);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto free_mutex;
+ }
/* XXX MPA check that all elements are initialised */
#ifdef DNS_ZONE_CHECKLOCK
zone->zmgr = NULL;
ISC_LINK_INIT(zone, link);
result = isc_refcount_init(&zone->erefs, 1); /* Implicit attach. */
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto free_dblock;
+ }
zone->irefs = 0;
dns_name_init(&zone->origin, NULL);
zone->strnamerd = NULL;
zone->sigvalidityinterval = 30 * 24 * 3600;
zone->sigresigninginterval = 7 * 24 * 3600;
zone->view = NULL;
+ zone->prev_view = NULL;
zone->checkmx = NULL;
zone->checksrv = NULL;
zone->checkns = NULL;
/* Must be after magic is set. */
result = dns_zone_setdbtype(zone, dbargc_default, dbargv_default);
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto free_erefs;
+ }
ISC_EVENT_INIT(&zone->ctlevent, sizeof(zone->ctlevent), 0, NULL,
DNS_EVENT_ZONECONTROL, zone_shutdown, zone, zone,
/*
* Managed objects. Order is important.
*/
- if (zone->request != NULL)
+ if (zone->request != NULL) {
dns_request_destroy(&zone->request); /* XXXMPA */
+ }
INSIST(zone->readio == NULL);
INSIST(zone->statelist == NULL);
INSIST(zone->writeio == NULL);
- if (zone->task != NULL)
+ if (zone->task != NULL) {
isc_task_detach(&zone->task);
- if (zone->loadtask != NULL)
+ }
+ if (zone->loadtask != NULL) {
isc_task_detach(&zone->loadtask);
- if (zone->view != NULL)
+ }
+ if (zone->view != NULL) {
dns_view_weakdetach(&zone->view);
+ }
+ if (zone->prev_view != NULL) {
+ dns_view_weakdetach(&zone->prev_view);
+ }
/* Unmanaged objects */
for (signing = ISC_LIST_HEAD(zone->signing);
isc_mem_free(zone->mctx, include->name);
isc_mem_put(zone->mctx, include, sizeof *include);
}
- if (zone->masterfile != NULL)
+ if (zone->masterfile != NULL) {
isc_mem_free(zone->mctx, zone->masterfile);
+ }
zone->masterfile = NULL;
- if (zone->keydirectory != NULL)
+ if (zone->keydirectory != NULL) {
isc_mem_free(zone->mctx, zone->keydirectory);
+ }
zone->keydirectory = NULL;
zone->journalsize = -1;
- if (zone->journal != NULL)
+ if (zone->journal != NULL) {
isc_mem_free(zone->mctx, zone->journal);
+ }
zone->journal = NULL;
- if (zone->stats != NULL)
+ if (zone->stats != NULL) {
isc_stats_detach(&zone->stats);
- if (zone->requeststats != NULL)
+ }
+ if (zone->requeststats != NULL) {
isc_stats_detach(&zone->requeststats);
- if (zone->rcvquerystats != NULL)
+ }
+ if (zone->rcvquerystats != NULL){
dns_stats_detach(&zone->rcvquerystats);
- if (zone->db != NULL)
+ }
+ if (zone->db != NULL) {
zone_detachdb(zone);
+ }
if (zone->rpzs != NULL) {
REQUIRE(zone->rpz_num < zone->rpzs->p.num_zones);
dns_rpz_detach_rpzs(&zone->rpzs);
dns_catz_catzs_detach(&zone->catzs);
}
zone_freedbargs(zone);
- RUNTIME_CHECK(dns_zone_setmasterswithkeys(zone, NULL, NULL, 0)
- == ISC_R_SUCCESS);
- RUNTIME_CHECK(dns_zone_setalsonotify(zone, NULL, 0)
- == ISC_R_SUCCESS);
+ RUNTIME_CHECK(dns_zone_setmasterswithkeys(zone, NULL,
+ NULL, 0) == ISC_R_SUCCESS);
+ RUNTIME_CHECK(dns_zone_setalsonotify(zone, NULL, 0) == ISC_R_SUCCESS);
zone->check_names = dns_severity_ignore;
- if (zone->update_acl != NULL)
+ if (zone->update_acl != NULL) {
dns_acl_detach(&zone->update_acl);
- if (zone->forward_acl != NULL)
+ }
+ if (zone->forward_acl != NULL) {
dns_acl_detach(&zone->forward_acl);
- if (zone->notify_acl != NULL)
+ }
+ if (zone->notify_acl != NULL) {
dns_acl_detach(&zone->notify_acl);
- if (zone->query_acl != NULL)
+ }
+ if (zone->query_acl != NULL) {
dns_acl_detach(&zone->query_acl);
- if (zone->queryon_acl != NULL)
+ }
+ if (zone->queryon_acl != NULL) {
dns_acl_detach(&zone->queryon_acl);
- if (zone->xfr_acl != NULL)
+ }
+ if (zone->xfr_acl != NULL) {
dns_acl_detach(&zone->xfr_acl);
- if (dns_name_dynamic(&zone->origin))
+ }
+ if (dns_name_dynamic(&zone->origin)) {
dns_name_free(&zone->origin, zone->mctx);
- if (zone->strnamerd != NULL)
+ }
+ if (zone->strnamerd != NULL) {
isc_mem_free(zone->mctx, zone->strnamerd);
- if (zone->strname != NULL)
+ }
+ if (zone->strname != NULL) {
isc_mem_free(zone->mctx, zone->strname);
- if (zone->strrdclass != NULL)
+ }
+ if (zone->strrdclass != NULL) {
isc_mem_free(zone->mctx, zone->strrdclass);
- if (zone->strviewname != NULL)
+ }
+ if (zone->strviewname != NULL) {
isc_mem_free(zone->mctx, zone->strviewname);
- if (zone->ssutable != NULL)
+ }
+ if (zone->ssutable != NULL) {
dns_ssutable_detach(&zone->ssutable);
+ }
/* last stuff */
ZONEDB_DESTROYLOCK(&zone->dblock);
/* Set up a new database argument list. */
argv = isc_mem_get(zone->mctx, dbargc * sizeof(*argv));
- if (argv == NULL)
+ if (argv == NULL) {
goto nomem;
- for (i = 0; i < dbargc; i++)
+ }
+ for (i = 0; i < dbargc; i++) {
argv[i] = NULL;
+ }
for (i = 0; i < dbargc; i++) {
argv[i] = isc_mem_strdup(zone->mctx, dbargv[i]);
if (argv[i] == NULL)
nomem:
if (argv != NULL) {
- for (i = 0; i < dbargc; i++)
- if (argv[i] != NULL)
+ for (i = 0; i < dbargc; i++) {
+ if (argv[i] != NULL) {
isc_mem_free(zone->mctx, argv[i]);
+ }
+ }
isc_mem_put(zone->mctx, argv, dbargc * sizeof(*argv));
}
result = ISC_R_NOMEMORY;
return (result);
}
-void
-dns_zone_setview(dns_zone_t *zone, dns_view_t *view) {
+static void
+dns_zone_setview_helper(dns_zone_t *zone, dns_view_t *view) {
char namebuf[1024];
- REQUIRE(DNS_ZONE_VALID(zone));
- LOCK_ZONE(zone);
+ if (zone->prev_view == NULL && zone->view != NULL) {
+ dns_view_weakattach(zone->view, &zone->prev_view);
+ }
+
INSIST(zone != zone->raw);
- if (zone->view != NULL)
+ if (zone->view != NULL) {
dns_view_weakdetach(&zone->view);
+ }
dns_view_weakattach(view, &zone->view);
- if (zone->strviewname != NULL)
+ if (zone->strviewname != NULL) {
isc_mem_free(zone->mctx, zone->strviewname);
- if (zone->strnamerd != NULL)
+ }
+ if (zone->strnamerd != NULL) {
isc_mem_free(zone->mctx, zone->strnamerd);
+ }
zone_namerd_tostr(zone, namebuf, sizeof namebuf);
zone->strnamerd = isc_mem_strdup(zone->mctx, namebuf);
zone_viewname_tostr(zone, namebuf, sizeof namebuf);
zone->strviewname = isc_mem_strdup(zone->mctx, namebuf);
- if (inline_secure(zone))
+ if (inline_secure(zone)) {
dns_zone_setview(zone->raw, view);
+ }
+}
+
+void
+dns_zone_setview(dns_zone_t *zone, dns_view_t *view) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+ LOCK_ZONE(zone);
+ dns_zone_setview_helper(zone, view);
UNLOCK_ZONE(zone);
}
return (zone->view);
}
+void
+dns_zone_setviewcommit(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ if (zone->prev_view != NULL)
+ dns_view_weakdetach(&zone->prev_view);
+ UNLOCK_ZONE(zone);
+}
+
+void
+dns_zone_setviewrevert(dns_zone_t *zone) {
+ REQUIRE(DNS_ZONE_VALID(zone));
+
+ LOCK_ZONE(zone);
+ if (zone->prev_view != NULL) {
+ dns_zone_setview_helper(zone, zone->prev_view);
+ dns_view_weakdetach(&zone->prev_view);
+ }
+ UNLOCK_ZONE(zone);
+}
isc_result_t
dns_zone_setorigin(dns_zone_t *zone, const dns_name_t *origin) {