diff options
Diffstat (limited to 'bin/named')
-rw-r--r-- | bin/named/config.c | 2 | ||||
-rw-r--r-- | bin/named/main.c | 34 | ||||
-rw-r--r-- | bin/named/server.c | 122 |
3 files changed, 140 insertions, 18 deletions
diff --git a/bin/named/config.c b/bin/named/config.c index 27827208..786dfb7f 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -144,6 +144,8 @@ options {\n\ lame-ttl 600;\n\ max-ncache-ttl 10800; /* 3 hours */\n\ max-cache-ttl 604800; /* 1 week */\n\ + min-ncache-ttl 0; /* 0 hours */\n\ + min-cache-ttl 0; /* 0 seconds */\n\ transfer-format many-answers;\n\ max-cache-size 0;\n\ check-names master fail;\n\ diff --git a/bin/named/main.c b/bin/named/main.c index 1d844e03..8e82ee97 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -45,6 +45,7 @@ #include <isccc/result.h> #include <dns/dispatch.h> +#include <dns/dynamic_db.h> #include <dns/name.h> #include <dns/result.h> #include <dns/view.h> @@ -661,14 +662,6 @@ create_managers(void) { ISC_LOG_INFO, "using up to %u sockets", socks); } - result = isc_entropy_create(ns_g_mctx, &ns_g_entropy); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_entropy_create() failed: %s", - isc_result_totext(result)); - return (ISC_R_UNEXPECTED); - } - result = isc_hash_create(ns_g_mctx, ns_g_entropy, DNS_NAME_MAXWIRE); if (result != ISC_R_SUCCESS) { UNEXPECTED_ERROR(__FILE__, __LINE__, @@ -684,10 +677,6 @@ static void destroy_managers(void) { ns_lwresd_shutdown(); - isc_entropy_detach(&ns_g_entropy); - if (ns_g_fallbackentropy != NULL) - isc_entropy_detach(&ns_g_fallbackentropy); - /* * isc_taskmgr_destroy() will block until all tasks have exited, */ @@ -788,6 +777,21 @@ setup(void) { } #endif + result = isc_entropy_create(ns_g_mctx, &ns_g_entropy); + if (result != ISC_R_SUCCESS) + ns_main_earlyfatal("isc_entropy_create() failed: %s", + isc_result_totext(result)); + + /* + * DST may load additional libraries, which must be done before + * chroot + */ + result = dst_lib_init2(ns_g_mctx, ns_g_entropy, + ns_g_engine, ISC_ENTROPY_GOODONLY); + if (result != ISC_R_SUCCESS) + ns_main_earlyfatal("dst_lib_init2() failed: %s", + isc_result_totext(result)); + #ifdef ISC_PLATFORM_USETHREADS /* * Check for the number of cpu's before ns_os_chroot(). @@ -954,6 +958,12 @@ cleanup(void) { ns_builtin_deinit(); + dst_lib_destroy(); + + isc_entropy_detach(&ns_g_entropy); + if (ns_g_fallbackentropy != NULL) + isc_entropy_detach(&ns_g_fallbackentropy); + /* * Add calls to unregister sdb drivers here. */ diff --git a/bin/named/server.c b/bin/named/server.c index 77a4e440..1777cb88 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -63,6 +63,7 @@ #include <dns/db.h> #include <dns/dispatch.h> #include <dns/dlz.h> +#include <dns/dynamic_db.h> #include <dns/dns64.h> #include <dns/forward.h> #include <dns/journal.h> @@ -1090,6 +1091,8 @@ configure_order(dns_order_t *order, const cfg_obj_t *ent) { mode = DNS_RDATASETATTR_FIXEDORDER; else if (!strcasecmp(str, "random")) mode = DNS_RDATASETATTR_RANDOMIZE; + else if (!strcasecmp(str, "random_1")) + mode = DNS_RDATASETATTR_RANDOMIZE|DNS_RDATASETATTR_SINGLE; else if (!strcasecmp(str, "cyclic")) mode = 0; else @@ -1249,6 +1252,72 @@ configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) { } static isc_result_t +configure_dynamic_db(const cfg_obj_t *dynamic_db, isc_mem_t *mctx, + const dns_dyndb_arguments_t *dyndb_args) +{ + isc_result_t result; + const cfg_obj_t *obj; + const cfg_obj_t *options; + const cfg_listelt_t *element; + const char *name; + const char *libname; + const char **argv = NULL; + unsigned int i; + unsigned int len; + + /* Get the name of the database. */ + obj = cfg_tuple_get(dynamic_db, "name"); + name = cfg_obj_asstring(obj); + + /* Get options. */ + options = cfg_tuple_get(dynamic_db, "options"); + + /* Get library name. */ + obj = NULL; + CHECK(cfg_map_get(options, "library", &obj)); + libname = cfg_obj_asstring(obj); + + /* Create a list of arguments. */ + obj = NULL; + result = cfg_map_get(options, "arg", &obj); + if (result == ISC_R_NOTFOUND) + len = 0; + else if (result == ISC_R_SUCCESS) + len = cfg_list_length(obj, isc_boolean_false); + else + goto cleanup; + + /* Account for the last terminating NULL. */ + len++; + + argv = isc_mem_allocate(mctx, len * sizeof(const char *)); + if (argv == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } + for (element = cfg_list_first(obj), i = 0; + element != NULL; + element = cfg_list_next(element), i++) + { + REQUIRE(i < len); + + obj = cfg_listelt_value(element); + argv[i] = cfg_obj_asstring(obj); + } + REQUIRE(i < len); + argv[i] = NULL; + + CHECK(dns_dynamic_db_load(libname, name, mctx, argv, dyndb_args)); + +cleanup: + if (argv != NULL) + isc_mem_free(mctx, argv); + + return result; +} + + +static isc_result_t disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) { isc_result_t result; const cfg_obj_t *algorithms; @@ -2071,6 +2140,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, const cfg_obj_t *dlz; unsigned int dlzargc; char **dlzargv; + const cfg_obj_t *dynamic_db_list; const cfg_obj_t *disabled; const cfg_obj_t *obj; const cfg_listelt_t *element; @@ -2541,6 +2611,18 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, if (view->maxncachettl > 7 * 24 * 3600) view->maxncachettl = 7 * 24 * 3600; + obj = NULL; + result = ns_config_get(maps, "min-cache-ttl", &obj); + INSIST(result == ISC_R_SUCCESS); + view->mincachettl = cfg_obj_asuint32(obj); + + obj = NULL; + result = ns_config_get(maps, "min-ncache-ttl", &obj); + INSIST(result == ISC_R_SUCCESS); + view->minncachettl = cfg_obj_asuint32(obj); + if (view->minncachettl > 7 * 24 * 3600) + view->minncachettl = 7 * 24 * 3600; + /* * Configure the view's cache. * @@ -3264,6 +3346,37 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, dns_view_setrootdelonly(view, ISC_FALSE); /* + * Configure dynamic databases. + */ + dynamic_db_list = NULL; + if (voptions != NULL) + (void)cfg_map_get(voptions, "dynamic-db", &dynamic_db_list); + else + (void)cfg_map_get(config, "dynamic-db", &dynamic_db_list); + element = cfg_list_first(dynamic_db_list); + if (element != NULL) { + dns_dyndb_arguments_t *args; + + args = dns_dyndb_arguments_create(mctx); + if (args == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } + dns_dyndb_set_view(args, view); + dns_dyndb_set_zonemgr(args, ns_g_server->zonemgr); + dns_dyndb_set_task(args, ns_g_server->task); + dns_dyndb_set_timermgr(args, ns_g_timermgr); + while (element != NULL) { + obj = cfg_listelt_value(element); + CHECK(configure_dynamic_db(obj, mctx, args)); + + element = cfg_list_next(element); + } + + dns_dyndb_arguments_destroy(mctx, args); + } + + /* * Setup automatic empty zones. If recursion is off then * they are disabled by default. */ @@ -4917,6 +5030,7 @@ load_configuration(const char *filename, ns_server_t *server, cfg_aclconfctx_detach(&ns_g_aclconfctx); CHECK(cfg_aclconfctx_create(ns_g_mctx, &ns_g_aclconfctx)); + dns_dynamic_db_cleanup(ISC_FALSE); /* * Parse the global default pseudo-config file. */ @@ -6046,6 +6160,8 @@ shutdown_server(isc_task_t *task, isc_event_t *event) { dns_view_detach(&view); } + dns_dynamic_db_cleanup(ISC_TRUE); + while ((nsc = ISC_LIST_HEAD(server->cachelist)) != NULL) { ISC_LIST_UNLINK(server->cachelist, nsc, link); dns_cache_detach(&nsc->cache); @@ -6126,10 +6242,6 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) { ISC_R_NOMEMORY : ISC_R_SUCCESS, "allocating reload event"); - CHECKFATAL(dst_lib_init2(ns_g_mctx, ns_g_entropy, - ns_g_engine, ISC_ENTROPY_GOODONLY), - "initializing DST"); - server->tkeyctx = NULL; CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, ns_g_entropy, &server->tkeyctx), @@ -6276,8 +6388,6 @@ ns_server_destroy(ns_server_t **serverp) { if (server->tkeyctx != NULL) dns_tkeyctx_destroy(&server->tkeyctx); - dst_lib_destroy(); - isc_event_free(&server->reload_event); INSIST(ISC_LIST_EMPTY(server->viewlist)); |