summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/bin/named/server.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/bin/named/server.c')
-rw-r--r--contrib/bind9/bin/named/server.c293
1 files changed, 152 insertions, 141 deletions
diff --git a/contrib/bind9/bin/named/server.c b/contrib/bind9/bin/named/server.c
index b9d30d0..f29321e 100644
--- a/contrib/bind9/bin/named/server.c
+++ b/contrib/bind9/bin/named/server.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: server.c,v 1.339.2.15.2.65 2005/07/27 02:53:15 marka Exp $ */
+/* $Id: server.c,v 1.339.2.15.2.70 2006/05/24 04:30:24 marka Exp $ */
#include <config.h>
@@ -167,25 +167,25 @@ static void
ns_server_reload(isc_task_t *task, isc_event_t *event);
static isc_result_t
-ns_listenelt_fromconfig(cfg_obj_t *listener, cfg_obj_t *config,
+ns_listenelt_fromconfig(const cfg_obj_t *listener, const cfg_obj_t *config,
ns_aclconfctx_t *actx,
isc_mem_t *mctx, ns_listenelt_t **target);
static isc_result_t
-ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
+ns_listenlist_fromconfig(const cfg_obj_t *listenlist, const cfg_obj_t *config,
ns_aclconfctx_t *actx,
isc_mem_t *mctx, ns_listenlist_t **target);
static isc_result_t
-configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
- cfg_obj_t *forwarders, cfg_obj_t *forwardtype);
+configure_forward(const cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
+ const cfg_obj_t *forwarders, const cfg_obj_t *forwardtype);
static isc_result_t
-configure_alternates(cfg_obj_t *config, dns_view_t *view,
- cfg_obj_t *alternates);
+configure_alternates(const cfg_obj_t *config, dns_view_t *view,
+ const cfg_obj_t *alternates);
static isc_result_t
-configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
- isc_mem_t *mctx, dns_view_t *view,
+configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
+ const cfg_obj_t *vconfig, isc_mem_t *mctx, dns_view_t *view,
ns_aclconfctx_t *aclconf);
static void
@@ -197,13 +197,13 @@ end_reserved_dispatches(ns_server_t *server, isc_boolean_t all);
* (for a global default).
*/
static isc_result_t
-configure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config,
+configure_view_acl(const cfg_obj_t *vconfig, const cfg_obj_t *config,
const char *aclname, ns_aclconfctx_t *actx,
isc_mem_t *mctx, dns_acl_t **aclp)
{
isc_result_t result;
- cfg_obj_t *maps[3];
- cfg_obj_t *aclobj = NULL;
+ const cfg_obj_t *maps[3];
+ const cfg_obj_t *aclobj = NULL;
int i = 0;
if (*aclp != NULL)
@@ -211,14 +211,14 @@ configure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config,
if (vconfig != NULL)
maps[i++] = cfg_tuple_get(vconfig, "options");
if (config != NULL) {
- cfg_obj_t *options = NULL;
+ const cfg_obj_t *options = NULL;
(void)cfg_map_get(config, "options", &options);
if (options != NULL)
maps[i++] = options;
}
maps[i] = NULL;
- result = ns_config_get(maps, aclname, &aclobj);
+ (void)ns_config_get(maps, aclname, &aclobj);
if (aclobj == NULL)
/*
* No value available. *aclp == NULL.
@@ -231,13 +231,13 @@ configure_view_acl(cfg_obj_t *vconfig, cfg_obj_t *config,
}
static isc_result_t
-configure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key,
+configure_view_dnsseckey(const cfg_obj_t *vconfig, const cfg_obj_t *key,
dns_keytable_t *keytable, isc_mem_t *mctx)
{
dns_rdataclass_t viewclass;
dns_rdata_dnskey_t keystruct;
isc_uint32_t flags, proto, alg;
- char *keystr, *keynamestr;
+ const char *keystr, *keynamestr;
unsigned char keydata[4096];
isc_buffer_t keydatabuf;
unsigned char rrdata[4096];
@@ -258,7 +258,7 @@ configure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key,
if (vconfig == NULL)
viewclass = dns_rdataclass_in;
else {
- cfg_obj_t *classobj = cfg_tuple_get(vconfig, "class");
+ const cfg_obj_t *classobj = cfg_tuple_get(vconfig, "class");
CHECK(ns_config_getclass(classobj, dns_rdataclass_in,
&viewclass));
}
@@ -334,15 +334,15 @@ configure_view_dnsseckey(cfg_obj_t *vconfig, cfg_obj_t *key,
* from 'vconfig' and 'config'. The variable to be configured is '*target'.
*/
static isc_result_t
-configure_view_dnsseckeys(cfg_obj_t *vconfig, cfg_obj_t *config,
+configure_view_dnsseckeys(const cfg_obj_t *vconfig, const cfg_obj_t *config,
isc_mem_t *mctx, dns_keytable_t **target)
{
isc_result_t result;
- cfg_obj_t *keys = NULL;
- cfg_obj_t *voptions = NULL;
- cfg_listelt_t *element, *element2;
- cfg_obj_t *keylist;
- cfg_obj_t *key;
+ const cfg_obj_t *keys = NULL;
+ const cfg_obj_t *voptions = NULL;
+ const cfg_listelt_t *element, *element2;
+ const cfg_obj_t *keylist;
+ const cfg_obj_t *key;
dns_keytable_t *keytable = NULL;
CHECK(dns_keytable_create(mctx, &keytable));
@@ -381,10 +381,10 @@ configure_view_dnsseckeys(cfg_obj_t *vconfig, cfg_obj_t *config,
}
static isc_result_t
-mustbesecure(cfg_obj_t *mbs, dns_resolver_t *resolver)
+mustbesecure(const cfg_obj_t *mbs, dns_resolver_t *resolver)
{
- cfg_listelt_t *element;
- cfg_obj_t *obj;
+ const cfg_listelt_t *element;
+ const cfg_obj_t *obj;
const char *str;
dns_fixedname_t fixed;
dns_name_t *name;
@@ -418,14 +418,14 @@ mustbesecure(cfg_obj_t *mbs, dns_resolver_t *resolver)
* Get a dispatch appropriate for the resolver of a given view.
*/
static isc_result_t
-get_view_querysource_dispatch(cfg_obj_t **maps,
+get_view_querysource_dispatch(const cfg_obj_t **maps,
int af, dns_dispatch_t **dispatchp)
{
isc_result_t result;
dns_dispatch_t *disp;
isc_sockaddr_t sa;
unsigned int attrs, attrmask;
- cfg_obj_t *obj = NULL;
+ const cfg_obj_t *obj = NULL;
/*
* Make compiler happy.
@@ -436,7 +436,6 @@ get_view_querysource_dispatch(cfg_obj_t **maps,
case AF_INET:
result = ns_config_get(maps, "query-source", &obj);
INSIST(result == ISC_R_SUCCESS);
-
break;
case AF_INET6:
result = ns_config_get(maps, "query-source-v6", &obj);
@@ -517,10 +516,10 @@ get_view_querysource_dispatch(cfg_obj_t **maps,
}
static isc_result_t
-configure_order(dns_order_t *order, cfg_obj_t *ent) {
+configure_order(dns_order_t *order, const cfg_obj_t *ent) {
dns_rdataclass_t rdclass;
dns_rdatatype_t rdtype;
- cfg_obj_t *obj;
+ const cfg_obj_t *obj;
dns_fixedname_t fixed;
unsigned int mode = 0;
const char *str;
@@ -567,7 +566,7 @@ configure_order(dns_order_t *order, cfg_obj_t *ent) {
/*
* "*" should match everything including the root (BIND 8 compat).
* As dns_name_matcheswildcard(".", "*.") returns FALSE add a
- * explict entry for "." when the name is "*".
+ * explicit entry for "." when the name is "*".
*/
if (addroot) {
result = dns_order_add(order, dns_rootname,
@@ -581,12 +580,12 @@ configure_order(dns_order_t *order, cfg_obj_t *ent) {
}
static isc_result_t
-configure_peer(cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
- isc_sockaddr_t *sa;
+configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
+ const isc_sockaddr_t *sa;
isc_netaddr_t na;
dns_peer_t *peer;
- cfg_obj_t *obj;
- char *str;
+ const cfg_obj_t *obj;
+ const char *str;
isc_result_t result;
sa = cfg_obj_assockaddr(cfg_map_getname(cpeer));
@@ -664,10 +663,10 @@ configure_peer(cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
}
static isc_result_t
-disable_algorithms(cfg_obj_t *disabled, dns_resolver_t *resolver) {
+disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) {
isc_result_t result;
- cfg_obj_t *algorithms;
- cfg_listelt_t *element;
+ const cfg_obj_t *algorithms;
+ const cfg_listelt_t *element;
const char *str;
dns_fixedname_t fixed;
dns_name_t *name;
@@ -688,7 +687,7 @@ disable_algorithms(cfg_obj_t *disabled, dns_resolver_t *resolver) {
isc_textregion_t r;
dns_secalg_t alg;
- r.base = cfg_obj_asstring(cfg_listelt_value(element));
+ DE_CONST(cfg_obj_asstring(cfg_listelt_value(element)), r.base);
r.length = strlen(r.base);
result = dns_secalg_fromtext(&alg, &r);
@@ -717,21 +716,21 @@ disable_algorithms(cfg_obj_t *disabled, dns_resolver_t *resolver) {
* global defaults in 'config' used exclusively.
*/
static isc_result_t
-configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
- isc_mem_t *mctx, ns_aclconfctx_t *actx,
+configure_view(dns_view_t *view, const cfg_obj_t *config,
+ const cfg_obj_t *vconfig, isc_mem_t *mctx, ns_aclconfctx_t *actx,
isc_boolean_t need_hints)
{
- cfg_obj_t *maps[4];
- cfg_obj_t *cfgmaps[3];
- cfg_obj_t *options = NULL;
- cfg_obj_t *voptions = NULL;
- cfg_obj_t *forwardtype;
- cfg_obj_t *forwarders;
- cfg_obj_t *alternates;
- cfg_obj_t *zonelist;
- cfg_obj_t *disabled;
- cfg_obj_t *obj;
- cfg_listelt_t *element;
+ const cfg_obj_t *maps[4];
+ const cfg_obj_t *cfgmaps[3];
+ const cfg_obj_t *options = NULL;
+ const cfg_obj_t *voptions = NULL;
+ const cfg_obj_t *forwardtype;
+ const cfg_obj_t *forwarders;
+ const cfg_obj_t *alternates;
+ const cfg_obj_t *zonelist;
+ const cfg_obj_t *disabled;
+ const cfg_obj_t *obj;
+ const cfg_listelt_t *element;
in_port_t port;
dns_cache_t *cache = NULL;
isc_result_t result;
@@ -792,7 +791,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *zconfig = cfg_listelt_value(element);
+ const cfg_obj_t *zconfig = cfg_listelt_value(element);
CHECK(configure_zone(config, zconfig, vconfig, mctx, view,
actx));
}
@@ -1018,8 +1017,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
* Configure the view's peer list.
*/
{
- cfg_obj_t *peers = NULL;
- cfg_listelt_t *element;
+ const cfg_obj_t *peers = NULL;
+ const cfg_listelt_t *element;
dns_peerlist_t *newpeers = NULL;
(void)ns_config_get(cfgmaps, "server", &peers);
@@ -1028,7 +1027,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *cpeer = cfg_listelt_value(element);
+ const cfg_obj_t *cpeer = cfg_listelt_value(element);
dns_peer_t *peer;
CHECK(configure_peer(cpeer, mctx, &peer));
@@ -1043,8 +1042,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
* Configure the views rrset-order.
*/
{
- cfg_obj_t *rrsetorder = NULL;
- cfg_listelt_t *element;
+ const cfg_obj_t *rrsetorder = NULL;
+ const cfg_listelt_t *element;
(void)ns_config_get(maps, "rrset-order", &rrsetorder);
CHECK(dns_order_create(mctx, &order));
@@ -1052,7 +1051,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *ent = cfg_listelt_value(element);
+ const cfg_obj_t *ent = cfg_listelt_value(element);
CHECK(configure_order(order, ent));
}
@@ -1078,7 +1077,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
* Configure the "match-recursive-only" option.
*/
obj = NULL;
- (void) ns_config_get(maps, "match-recursive-only", &obj);
+ (void)ns_config_get(maps, "match-recursive-only", &obj);
if (obj != NULL && cfg_obj_asboolean(obj))
view->matchrecursiveonly = ISC_TRUE;
else
@@ -1275,8 +1274,8 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
dns_fixedname_t fixed;
dns_name_t *name;
isc_buffer_t b;
- char *str;
- cfg_obj_t *exclude;
+ const char *str;
+ const cfg_obj_t *exclude;
dns_fixedname_init(&fixed);
name = dns_fixedname_name(&fixed);
@@ -1330,12 +1329,12 @@ configure_hints(dns_view_t *view, const char *filename) {
}
static isc_result_t
-configure_alternates(cfg_obj_t *config, dns_view_t *view,
- cfg_obj_t *alternates)
+configure_alternates(const cfg_obj_t *config, dns_view_t *view,
+ const cfg_obj_t *alternates)
{
- cfg_obj_t *portobj;
- cfg_obj_t *addresses;
- cfg_listelt_t *element;
+ const cfg_obj_t *portobj;
+ const cfg_obj_t *addresses;
+ const cfg_listelt_t *element;
isc_result_t result = ISC_R_SUCCESS;
in_port_t port;
@@ -1368,14 +1367,14 @@ configure_alternates(cfg_obj_t *config, dns_view_t *view,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *alternate = cfg_listelt_value(element);
+ const cfg_obj_t *alternate = cfg_listelt_value(element);
isc_sockaddr_t sa;
if (!cfg_obj_issockaddr(alternate)) {
dns_fixedname_t fixed;
dns_name_t *name;
- char *str = cfg_obj_asstring(cfg_tuple_get(alternate,
- "name"));
+ const char *str = cfg_obj_asstring(cfg_tuple_get(
+ alternate, "name"));
isc_buffer_t buffer;
in_port_t myport = port;
@@ -1415,12 +1414,12 @@ configure_alternates(cfg_obj_t *config, dns_view_t *view,
}
static isc_result_t
-configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
- cfg_obj_t *forwarders, cfg_obj_t *forwardtype)
+configure_forward(const cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
+ const cfg_obj_t *forwarders, const cfg_obj_t *forwardtype)
{
- cfg_obj_t *portobj;
- cfg_obj_t *faddresses;
- cfg_listelt_t *element;
+ const cfg_obj_t *portobj;
+ const cfg_obj_t *faddresses;
+ const cfg_listelt_t *element;
dns_fwdpolicy_t fwdpolicy = dns_fwdpolicy_none;
isc_sockaddrlist_t addresses;
isc_sockaddr_t *sa;
@@ -1458,7 +1457,7 @@ configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *forwarder = cfg_listelt_value(element);
+ const cfg_obj_t *forwarder = cfg_listelt_value(element);
sa = isc_mem_get(view->mctx, sizeof(isc_sockaddr_t));
if (sa == NULL) {
result = ISC_R_NOMEMORY;
@@ -1481,7 +1480,7 @@ configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
if (forwardtype == NULL)
fwdpolicy = dns_fwdpolicy_first;
else {
- char *forwardstr = cfg_obj_asstring(forwardtype);
+ const char *forwardstr = cfg_obj_asstring(forwardtype);
if (strcasecmp(forwardstr, "first") == 0)
fwdpolicy = dns_fwdpolicy_first;
else if (strcasecmp(forwardstr, "only") == 0)
@@ -1523,14 +1522,16 @@ configure_forward(cfg_obj_t *config, dns_view_t *view, dns_name_t *origin,
* The view created is attached to '*viewp'.
*/
static isc_result_t
-create_view(cfg_obj_t *vconfig, dns_viewlist_t *viewlist, dns_view_t **viewp) {
+create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist,
+ dns_view_t **viewp)
+{
isc_result_t result;
const char *viewname;
dns_rdataclass_t viewclass;
dns_view_t *view = NULL;
if (vconfig != NULL) {
- cfg_obj_t *classobj = NULL;
+ const cfg_obj_t *classobj = NULL;
viewname = cfg_obj_asstring(cfg_tuple_get(vconfig, "name"));
classobj = cfg_tuple_get(vconfig, "class");
@@ -1560,19 +1561,19 @@ create_view(cfg_obj_t *vconfig, dns_viewlist_t *viewlist, dns_view_t **viewp) {
* Configure or reconfigure a zone.
*/
static isc_result_t
-configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
- isc_mem_t *mctx, dns_view_t *view,
+configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
+ const cfg_obj_t *vconfig, isc_mem_t *mctx, dns_view_t *view,
ns_aclconfctx_t *aclconf)
{
dns_view_t *pview = NULL; /* Production view */
dns_zone_t *zone = NULL; /* New or reused zone */
dns_zone_t *dupzone = NULL;
- cfg_obj_t *options = NULL;
- cfg_obj_t *zoptions = NULL;
- cfg_obj_t *typeobj = NULL;
- cfg_obj_t *forwarders = NULL;
- cfg_obj_t *forwardtype = NULL;
- cfg_obj_t *only = NULL;
+ const cfg_obj_t *options = NULL;
+ const cfg_obj_t *zoptions = NULL;
+ const cfg_obj_t *typeobj = NULL;
+ const cfg_obj_t *forwarders = NULL;
+ const cfg_obj_t *forwardtype = NULL;
+ const cfg_obj_t *only = NULL;
isc_result_t result;
isc_result_t tresult;
isc_buffer_t buffer;
@@ -1629,7 +1630,7 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
* configure it and return.
*/
if (strcasecmp(ztypestr, "hint") == 0) {
- cfg_obj_t *fileobj = NULL;
+ const cfg_obj_t *fileobj = NULL;
if (cfg_map_get(zoptions, "file", &fileobj) != ISC_R_SUCCESS) {
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_ERROR,
@@ -1639,7 +1640,7 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
goto cleanup;
}
if (dns_name_equal(origin, dns_rootname)) {
- char *hintsfile = cfg_obj_asstring(fileobj);
+ const char *hintsfile = cfg_obj_asstring(fileobj);
result = configure_hints(view, hintsfile);
if (result != ISC_R_SUCCESS) {
@@ -1795,9 +1796,10 @@ configure_zone(cfg_obj_t *config, cfg_obj_t *zconfig, cfg_obj_t *vconfig,
* Configure a single server quota.
*/
static void
-configure_server_quota(cfg_obj_t **maps, const char *name, isc_quota_t *quota)
+configure_server_quota(const cfg_obj_t **maps, const char *name,
+ isc_quota_t *quota)
{
- cfg_obj_t *obj = NULL;
+ const cfg_obj_t *obj = NULL;
isc_result_t result;
result = ns_config_get(maps, name, &obj);
@@ -1810,9 +1812,9 @@ configure_server_quota(cfg_obj_t **maps, const char *name, isc_quota_t *quota)
* parsed. This can be extended to support other options if necessary.
*/
static isc_result_t
-directory_callback(const char *clausename, cfg_obj_t *obj, void *arg) {
+directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
isc_result_t result;
- char *directory;
+ const char *directory;
REQUIRE(strcasecmp("directory", clausename) == 0);
@@ -1891,8 +1893,7 @@ add_listenelt(isc_mem_t *mctx, ns_listenlist_t *list, isc_sockaddr_t *addr) {
clean:
INSIST(lelt == NULL);
- if (src_acl != NULL)
- dns_acl_detach(&src_acl);
+ dns_acl_detach(&src_acl);
return (result);
}
@@ -2049,7 +2050,7 @@ setstring(ns_server_t *server, char **field, const char *value) {
* or NULL if whether 'obj' is a string or void value, respectively.
*/
static isc_result_t
-setoptstring(ns_server_t *server, char **field, cfg_obj_t *obj) {
+setoptstring(ns_server_t *server, char **field, const cfg_obj_t *obj) {
if (cfg_obj_isvoid(obj))
return (setstring(server, field, NULL));
else
@@ -2057,11 +2058,12 @@ setoptstring(ns_server_t *server, char **field, cfg_obj_t *obj) {
}
static void
-set_limit(cfg_obj_t **maps, const char *configname, const char *description,
- isc_resource_t resourceid, isc_resourcevalue_t defaultvalue)
+set_limit(const cfg_obj_t **maps, const char *configname,
+ const char *description, isc_resource_t resourceid,
+ isc_resourcevalue_t defaultvalue)
{
- cfg_obj_t *obj = NULL;
- char *resource;
+ const cfg_obj_t *obj = NULL;
+ const char *resource;
isc_resourcevalue_t value;
isc_result_t result;
@@ -2092,7 +2094,7 @@ set_limit(cfg_obj_t **maps, const char *configname, const char *description,
ns_g_init ## resource)
static void
-set_limits(cfg_obj_t **maps) {
+set_limits(const cfg_obj_t **maps) {
SETLIMIT("stacksize", stacksize, "stack size");
SETLIMIT("datasize", datasize, "data size");
SETLIMIT("coresize", coresize, "core size");
@@ -2101,15 +2103,15 @@ set_limits(cfg_obj_t **maps) {
static isc_result_t
portlist_fromconf(dns_portlist_t *portlist, unsigned int family,
- cfg_obj_t *ports)
+ const cfg_obj_t *ports)
{
- cfg_listelt_t *element;
+ const cfg_listelt_t *element;
isc_result_t result = ISC_R_SUCCESS;
for (element = cfg_list_first(ports);
element != NULL;
element = cfg_list_next(element)) {
- cfg_obj_t *obj = cfg_listelt_value(element);
+ const cfg_obj_t *obj = cfg_listelt_value(element);
in_port_t port = (in_port_t)cfg_obj_asuint32(obj);
result = dns_portlist_add(portlist, family, port);
@@ -2126,13 +2128,13 @@ load_configuration(const char *filename, ns_server_t *server,
isc_result_t result;
cfg_parser_t *parser = NULL;
cfg_obj_t *config;
- cfg_obj_t *options;
- cfg_obj_t *views;
- cfg_obj_t *obj;
- cfg_obj_t *v4ports, *v6ports;
- cfg_obj_t *maps[3];
- cfg_obj_t *builtin_views;
- cfg_listelt_t *element;
+ const cfg_obj_t *options;
+ const cfg_obj_t *views;
+ const cfg_obj_t *obj;
+ const cfg_obj_t *v4ports, *v6ports;
+ const cfg_obj_t *maps[3];
+ const cfg_obj_t *builtin_views;
+ const cfg_listelt_t *element;
dns_view_t *view = NULL;
dns_view_t *view_next;
dns_viewlist_t viewlist;
@@ -2319,7 +2321,7 @@ load_configuration(const char *filename, ns_server_t *server,
* statement.
*/
{
- cfg_obj_t *clistenon = NULL;
+ const cfg_obj_t *clistenon = NULL;
ns_listenlist_t *listenon = NULL;
clistenon = NULL;
@@ -2353,7 +2355,7 @@ load_configuration(const char *filename, ns_server_t *server,
* Ditto for IPv6.
*/
{
- cfg_obj_t *clistenon = NULL;
+ const cfg_obj_t *clistenon = NULL;
ns_listenlist_t *listenon = NULL;
if (options != NULL)
@@ -2438,7 +2440,7 @@ load_configuration(const char *filename, ns_server_t *server,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *vconfig = cfg_listelt_value(element);
+ const cfg_obj_t *vconfig = cfg_listelt_value(element);
view = NULL;
CHECK(create_view(vconfig, &viewlist, &view));
@@ -2478,7 +2480,7 @@ load_configuration(const char *filename, ns_server_t *server,
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *vconfig = cfg_listelt_value(element);
+ const cfg_obj_t *vconfig = cfg_listelt_value(element);
CHECK(create_view(vconfig, &viewlist, &view));
CHECK(configure_view(view, config, vconfig, ns_g_mctx,
&aclconfctx, ISC_FALSE));
@@ -2582,7 +2584,7 @@ load_configuration(const char *filename, ns_server_t *server,
"ignoring config file logging "
"statement due to -g option");
} else {
- cfg_obj_t *logobj = NULL;
+ const cfg_obj_t *logobj = NULL;
isc_logconfig_t *logc = NULL;
CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
@@ -2621,8 +2623,8 @@ load_configuration(const char *filename, ns_server_t *server,
* compatibility.
*/
if (first_time) {
- cfg_obj_t *logobj = NULL;
- cfg_obj_t *categories = NULL;
+ const cfg_obj_t *logobj = NULL;
+ const cfg_obj_t *categories = NULL;
obj = NULL;
if (ns_config_get(maps, "querylog", &obj) == ISC_R_SUCCESS) {
@@ -2634,13 +2636,13 @@ load_configuration(const char *filename, ns_server_t *server,
(void)cfg_map_get(logobj, "category",
&categories);
if (categories != NULL) {
- cfg_listelt_t *element;
+ const cfg_listelt_t *element;
for (element = cfg_list_first(categories);
element != NULL;
element = cfg_list_next(element))
{
- cfg_obj_t *catobj;
- char *str;
+ const cfg_obj_t *catobj;
+ const char *str;
obj = cfg_listelt_value(element);
catobj = cfg_tuple_get(obj, "name");
@@ -3133,7 +3135,7 @@ end_reserved_dispatches(ns_server_t *server, isc_boolean_t all) {
}
void
-ns_add_reserved_dispatch(ns_server_t *server, isc_sockaddr_t *addr) {
+ns_add_reserved_dispatch(ns_server_t *server, const isc_sockaddr_t *addr) {
ns_dispatch_t *dispatch;
in_port_t port;
char addrbuf[ISC_SOCKADDR_FORMATSIZE];
@@ -3458,20 +3460,29 @@ isc_result_t
ns_server_refreshcommand(ns_server_t *server, char *args, isc_buffer_t *text) {
isc_result_t result;
dns_zone_t *zone = NULL;
- const unsigned char msg[] = "zone refresh queued";
+ const unsigned char msg1[] = "zone refresh queued";
+ const unsigned char msg2[] = "not a slave or stub zone";
+ dns_zonetype_t type;
result = zone_from_args(server, args, &zone);
if (result != ISC_R_SUCCESS)
return (result);
if (zone == NULL)
return (ISC_R_UNEXPECTEDEND);
-
- dns_zone_refresh(zone);
- dns_zone_detach(&zone);
- if (sizeof(msg) <= isc_buffer_availablelength(text))
- isc_buffer_putmem(text, msg, sizeof(msg));
- return (ISC_R_SUCCESS);
+ type = dns_zone_gettype(zone);
+ if (type == dns_zone_slave || type == dns_zone_stub) {
+ dns_zone_refresh(zone);
+ dns_zone_detach(&zone);
+ if (sizeof(msg1) <= isc_buffer_availablelength(text))
+ isc_buffer_putmem(text, msg1, sizeof(msg1));
+ return (ISC_R_SUCCESS);
+ }
+
+ dns_zone_detach(&zone);
+ if (sizeof(msg2) <= isc_buffer_availablelength(text))
+ isc_buffer_putmem(text, msg2, sizeof(msg2));
+ return (ISC_R_FAILURE);
}
isc_result_t
@@ -3486,12 +3497,12 @@ ns_server_togglequerylog(ns_server_t *server) {
}
static isc_result_t
-ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
+ns_listenlist_fromconfig(const cfg_obj_t *listenlist, const cfg_obj_t *config,
ns_aclconfctx_t *actx,
isc_mem_t *mctx, ns_listenlist_t **target)
{
isc_result_t result;
- cfg_listelt_t *element;
+ const cfg_listelt_t *element;
ns_listenlist_t *dlist = NULL;
REQUIRE(target != NULL && *target == NULL);
@@ -3505,7 +3516,7 @@ ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
element = cfg_list_next(element))
{
ns_listenelt_t *delt = NULL;
- cfg_obj_t *listener = cfg_listelt_value(element);
+ const cfg_obj_t *listener = cfg_listelt_value(element);
result = ns_listenelt_fromconfig(listener, config, actx,
mctx, &delt);
if (result != ISC_R_SUCCESS)
@@ -3525,12 +3536,12 @@ ns_listenlist_fromconfig(cfg_obj_t *listenlist, cfg_obj_t *config,
* data structure.
*/
static isc_result_t
-ns_listenelt_fromconfig(cfg_obj_t *listener, cfg_obj_t *config,
+ns_listenelt_fromconfig(const cfg_obj_t *listener, const cfg_obj_t *config,
ns_aclconfctx_t *actx,
isc_mem_t *mctx, ns_listenelt_t **target)
{
isc_result_t result;
- cfg_obj_t *portobj;
+ const cfg_obj_t *portobj;
in_port_t port;
ns_listenelt_t *delt = NULL;
REQUIRE(target != NULL && *target == NULL);
@@ -3823,6 +3834,11 @@ ns_server_dumpdb(ns_server_t *server, char *args) {
char *ptr;
const char *sep;
+ /* Skip the command name. */
+ ptr = next_token(&args, " \t");
+ if (ptr == NULL)
+ return (ISC_R_UNEXPECTEDEND);
+
dctx = isc_mem_get(server->mctx, sizeof(*dctx));
if (dctx == NULL)
return (ISC_R_NOMEMORY);
@@ -3845,11 +3861,6 @@ ns_server_dumpdb(ns_server_t *server, char *args) {
CHECKMF(isc_stdio_open(server->dumpfile, "w", &dctx->fp),
"could not open dump file", server->dumpfile);
- /* Skip the command name. */
- ptr = next_token(&args, " \t");
- if (ptr == NULL)
- return (ISC_R_UNEXPECTEDEND);
-
sep = (args == NULL) ? "" : ": ";
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL,
NS_LOGMODULE_SERVER, ISC_LOG_INFO,
OpenPOWER on IntegriCloud