|
Tomas Hozza |
4fa997 |
diff --git a/bin/named/main.c b/bin/named/main.c
|
|
Tomas Hozza |
a3771c |
index d951ef5..306295f 100644
|
|
Tomas Hozza |
4fa997 |
--- a/bin/named/main.c
|
|
Tomas Hozza |
4fa997 |
+++ b/bin/named/main.c
|
|
Tomas Hozza |
4fa997 |
@@ -43,6 +43,7 @@
|
|
Martin Nagy |
b1c08c |
#include <isccc/result.h>
|
|
Martin Nagy |
b1c08c |
|
|
Martin Nagy |
b1c08c |
#include <dns/dispatch.h>
|
|
Martin Nagy |
b1c08c |
+#include <dns/dynamic_db.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/name.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/result.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/view.h>
|
|
Tomas Hozza |
4fa997 |
diff --git a/bin/named/server.c b/bin/named/server.c
|
|
Tomas Hozza |
a3771c |
index 19e064f..960d4bb 100644
|
|
Tomas Hozza |
4fa997 |
--- a/bin/named/server.c
|
|
Tomas Hozza |
4fa997 |
+++ b/bin/named/server.c
|
|
Tomas Hozza |
a3771c |
@@ -68,6 +68,7 @@
|
|
Adam Tkac |
86c080 |
#include <dns/db.h>
|
|
Adam Tkac |
86c080 |
#include <dns/dispatch.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/dlz.h>
|
|
Martin Nagy |
b1c08c |
+#include <dns/dynamic_db.h>
|
|
Adam Tkac |
5bc2b4 |
#include <dns/dns64.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/forward.h>
|
|
Martin Nagy |
b1c08c |
#include <dns/journal.h>
|
|
Tomas Hozza |
a3771c |
@@ -1308,6 +1309,70 @@ configure_peer(const cfg_obj_t *cpeer, isc_mem_t *mctx, dns_peer_t **peerp) {
|
|
Tomas Hozza |
4fa997 |
return (result);
|
|
Martin Nagy |
b1c08c |
}
|
|
Martin Nagy |
b1c08c |
|
|
Martin Nagy |
b1c08c |
+configure_dynamic_db(const cfg_obj_t *dynamic_db, isc_mem_t *mctx,
|
|
Martin Nagy |
32aa83 |
+ const dns_dyndb_arguments_t *dyndb_args)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ isc_result_t result;
|
|
Martin Nagy |
b1c08c |
+ const cfg_obj_t *obj;
|
|
Martin Nagy |
b1c08c |
+ const cfg_obj_t *options;
|
|
Martin Nagy |
b1c08c |
+ const cfg_listelt_t *element;
|
|
Martin Nagy |
b1c08c |
+ const char *name;
|
|
Martin Nagy |
b1c08c |
+ const char *libname;
|
|
Martin Nagy |
b1c08c |
+ const char **argv = NULL;
|
|
Martin Nagy |
b1c08c |
+ unsigned int i;
|
|
Martin Nagy |
b1c08c |
+ unsigned int len;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ /* Get the name of the database. */
|
|
Martin Nagy |
b1c08c |
+ obj = cfg_tuple_get(dynamic_db, "name");
|
|
Martin Nagy |
b1c08c |
+ name = cfg_obj_asstring(obj);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ /* Get options. */
|
|
Martin Nagy |
b1c08c |
+ options = cfg_tuple_get(dynamic_db, "options");
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ /* Get library name. */
|
|
Martin Nagy |
b1c08c |
+ obj = NULL;
|
|
Martin Nagy |
b1c08c |
+ CHECK(cfg_map_get(options, "library", &obj));
|
|
Martin Nagy |
b1c08c |
+ libname = cfg_obj_asstring(obj);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ /* Create a list of arguments. */
|
|
Martin Nagy |
b1c08c |
+ obj = NULL;
|
|
Martin Nagy |
205f42 |
+ result = cfg_map_get(options, "arg", &obj);
|
|
Martin Nagy |
205f42 |
+ if (result == ISC_R_NOTFOUND)
|
|
Martin Nagy |
205f42 |
+ len = 0;
|
|
Martin Nagy |
205f42 |
+ else if (result == ISC_R_SUCCESS)
|
|
Martin Nagy |
205f42 |
+ len = cfg_list_length(obj, isc_boolean_false);
|
|
Martin Nagy |
205f42 |
+ else
|
|
Martin Nagy |
205f42 |
+ goto cleanup;
|
|
Martin Nagy |
205f42 |
+
|
|
Martin Nagy |
205f42 |
+ /* Account for the last terminating NULL. */
|
|
Martin Nagy |
205f42 |
+ len++;
|
|
Martin Nagy |
205f42 |
+
|
|
Martin Nagy |
205f42 |
+ argv = isc_mem_allocate(mctx, len * sizeof(const char *));
|
|
Martin Nagy |
205f42 |
+ if (argv == NULL) {
|
|
Martin Nagy |
205f42 |
+ result = ISC_R_NOMEMORY;
|
|
Martin Nagy |
205f42 |
+ goto cleanup;
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+ for (element = cfg_list_first(obj), i = 0;
|
|
Martin Nagy |
b1c08c |
+ element != NULL;
|
|
Martin Nagy |
b1c08c |
+ element = cfg_list_next(element), i++)
|
|
Martin Nagy |
b1c08c |
+ {
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(i < len);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ obj = cfg_listelt_value(element);
|
|
Martin Nagy |
b1c08c |
+ argv[i] = cfg_obj_asstring(obj);
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(i < len);
|
|
Martin Nagy |
b1c08c |
+ argv[i] = NULL;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
32aa83 |
+ CHECK(dns_dynamic_db_load(libname, name, mctx, argv, dyndb_args));
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+cleanup:
|
|
Martin Nagy |
b1c08c |
+ if (argv != NULL)
|
|
Martin Nagy |
b1c08c |
+ isc_mem_free(mctx, argv);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return result;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Tomas Hozza |
4fa997 |
static isc_result_t
|
|
Martin Nagy |
b1c08c |
disable_algorithms(const cfg_obj_t *disabled, dns_resolver_t *resolver) {
|
|
Martin Nagy |
b1c08c |
isc_result_t result;
|
|
Tomas Hozza |
a3771c |
@@ -2344,6 +2409,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
|
|
Adam Tkac |
86c080 |
const cfg_obj_t *dlz;
|
|
Martin Nagy |
b1c08c |
unsigned int dlzargc;
|
|
Martin Nagy |
b1c08c |
char **dlzargv;
|
|
Martin Nagy |
b1c08c |
+ const cfg_obj_t *dynamic_db_list;
|
|
Martin Nagy |
b1c08c |
const cfg_obj_t *disabled;
|
|
Martin Nagy |
b1c08c |
const cfg_obj_t *obj;
|
|
Tomas Hozza |
a3771c |
#ifdef ENABLE_FETCHLIMIT
|
|
Tomas Hozza |
a3771c |
@@ -3698,6 +3764,37 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
|
|
Adam Tkac |
6cd938 |
dns_view_setrootdelonly(view, ISC_FALSE);
|
|
Adam Tkac |
6cd938 |
|
|
Adam Tkac |
6cd938 |
/*
|
|
Martin Nagy |
b1c08c |
+ * Configure dynamic databases.
|
|
Martin Nagy |
b1c08c |
+ */
|
|
Martin Nagy |
b1c08c |
+ dynamic_db_list = NULL;
|
|
Martin Nagy |
b1c08c |
+ if (voptions != NULL)
|
|
Martin Nagy |
b1c08c |
+ (void)cfg_map_get(voptions, "dynamic-db", &dynamic_db_list);
|
|
Martin Nagy |
b1c08c |
+ else
|
|
Martin Nagy |
b1c08c |
+ (void)cfg_map_get(config, "dynamic-db", &dynamic_db_list);
|
|
Martin Nagy |
32aa83 |
+ element = cfg_list_first(dynamic_db_list);
|
|
Martin Nagy |
32aa83 |
+ if (element != NULL) {
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_arguments_t *args;
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ args = dns_dyndb_arguments_create(mctx);
|
|
Martin Nagy |
32aa83 |
+ if (args == NULL) {
|
|
Martin Nagy |
32aa83 |
+ result = ISC_R_NOMEMORY;
|
|
Martin Nagy |
32aa83 |
+ goto cleanup;
|
|
Martin Nagy |
32aa83 |
+ }
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_view(args, view);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_zonemgr(args, ns_g_server->zonemgr);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_task(args, ns_g_server->task);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_timermgr(args, ns_g_timermgr);
|
|
Martin Nagy |
32aa83 |
+ while (element != NULL) {
|
|
Martin Nagy |
32aa83 |
+ obj = cfg_listelt_value(element);
|
|
Martin Nagy |
32aa83 |
+ CHECK(configure_dynamic_db(obj, mctx, args));
|
|
Adam Tkac |
86c080 |
+
|
|
Martin Nagy |
32aa83 |
+ element = cfg_list_next(element);
|
|
Martin Nagy |
32aa83 |
+ }
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_arguments_destroy(mctx, args);
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+
|
|
Adam Tkac |
6cd938 |
+ /*
|
|
Adam Tkac |
6cd938 |
* Setup automatic empty zones. If recursion is off then
|
|
Adam Tkac |
6cd938 |
* they are disabled by default.
|
|
Adam Tkac |
6cd938 |
*/
|
|
Tomas Hozza |
a3771c |
@@ -5443,6 +5540,7 @@ load_configuration(const char *filename, ns_server_t *server,
|
|
Adam Tkac |
86c080 |
cfg_aclconfctx_detach(&ns_g_aclconfctx);
|
|
Adam Tkac |
86c080 |
CHECK(cfg_aclconfctx_create(ns_g_mctx, &ns_g_aclconfctx));
|
|
Martin Nagy |
01aab7 |
|
|
Martin Nagy |
01aab7 |
+ dns_dynamic_db_cleanup(ISC_FALSE);
|
|
Martin Nagy |
01aab7 |
/*
|
|
Martin Nagy |
01aab7 |
* Parse the global default pseudo-config file.
|
|
Martin Nagy |
01aab7 |
*/
|
|
Tomas Hozza |
a3771c |
@@ -6671,6 +6769,8 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
|
|
Adam Tkac |
6cd938 |
dns_view_detach(&view);
|
|
Adam Tkac |
6cd938 |
}
|
|
Adam Tkac |
6cd938 |
|
|
Adam Tkac |
6cd938 |
+ dns_dynamic_db_cleanup(ISC_TRUE);
|
|
Adam Tkac |
6cd938 |
+
|
|
Adam Tkac |
6cd938 |
while ((nsc = ISC_LIST_HEAD(server->cachelist)) != NULL) {
|
|
Adam Tkac |
6cd938 |
ISC_LIST_UNLINK(server->cachelist, nsc, link);
|
|
Adam Tkac |
6cd938 |
dns_cache_detach(&nsc->cache);
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in
|
|
Tomas Hozza |
a3771c |
index 6dfd146..4fb7c6e 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/dns/Makefile.in
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/Makefile.in
|
|
Tomas Hozza |
4fa997 |
@@ -65,7 +65,7 @@ GEOIPLINKOBJS = geoip.@O@
|
|
Tomas Hozza |
4fa997 |
DNSOBJS = acache.@O@ acl.@O@ adb.@O@ byaddr.@O@ \
|
|
Tomas Hozza |
4fa997 |
cache.@O@ callbacks.@O@ clientinfo.@O@ compress.@O@ \
|
|
Tomas Hozza |
4fa997 |
db.@O@ dbiterator.@O@ dbtable.@O@ diff.@O@ dispatch.@O@ \
|
|
Tomas Hozza |
4fa997 |
- dlz.@O@ dns64.@O@ dnssec.@O@ ds.@O@ forward.@O@ \
|
|
Tomas Hozza |
4fa997 |
+ dlz.@O@ dns64.@O@ dnssec.@O@ ds.@O@ dynamic_db.@O@ forward.@O@ \
|
|
Tomas Hozza |
4fa997 |
iptable.@O@ journal.@O@ keydata.@O@ keytable.@O@ \
|
|
Tomas Hozza |
4fa997 |
lib.@O@ log.@O@ lookup.@O@ \
|
|
Tomas Hozza |
4fa997 |
master.@O@ masterdump.@O@ message.@O@ \
|
|
Tomas Hozza |
4fa997 |
@@ -103,7 +103,7 @@ GEOIOLINKSRCS = geoip.c
|
|
Tomas Hozza |
4fa997 |
DNSSRCS = acache.c acl.c adb.c byaddr.c \
|
|
Tomas Hozza |
4fa997 |
cache.c callbacks.c clientinfo.c compress.c \
|
|
Tomas Hozza |
4fa997 |
db.c dbiterator.c dbtable.c diff.c dispatch.c \
|
|
Tomas Hozza |
4fa997 |
- dlz.c dns64.c dnssec.c ds.c forward.c geoip.c \
|
|
Tomas Hozza |
4fa997 |
+ dlz.c dns64.c dnssec.c ds.c dynamic_db.c forward.c geoip.c \
|
|
Tomas Hozza |
4fa997 |
iptable.c journal.c keydata.c keytable.c lib.c log.c \
|
|
Tomas Hozza |
4fa997 |
lookup.c master.c masterdump.c message.c \
|
|
Tomas Hozza |
4fa997 |
name.c ncache.c nsec.c nsec3.c order.c peer.c portlist.c \
|
|
Tomas Hozza |
4fa997 |
@@ -142,6 +142,12 @@ libdns.@SA@: ${OBJS}
|
|
Tomas Hozza |
4fa997 |
${AR} ${ARFLAGS} $@ ${OBJS}
|
|
Tomas Hozza |
4fa997 |
${RANLIB} $@
|
|
Tomas Hozza |
4fa997 |
|
|
Tomas Hozza |
4fa997 |
+dynamic_db.@O@: dynamic_db.c
|
|
Tomas Hozza |
4fa997 |
+ ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \
|
|
Tomas Hozza |
4fa997 |
+ -DDYNDB_LIBDIR=\"@libdir@/bind/\" \
|
|
Tomas Hozza |
4fa997 |
+ -c ${srcdir}/dynamic_db.c
|
|
Tomas Hozza |
4fa997 |
+
|
|
Tomas Hozza |
4fa997 |
+
|
|
Tomas Hozza |
4fa997 |
libdns.la: ${OBJS}
|
|
Tomas Hozza |
4fa997 |
${LIBTOOL_MODE_LINK} \
|
|
Tomas Hozza |
4fa997 |
${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la -rpath ${libdir} \
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/dynamic_db.c b/lib/dns/dynamic_db.c
|
|
Tomas Hozza |
a3771c |
index e69de29..e32a3c8 100644
|
|
Tomas Hozza |
a3771c |
--- a/lib/dns/dynamic_db.c
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/dynamic_db.c
|
|
Tomas Hozza |
4fa997 |
@@ -0,0 +1,367 @@
|
|
Martin Nagy |
b1c08c |
+/*
|
|
Adam Tkac |
95c9b3 |
+ * Copyright (C) 2008-2011 Red Hat, Inc.
|
|
Martin Nagy |
b1c08c |
+ *
|
|
Martin Nagy |
b1c08c |
+ * Permission to use, copy, modify, and/or distribute this software for any
|
|
Martin Nagy |
b1c08c |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
Martin Nagy |
b1c08c |
+ * copyright notice and this permission notice appear in all copies.
|
|
Martin Nagy |
b1c08c |
+ *
|
|
Martin Nagy |
32aa83 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND Red Hat DISCLAIMS ALL WARRANTIES WITH
|
|
Martin Nagy |
b1c08c |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
Martin Nagy |
32aa83 |
+ * AND FITNESS. IN NO EVENT SHALL Red Hat BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
Martin Nagy |
b1c08c |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
Martin Nagy |
b1c08c |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
Martin Nagy |
b1c08c |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
Martin Nagy |
b1c08c |
+ * PERFORMANCE OF THIS SOFTWARE.
|
|
Martin Nagy |
b1c08c |
+ */
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#include <config.h>
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
ec6004 |
+#include <isc/buffer.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/mem.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/mutex.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/once.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/result.h>
|
|
Martin Nagy |
ec6004 |
+#include <isc/region.h>
|
|
Martin Nagy |
32aa83 |
+#include <isc/task.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/types.h>
|
|
Martin Nagy |
b1c08c |
+#include <isc/util.h>
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#include <dns/dynamic_db.h>
|
|
Martin Nagy |
b1c08c |
+#include <dns/log.h>
|
|
Martin Nagy |
b1c08c |
+#include <dns/types.h>
|
|
Martin Nagy |
32aa83 |
+#include <dns/view.h>
|
|
Martin Nagy |
32aa83 |
+#include <dns/zone.h>
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
32aa83 |
+#include <string.h>
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#if HAVE_DLFCN_H
|
|
Martin Nagy |
b1c08c |
+#include <dlfcn.h>
|
|
Martin Nagy |
b1c08c |
+#endif
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
ec6004 |
+#ifndef DYNDB_LIBDIR
|
|
Martin Nagy |
ec6004 |
+#define DYNDB_LIBDIR ""
|
|
Martin Nagy |
ec6004 |
+#endif
|
|
Martin Nagy |
ec6004 |
+
|
|
Martin Nagy |
b1c08c |
+#define CHECK(op) \
|
|
Martin Nagy |
b1c08c |
+ do { result = (op); \
|
|
Martin Nagy |
b1c08c |
+ if (result != ISC_R_SUCCESS) goto cleanup; \
|
|
Martin Nagy |
b1c08c |
+ } while (0)
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+typedef isc_result_t (*register_func_t)(isc_mem_t *mctx, const char *name,
|
|
Adam Tkac |
95c9b3 |
+ const char * const *argv,
|
|
Adam Tkac |
95c9b3 |
+ const dns_dyndb_arguments_t *dyndb_args);
|
|
Martin Nagy |
b1c08c |
+typedef void (*destroy_func_t)(void);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+typedef struct dyndb_implementation dyndb_implementation_t;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+struct dyndb_implementation {
|
|
Martin Nagy |
b1c08c |
+ isc_mem_t *mctx;
|
|
Martin Nagy |
b1c08c |
+ void *handle;
|
|
Martin Nagy |
b1c08c |
+ register_func_t register_function;
|
|
Martin Nagy |
b1c08c |
+ destroy_func_t destroy_function;
|
|
Martin Nagy |
b1c08c |
+ LINK(dyndb_implementation_t) link;
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
32aa83 |
+struct dns_dyndb_arguments {
|
|
Martin Nagy |
32aa83 |
+ dns_view_t *view;
|
|
Martin Nagy |
32aa83 |
+ dns_zonemgr_t *zmgr;
|
|
Martin Nagy |
32aa83 |
+ isc_task_t *task;
|
|
Martin Nagy |
32aa83 |
+ isc_timermgr_t *timermgr;
|
|
Martin Nagy |
32aa83 |
+};
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
b1c08c |
+/* List of implementations. Locked by dyndb_lock. */
|
|
Martin Nagy |
b1c08c |
+static LIST(dyndb_implementation_t) dyndb_implementations;
|
|
Martin Nagy |
b1c08c |
+/* Locks dyndb_implementations. */
|
|
Martin Nagy |
b1c08c |
+static isc_mutex_t dyndb_lock;
|
|
Martin Nagy |
b1c08c |
+static isc_once_t once = ISC_ONCE_INIT;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static void
|
|
Martin Nagy |
b1c08c |
+dyndb_initialize(void) {
|
|
Martin Nagy |
b1c08c |
+ RUNTIME_CHECK(isc_mutex_init(&dyndb_lock) == ISC_R_SUCCESS);
|
|
Martin Nagy |
b1c08c |
+ INIT_LIST(dyndb_implementations);
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#if HAVE_DLFCN_H
|
|
Martin Nagy |
b1c08c |
+static isc_result_t
|
|
Martin Nagy |
b1c08c |
+load_symbol(void *handle, const char *symbol_name, void **symbolp)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ const char *errmsg;
|
|
Martin Nagy |
b1c08c |
+ void *symbol;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(handle != NULL);
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(symbolp != NULL && *symbolp == NULL);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ symbol = dlsym(handle, symbol_name);
|
|
Martin Nagy |
b1c08c |
+ if (symbol == NULL) {
|
|
Martin Nagy |
b1c08c |
+ errmsg = dlerror();
|
|
Martin Nagy |
b1c08c |
+ if (errmsg == NULL)
|
|
Martin Nagy |
b1c08c |
+ errmsg = "returned function pointer is NULL";
|
|
Martin Nagy |
b1c08c |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
|
Martin Nagy |
b1c08c |
+ DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR,
|
|
Martin Nagy |
b1c08c |
+ "failed to lookup symbol %s: %s",
|
|
Martin Nagy |
b1c08c |
+ symbol_name, errmsg);
|
|
Martin Nagy |
b1c08c |
+ return ISC_R_FAILURE;
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+ dlerror();
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ *symbolp = symbol;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return ISC_R_SUCCESS;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static isc_result_t
|
|
Martin Nagy |
b1c08c |
+load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **impp)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ isc_result_t result;
|
|
Martin Nagy |
ec6004 |
+ size_t module_size;
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_t *module_buf = NULL;
|
|
Martin Nagy |
ec6004 |
+ isc_region_t module_region;
|
|
Adam Tkac |
95c9b3 |
+ void *handle = NULL;
|
|
Martin Nagy |
b1c08c |
+ dyndb_implementation_t *imp;
|
|
Martin Nagy |
b1c08c |
+ register_func_t register_function = NULL;
|
|
Martin Nagy |
b1c08c |
+ destroy_func_t destroy_function = NULL;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(impp != NULL && *impp == NULL);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
ec6004 |
+ /* Build up the full path. */
|
|
Martin Nagy |
ec6004 |
+ module_size = strlen(DYNDB_LIBDIR) + strlen(filename) + 1;
|
|
Martin Nagy |
ec6004 |
+ CHECK(isc_buffer_allocate(mctx, &module_buf, module_size));
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_putstr(module_buf, DYNDB_LIBDIR);
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_putstr(module_buf, filename);
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_putuint8(module_buf, 0);
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_region(module_buf, &module_region);
|
|
Martin Nagy |
ec6004 |
+
|
|
Martin Nagy |
ec6004 |
+ handle = dlopen((char *)module_region.base, RTLD_LAZY);
|
|
Martin Nagy |
b1c08c |
+ if (handle == NULL) {
|
|
Martin Nagy |
b1c08c |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
|
Martin Nagy |
b1c08c |
+ DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR,
|
|
Martin Nagy |
b1c08c |
+ "failed to dynamically load driver '%s': %s",
|
|
Martin Nagy |
b1c08c |
+ filename, dlerror());
|
|
Martin Nagy |
b1c08c |
+ result = ISC_R_FAILURE;
|
|
Martin Nagy |
b1c08c |
+ goto cleanup;
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+ dlerror();
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ CHECK(load_symbol(handle, "dynamic_driver_init",
|
|
Martin Nagy |
b1c08c |
+ (void **)®ister_function));
|
|
Martin Nagy |
b1c08c |
+ CHECK(load_symbol(handle, "dynamic_driver_destroy",
|
|
Martin Nagy |
b1c08c |
+ (void **)&destroy_function));
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ imp = isc_mem_get(mctx, sizeof(dyndb_implementation_t));
|
|
Martin Nagy |
b1c08c |
+ if (imp == NULL) {
|
|
Martin Nagy |
b1c08c |
+ result = ISC_R_NOMEMORY;
|
|
Martin Nagy |
b1c08c |
+ goto cleanup;
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ imp->mctx = NULL;
|
|
Martin Nagy |
b1c08c |
+ isc_mem_attach(mctx, &imp->mctx);
|
|
Martin Nagy |
b1c08c |
+ imp->handle = handle;
|
|
Martin Nagy |
b1c08c |
+ imp->register_function = register_function;
|
|
Martin Nagy |
b1c08c |
+ imp->destroy_function = destroy_function;
|
|
Martin Nagy |
b1c08c |
+ INIT_LINK(imp, link);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ *impp = imp;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+cleanup:
|
|
Martin Nagy |
ec6004 |
+ if (result != ISC_R_SUCCESS && handle != NULL)
|
|
Martin Nagy |
b1c08c |
+ dlclose(handle);
|
|
Martin Nagy |
ec6004 |
+ if (module_buf != NULL)
|
|
Martin Nagy |
ec6004 |
+ isc_buffer_free(&module_buf);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return result;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static void
|
|
Martin Nagy |
b1c08c |
+unload_library(dyndb_implementation_t **impp)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ dyndb_implementation_t *imp;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(impp != NULL && *impp != NULL);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ imp = *impp;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ isc_mem_putanddetach(&imp->mctx, imp, sizeof(dyndb_implementation_t));
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ *impp = NULL;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#else /* HAVE_DLFCN_H */
|
|
Martin Nagy |
b1c08c |
+static isc_result_t
|
|
Martin Nagy |
b1c08c |
+load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **impp)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ UNUSED(mctx);
|
|
Martin Nagy |
b1c08c |
+ UNUSED(filename);
|
|
Martin Nagy |
b1c08c |
+ UNUSED(impp);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB,
|
|
Martin Nagy |
b1c08c |
+ ISC_LOG_ERROR,
|
|
Martin Nagy |
b1c08c |
+ "dynamic database support is not implemented")
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return ISC_R_NOTIMPLEMENTED;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static void
|
|
Martin Nagy |
b1c08c |
+unload_library(dyndb_implementation_t **impp)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ dyndb_implementation_t *imp;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ REQUIRE(impp != NULL && *impp != NULL);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ imp = *impp;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ isc_mem_putanddetach(&imp->mctx, imp, sizeof(dyndb_implementation_t));
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ *impp = NULL;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+#endif /* HAVE_DLFCN_H */
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+isc_result_t
|
|
Martin Nagy |
b1c08c |
+dns_dynamic_db_load(const char *libname, const char *name, isc_mem_t *mctx,
|
|
Adam Tkac |
95c9b3 |
+ const char * const *argv,
|
|
Adam Tkac |
95c9b3 |
+ const dns_dyndb_arguments_t *dyndb_args)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ isc_result_t result;
|
|
Martin Nagy |
b1c08c |
+ dyndb_implementation_t *implementation = NULL;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ CHECK(load_library(mctx, libname, &implementation));
|
|
Martin Nagy |
32aa83 |
+ CHECK(implementation->register_function(mctx, name, argv, dyndb_args));
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ LOCK(&dyndb_lock);
|
|
Martin Nagy |
b1c08c |
+ APPEND(dyndb_implementations, implementation, link);
|
|
Martin Nagy |
b1c08c |
+ UNLOCK(&dyndb_lock);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return ISC_R_SUCCESS;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+cleanup:
|
|
Martin Nagy |
b1c08c |
+ if (implementation != NULL)
|
|
Martin Nagy |
b1c08c |
+ unload_library(&implementation);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ return result;
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
205f42 |
+void
|
|
Martin Nagy |
01aab7 |
+dns_dynamic_db_cleanup(isc_boolean_t exiting)
|
|
Martin Nagy |
b1c08c |
+{
|
|
Martin Nagy |
b1c08c |
+ dyndb_implementation_t *elem;
|
|
Martin Nagy |
01aab7 |
+ dyndb_implementation_t *prev;
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ RUNTIME_CHECK(isc_once_do(&once, dyndb_initialize) == ISC_R_SUCCESS);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+ LOCK(&dyndb_lock);
|
|
Martin Nagy |
01aab7 |
+ elem = TAIL(dyndb_implementations);
|
|
Martin Nagy |
b1c08c |
+ while (elem != NULL) {
|
|
Martin Nagy |
01aab7 |
+ prev = PREV(elem, link);
|
|
Martin Nagy |
b1c08c |
+ UNLINK(dyndb_implementations, elem, link);
|
|
Martin Nagy |
b1c08c |
+ elem->destroy_function();
|
|
Martin Nagy |
b1c08c |
+ unload_library(&elem);
|
|
Martin Nagy |
01aab7 |
+ elem = prev;
|
|
Martin Nagy |
b1c08c |
+ }
|
|
Martin Nagy |
b1c08c |
+ UNLOCK(&dyndb_lock);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
01aab7 |
+ if (exiting == ISC_TRUE)
|
|
Martin Nagy |
01aab7 |
+ isc_mutex_destroy(&dyndb_lock);
|
|
Martin Nagy |
b1c08c |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_arguments_t *
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_arguments_create(isc_mem_t *mctx)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_arguments_t *args;
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ args = isc_mem_get(mctx, sizeof(*args));
|
|
Martin Nagy |
32aa83 |
+ if (args != NULL)
|
|
Martin Nagy |
32aa83 |
+ memset(args, 0, sizeof(*args));
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ return args;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_view(args, NULL);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_zonemgr(args, NULL);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_task(args, NULL);
|
|
Martin Nagy |
32aa83 |
+ dns_dyndb_set_timermgr(args, NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ isc_mem_put(mctx, args, sizeof(*args));
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ if (args->view != NULL)
|
|
Martin Nagy |
32aa83 |
+ dns_view_detach(&args->view);
|
|
Martin Nagy |
32aa83 |
+ if (view != NULL)
|
|
Martin Nagy |
32aa83 |
+ dns_view_attach(view, &args->view);
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+dns_view_t *
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_get_view(dns_dyndb_arguments_t *args)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ return args->view;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ if (args->zmgr != NULL)
|
|
Martin Nagy |
32aa83 |
+ dns_zonemgr_detach(&args->zmgr);
|
|
Martin Nagy |
32aa83 |
+ if (zmgr != NULL)
|
|
Martin Nagy |
32aa83 |
+ dns_zonemgr_attach(zmgr, &args->zmgr);
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+dns_zonemgr_t *
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ return args->zmgr;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ if (args->task != NULL)
|
|
Martin Nagy |
32aa83 |
+ isc_task_detach(&args->task);
|
|
Martin Nagy |
32aa83 |
+ if (task != NULL)
|
|
Martin Nagy |
32aa83 |
+ isc_task_attach(task, &args->task);
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+isc_task_t *
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_get_task(dns_dyndb_arguments_t *args)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ return args->task;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args, isc_timermgr_t *timermgr)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ args->timermgr = timermgr;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+isc_timermgr_t *
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args)
|
|
Martin Nagy |
32aa83 |
+{
|
|
Martin Nagy |
32aa83 |
+ REQUIRE(args != NULL);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+ return args->timermgr;
|
|
Martin Nagy |
32aa83 |
+}
|
|
Tomas Hozza |
4fa997 |
+
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/include/dns/Makefile.in b/lib/dns/include/dns/Makefile.in
|
|
Tomas Hozza |
4fa997 |
index 667db71..0661291 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/dns/include/dns/Makefile.in
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/include/dns/Makefile.in
|
|
Tomas Hozza |
4fa997 |
@@ -23,7 +23,7 @@ top_srcdir = @top_srcdir@
|
|
Tomas Hozza |
4fa997 |
|
|
Tomas Hozza |
4fa997 |
HEADERS = acache.h acl.h adb.h bit.h byaddr.h cache.h callbacks.h cert.h \
|
|
Tomas Hozza |
4fa997 |
client.h clientinfo.h compress.h \
|
|
Tomas Hozza |
4fa997 |
- db.h dbiterator.h dbtable.h diff.h dispatch.h \
|
|
Tomas Hozza |
4fa997 |
+ db.h dbiterator.h dbtable.h diff.h dispatch.h dynamic_db.h \
|
|
Tomas Hozza |
4fa997 |
dlz.h dlz_dlopen.h dns64.h dnssec.h ds.h dsdigest.h \
|
|
Tomas Hozza |
4fa997 |
ecdb.h events.h fixedname.h forward.h geoip.h iptable.h \
|
|
Tomas Hozza |
4fa997 |
journal.h keydata.h keyflags.h keytable.h keyvalues.h \
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/include/dns/dynamic_db.h b/lib/dns/include/dns/dynamic_db.h
|
|
Tomas Hozza |
a3771c |
index e69de29..719fa0f 100644
|
|
Tomas Hozza |
a3771c |
--- a/lib/dns/include/dns/dynamic_db.h
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/include/dns/dynamic_db.h
|
|
Tomas Hozza |
4fa997 |
@@ -0,0 +1,51 @@
|
|
Martin Nagy |
b1c08c |
+/*
|
|
Adam Tkac |
95c9b3 |
+ * Copyright (C) 2008-2011 Red Hat, Inc.
|
|
Martin Nagy |
b1c08c |
+ *
|
|
Martin Nagy |
b1c08c |
+ * Permission to use, copy, modify, and/or distribute this software for any
|
|
Martin Nagy |
b1c08c |
+ * purpose with or without fee is hereby granted, provided that the above
|
|
Martin Nagy |
b1c08c |
+ * copyright notice and this permission notice appear in all copies.
|
|
Martin Nagy |
b1c08c |
+ *
|
|
Martin Nagy |
32aa83 |
+ * THE SOFTWARE IS PROVIDED "AS IS" AND Red Hat DISCLAIMS ALL WARRANTIES WITH
|
|
Martin Nagy |
b1c08c |
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
Martin Nagy |
32aa83 |
+ * AND FITNESS. IN NO EVENT SHALL Red Hat BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
Martin Nagy |
b1c08c |
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
Martin Nagy |
b1c08c |
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
Martin Nagy |
b1c08c |
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
Martin Nagy |
b1c08c |
+ * PERFORMANCE OF THIS SOFTWARE.
|
|
Martin Nagy |
b1c08c |
+ */
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#ifndef DYNAMIC_DB_H
|
|
Martin Nagy |
b1c08c |
+#define DYNAMIC_DB_H
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+#include <isc/types.h>
|
|
Martin Nagy |
205f42 |
+
|
|
Martin Nagy |
b1c08c |
+#include <dns/types.h>
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
32aa83 |
+/*
|
|
Martin Nagy |
32aa83 |
+ * TODO:
|
|
Martin Nagy |
32aa83 |
+ * Reformat the prototypes.
|
|
Martin Nagy |
32aa83 |
+ * Add annotated comments.
|
|
Martin Nagy |
32aa83 |
+ */
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
b1c08c |
+isc_result_t dns_dynamic_db_load(const char *libname, const char *name,
|
|
Martin Nagy |
b1c08c |
+ isc_mem_t *mctx, const char * const *argv,
|
|
Adam Tkac |
95c9b3 |
+ const dns_dyndb_arguments_t *dyndb_args);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
01aab7 |
+void dns_dynamic_db_cleanup(isc_boolean_t exiting);
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
32aa83 |
+dns_dyndb_arguments_t *dns_dyndb_arguments_create(isc_mem_t *mctx);
|
|
Martin Nagy |
32aa83 |
+void dns_dyndb_arguments_destroy(isc_mem_t *mctx, dns_dyndb_arguments_t *args);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
32aa83 |
+void dns_dyndb_set_view(dns_dyndb_arguments_t *args, dns_view_t *view);
|
|
Martin Nagy |
32aa83 |
+dns_view_t *dns_dyndb_get_view(dns_dyndb_arguments_t *args);
|
|
Martin Nagy |
32aa83 |
+void dns_dyndb_set_zonemgr(dns_dyndb_arguments_t *args, dns_zonemgr_t *zmgr);
|
|
Martin Nagy |
32aa83 |
+dns_zonemgr_t *dns_dyndb_get_zonemgr(dns_dyndb_arguments_t *args);
|
|
Martin Nagy |
32aa83 |
+void dns_dyndb_set_task(dns_dyndb_arguments_t *args, isc_task_t *task);
|
|
Martin Nagy |
32aa83 |
+isc_task_t *dns_dyndb_get_task(dns_dyndb_arguments_t *args);
|
|
Martin Nagy |
32aa83 |
+void dns_dyndb_set_timermgr(dns_dyndb_arguments_t *args,
|
|
Martin Nagy |
32aa83 |
+ isc_timermgr_t *timermgr);
|
|
Martin Nagy |
32aa83 |
+isc_timermgr_t *dns_dyndb_get_timermgr(dns_dyndb_arguments_t *args);
|
|
Martin Nagy |
32aa83 |
+
|
|
Martin Nagy |
b1c08c |
+#endif
|
|
Tomas Hozza |
4fa997 |
+
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/include/dns/log.h b/lib/dns/include/dns/log.h
|
|
Tomas Hozza |
a3771c |
index 845be49..7b94ec6 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/dns/include/dns/log.h
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/include/dns/log.h
|
|
Tomas Hozza |
4fa997 |
@@ -78,6 +78,7 @@ LIBDNS_EXTERNAL_DATA extern isc_logmodule_t dns_modules[];
|
|
Adam Tkac |
7f138a |
#define DNS_LOGMODULE_DNSSEC (&dns_modules[27])
|
|
Adam Tkac |
d6323c |
#define DNS_LOGMODULE_CRYPTO (&dns_modules[28])
|
|
Tomas Hozza |
4fa997 |
#define DNS_LOGMODULE_PACKETS (&dns_modules[29])
|
|
Tomas Hozza |
4fa997 |
+#define DNS_LOGMODULE_DYNDB (&dns_modules[30])
|
|
Martin Nagy |
b1c08c |
|
|
Martin Nagy |
b1c08c |
ISC_LANG_BEGINDECLS
|
|
Martin Nagy |
b1c08c |
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/include/dns/types.h b/lib/dns/include/dns/types.h
|
|
Tomas Hozza |
a3771c |
index 00ba58e..b7fdead 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/dns/include/dns/types.h
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/include/dns/types.h
|
|
Tomas Hozza |
4fa997 |
@@ -64,6 +64,7 @@ typedef struct dns_dlzimplementation dns_dlzimplementation_t;
|
|
Martin Nagy |
32aa83 |
typedef struct dns_dlzdb dns_dlzdb_t;
|
|
Tomas Hozza |
4fa997 |
typedef ISC_LIST(dns_dlzdb_t) dns_dlzdblist_t;
|
|
Martin Nagy |
32aa83 |
typedef struct dns_sdlzimplementation dns_sdlzimplementation_t;
|
|
Tomas Hozza |
4fa997 |
+typedef struct dns_dyndb_arguments dns_dyndb_arguments_t;
|
|
Martin Nagy |
32aa83 |
typedef struct dns_decompress dns_decompress_t;
|
|
Martin Nagy |
32aa83 |
typedef struct dns_dispatch dns_dispatch_t;
|
|
Tomas Hozza |
4fa997 |
typedef struct dns_dispatchevent dns_dispatchevent_t;
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/dns/log.c b/lib/dns/log.c
|
|
Tomas Hozza |
a3771c |
index 377b03c..acef9e6 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/dns/log.c
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/dns/log.c
|
|
Tomas Hozza |
4fa997 |
@@ -84,6 +84,7 @@ LIBDNS_EXTERNAL_DATA isc_logmodule_t dns_modules[] = {
|
|
Adam Tkac |
7f138a |
{ "dns/dnssec", 0 },
|
|
Adam Tkac |
d6323c |
{ "dns/crypto", 0 },
|
|
Tomas Hozza |
4fa997 |
{ "dns/packets", 0 },
|
|
Martin Nagy |
b1c08c |
+ { "dns/dynamic_db", 0 },
|
|
Martin Nagy |
b1c08c |
{ NULL, 0 }
|
|
Martin Nagy |
b1c08c |
};
|
|
Martin Nagy |
b1c08c |
|
|
Tomas Hozza |
4fa997 |
diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c
|
|
Tomas Hozza |
a3771c |
index 780ab46..48f166a 100644
|
|
Tomas Hozza |
4fa997 |
--- a/lib/isccfg/namedconf.c
|
|
Tomas Hozza |
4fa997 |
+++ b/lib/isccfg/namedconf.c
|
|
Tomas Hozza |
a3771c |
@@ -105,6 +105,7 @@ static cfg_type_t cfg_type_controls;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_controls_sockaddr;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_destinationlist;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_dialuptype;
|
|
Martin Nagy |
b1c08c |
+static cfg_type_t cfg_type_dynamic_db;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_ixfrdifftype;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_key;
|
|
Martin Nagy |
b1c08c |
static cfg_type_t cfg_type_logfile;
|
|
Tomas Hozza |
a3771c |
@@ -962,6 +963,7 @@ namedconf_or_view_clauses[] = {
|
|
Tomas Hozza |
4fa997 |
{ "key", &cfg_type_key, CFG_CLAUSEFLAG_MULTI },
|
|
Martin Nagy |
b1c08c |
{ "zone", &cfg_type_zone, CFG_CLAUSEFLAG_MULTI },
|
|
Tomas Hozza |
4fa997 |
{ "dlz", &cfg_type_dlz, CFG_CLAUSEFLAG_MULTI },
|
|
Martin Nagy |
b1c08c |
+ { "dynamic-db", &cfg_type_dynamic_db, CFG_CLAUSEFLAG_MULTI },
|
|
Martin Nagy |
b1c08c |
{ "server", &cfg_type_server, CFG_CLAUSEFLAG_MULTI },
|
|
Adam Tkac |
f12e46 |
{ "trusted-keys", &cfg_type_dnsseckeys, CFG_CLAUSEFLAG_MULTI },
|
|
Adam Tkac |
e99cc3 |
{ "managed-keys", &cfg_type_managedkeys, CFG_CLAUSEFLAG_MULTI },
|
|
Tomas Hozza |
a3771c |
@@ -2188,6 +2190,40 @@ static cfg_type_t cfg_type_dialuptype = {
|
|
Martin Nagy |
b1c08c |
&cfg_rep_string, dialup_enums
|
|
Martin Nagy |
b1c08c |
};
|
|
Martin Nagy |
b1c08c |
|
|
Martin Nagy |
b1c08c |
+/*
|
|
Martin Nagy |
b1c08c |
+ * Dynamic database clauses.
|
|
Martin Nagy |
b1c08c |
+ */
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static cfg_clausedef_t
|
|
Martin Nagy |
b1c08c |
+dynamic_db_clauses[] = {
|
|
Martin Nagy |
b1c08c |
+ { "library", &cfg_type_qstring, 0 },
|
|
Martin Nagy |
b1c08c |
+ { "arg", &cfg_type_qstring, CFG_CLAUSEFLAG_MULTI },
|
|
Martin Nagy |
b1c08c |
+ { NULL, NULL, 0 }
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static cfg_clausedef_t *
|
|
Martin Nagy |
b1c08c |
+dynamic_db_clausesets[] = {
|
|
Martin Nagy |
b1c08c |
+ dynamic_db_clauses,
|
|
Martin Nagy |
b1c08c |
+ NULL
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static cfg_type_t cfg_type_dynamic_db_opts = {
|
|
Martin Nagy |
b1c08c |
+ "dynamically_loadable_zones_opts", cfg_parse_map,
|
|
Martin Nagy |
b1c08c |
+ cfg_print_map, cfg_doc_map, &cfg_rep_map,
|
|
Martin Nagy |
b1c08c |
+ dynamic_db_clausesets
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static cfg_tuplefielddef_t dynamic_db_fields[] = {
|
|
Martin Nagy |
b1c08c |
+ { "name", &cfg_type_astring, 0 },
|
|
Martin Nagy |
b1c08c |
+ { "options", &cfg_type_dynamic_db_opts, 0 },
|
|
Martin Nagy |
b1c08c |
+ { NULL, NULL, 0 }
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
+static cfg_type_t cfg_type_dynamic_db = {
|
|
Martin Nagy |
b1c08c |
+ "dynamic_db", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple,
|
|
Martin Nagy |
b1c08c |
+ &cfg_rep_tuple, dynamic_db_fields
|
|
Martin Nagy |
b1c08c |
+};
|
|
Martin Nagy |
b1c08c |
+
|
|
Martin Nagy |
b1c08c |
static const char *notify_enums[] = { "explicit", "master-only", NULL };
|
|
Martin Nagy |
b1c08c |
static isc_result_t
|
|
Martin Nagy |
b1c08c |
parse_notify_type(cfg_parser_t *pctx, const cfg_type_t *type, cfg_obj_t **ret) {
|