]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3066. [func] The DLZ "dlopen" driver is now built by default,
authorEvan Hunt <each@isc.org>
Thu, 10 Mar 2011 04:29:18 +0000 (04:29 +0000)
committerEvan Hunt <each@isc.org>
Thu, 10 Mar 2011 04:29:18 +0000 (04:29 +0000)
no longer requiring a configure option.  To
disable it, use "configure --without-dlopen".
(Note: driver not supported on win32.) [RT #23467]

29 files changed:
CHANGES
bin/named/Makefile.in
bin/named/include/dlz/dlz_dlopen_driver.h [new file with mode: 0644]
bin/named/main.c
bin/named/query.c
bin/named/server.c
bin/named/unix/Makefile.in
bin/named/unix/dlz_dlopen_driver.c [new file with mode: 0644]
bin/named/xfrout.c
bin/named/zoneconf.c
bin/tests/system/Makefile.in
bin/tests/system/dlzexternal/Makefile.in [new file with mode: 0644]
bin/tests/system/dlzexternal/dlopen.c [new file with mode: 0644]
bin/tests/system/dlzexternal/driver.c [new file with mode: 0644]
bin/tests/system/dlzexternal/driver.h [new file with mode: 0644]
bin/tests/system/dlzexternal/ns1/named.conf.in [moved from bin/tests/system/dlzexternal/ns1/named.conf with 89% similarity]
bin/tests/system/dlzexternal/prereq.sh
bin/tests/system/dlzexternal/tests.sh
bin/tests/system/logfileconfig/ns1/named.conf
config.h.in
configure.in
contrib/dlz/bin/dlzbdb/Makefile.in
contrib/dlz/config.dlz.in
contrib/dlz/drivers/dlz_dlopen_driver.c
contrib/dlz/drivers/dlz_drivers.c
contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h
lib/dns/Makefile.in
lib/dns/win32/libdns.def
lib/isccfg/Makefile.in

diff --git a/CHANGES b/CHANGES
index 2bf2f02fa2a2bdeb3e96e4a416cf939ec2c878b7..2d47084f3e39c5618e08df9f4fd9b4a9c50f2f45 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+3066.  [func]          The DLZ "dlopen" driver is now built by default,
+                       no longer requiring a configure option.  To
+                       disable it, use "configure --without-dlopen".
+                       (Note: driver not supported on win32.) [RT #23467]
+                       
 3065.  [bug]           RRSIG could have time stamps too far in the future.
                        [RT #23356]
 
index f1915a54942433316b9cc97e3b30e56d9b8a111b..4e354c09d57f7943fc28dd62458019385ac961db 100644 (file)
@@ -13,7 +13,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.114 2010/12/22 09:00:40 marka Exp $
+# $Id: Makefile.in,v 1.114.14.1 2011/03/10 04:29:14 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -45,7 +45,7 @@ CINCLUDES =   -I${srcdir}/include -I${srcdir}/unix/include -I. \
                ${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} ${ISC_INCLUDES} \
                ${DLZDRIVER_INCLUDES} ${DBDRIVER_INCLUDES} @DST_OPENSSL_INC@
 
-CDEFINES =      @USE_DLZ@ @USE_PKCS11@ @USE_OPENSSL@
+CDEFINES =      @CONTRIB_DLZ@ @USE_PKCS11@ @USE_OPENSSL@
 
 CWARNINGS =
 
@@ -89,7 +89,7 @@ OBJS =                builtin.@O@ client.@O@ config.@O@ control.@O@ \
                lwdgnba.@O@ lwdgrbn.@O@ lwdnoop.@O@ lwsearch.@O@ \
                ${DLZDRIVER_OBJS} ${DBDRIVER_OBJS}
 
-UOBJS =                unix/os.@O@
+UOBJS =                unix/os.@O@ unix/dlz_dlopen_driver.@O@
 
 SYMOBJS =      symtbl.@O@
 
diff --git a/bin/named/include/dlz/dlz_dlopen_driver.h b/bin/named/include/dlz/dlz_dlopen_driver.h
new file mode 100644 (file)
index 0000000..7883a50
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2010-2011  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Written by Andrew Tridgell
+ *
+ * based on dlz_stub_driver.h
+ * which is:
+ * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
+ * conceived and contributed by Rob Butler.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef DLZ_DLOPEN_DRIVER_H
+#define DLZ_DLOPEN_DRIVER_H
+
+isc_result_t
+dlz_dlopen_init(isc_mem_t *mctx);
+
+void
+dlz_dlopen_clear(void);
+
+#define DLZ_DLOPEN_VERSION 1
+
+#endif
index 693aec9b24a318595dc076d5f032765e90faa4b4..4c43656ca62003b95608657be30f842693d418f7 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: main.c,v 1.180 2010/12/22 03:59:02 marka Exp $ */
+/* $Id: main.c,v 1.180.14.1 2011/03/10 04:29:14 each Exp $ */
 
 /*! \file */
 
@@ -51,6 +51,8 @@
 
 #include <dst/result.h>
 
+#include <dlz/dlz_dlopen_driver.h>
+
 /*
  * Defining NS_MAIN provides storage declarations (rather than extern)
  * for variables in named/globals.h.
  */
 /* #include "xxdb.h" */
 
+#ifdef CONTRIB_DLZ
 /*
- * Include DLZ drivers if appropriate.
+ * Include contributed DLZ drivers if appropriate.
  */
-#ifdef DLZ
 #include <dlz/dlz_drivers.h>
 #endif
 
@@ -856,9 +858,19 @@ setup(void) {
         */
        /* xxdb_init(); */
 
-#ifdef DLZ
+#ifdef ISC_DLZ_DLOPEN
+       /*
+        * Register the DLZ "dlopen" driver.
+        */
+       result = dlz_dlopen_init(ns_g_mctx);
+       if (result != ISC_R_SUCCESS)
+               ns_main_earlyfatal("dlz_dlopen_init() failed: %s",
+                                  isc_result_totext(result));
+#endif
+
+#if CONTRIB_DLZ
        /*
-        * Register any DLZ drivers.
+        * Register any other contributed DLZ drivers.
         */
        result = dlz_drivers_init();
        if (result != ISC_R_SUCCESS)
@@ -882,12 +894,18 @@ cleanup(void) {
         */
        /* xxdb_clear(); */
 
-#ifdef DLZ
+#ifdef CONTRIB_DLZ
        /*
-        * Unregister any DLZ drivers.
+        * Unregister contributed DLZ drivers.
         */
        dlz_drivers_clear();
 #endif
+#ifdef ISC_DLZ_DLOPEN
+       /*
+        * Unregister "dlopen" DLZ driver.
+        */
+       dlz_dlopen_clear();
+#endif
 
        dns_name_destroy();
 
index d9d20be373f239238a57b667d06094f0927c4ca3..63570ea8579168c318ec2a6ad2c6aca8a2846e99 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: query.c,v 1.353.8.2 2011/02/18 15:27:58 smann Exp $ */
+/* $Id: query.c,v 1.353.8.3 2011/03/10 04:29:15 each Exp $ */
 
 /*! \file */
 
@@ -31,9 +31,7 @@
 #include <dns/adb.h>
 #include <dns/byaddr.h>
 #include <dns/db.h>
-#ifdef DLZ
 #include <dns/dlz.h>
-#endif
 #include <dns/dns64.h>
 #include <dns/dnssec.h>
 #include <dns/events.h>
@@ -1025,7 +1023,6 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
 {
        isc_result_t result;
 
-#ifdef DLZ
        isc_result_t tresult;
        unsigned int namelabels;
        unsigned int zonelabels;
@@ -1091,16 +1088,10 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype,
                        result = tresult;
                }
        }
-#else
-       result = query_getzonedb(client, name, qtype, options,
-                                zonep, dbp, versionp);
-#endif
 
        /* If successful, Transfer ownership of zone. */
        if (result == ISC_R_SUCCESS) {
-#ifdef DLZ
                *zonep = zone;
-#endif
                /*
                 * If neither attempt above succeeded, return the cache instead
                 */
@@ -5193,17 +5184,13 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
 
        if (event == NULL && client->query.restarts == 0) {
                if (is_zone) {
-#ifdef DLZ
                        if (zone != NULL) {
                                /*
                                 * if is_zone = true, zone = NULL then this is
                                 * a DLZ zone.  Don't attempt to attach zone.
                                 */
-#endif
                                dns_zone_attach(zone, &client->query.authzone);
-#ifdef DLZ
                        }
-#endif
                        dns_db_attach(db, &client->query.authdb);
                }
                client->query.authdbset = ISC_TRUE;
@@ -5866,9 +5853,7 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype)
                 * resolver and not have it cached.
                 */
                if (qtype == dns_rdatatype_soa &&
-#ifdef DLZ
                    zone != NULL &&
-#endif
                    dns_zone_getzeronosoattl(zone))
                        result = query_addsoa(client, db, version, 0,
                                          dns_rdataset_isassociated(rdataset));
index 349f94e1541ac66bd401b66fa414e46f5d6e69d1..368d47d9e3faee8b836f14a26b73951d0e39727c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: server.c,v 1.599.8.6 2011/03/03 16:18:12 each Exp $ */
+/* $Id: server.c,v 1.599.8.7 2011/03/10 04:29:15 each Exp $ */
 
 /*! \file */
 
@@ -60,9 +60,7 @@
 #include <dns/cache.h>
 #include <dns/db.h>
 #include <dns/dispatch.h>
-#ifdef DLZ
 #include <dns/dlz.h>
-#endif
 #include <dns/dns64.h>
 #include <dns/forward.h>
 #include <dns/journal.h>
@@ -1340,7 +1338,6 @@ cache_sharable(dns_view_t *originview, dns_view_t *view,
        return (ISC_TRUE);
 }
 
-#ifdef DLZ
 /*
  * Callback from DLZ configure when the driver sets up a writeable zone
  */
@@ -1358,7 +1355,6 @@ dlzconfigure_callback(dns_view_t *view, dns_zone_t *zone) {
        return ns_zone_configure_writeable_dlz(view->dlzdatabase,
                                               zone, zclass, origin);
 }
-#endif
 
 static isc_result_t
 dns64_reverse(dns_view_t *view, isc_mem_t *mctx, isc_netaddr_t *na,
@@ -1569,11 +1565,9 @@ configure_view(dns_view_t *view, cfg_parser_t* parser,
        const cfg_obj_t *forwarders;
        const cfg_obj_t *alternates;
        const cfg_obj_t *zonelist;
-#ifdef DLZ
        const cfg_obj_t *dlz;
        unsigned int dlzargc;
        char **dlzargv;
-#endif
        const cfg_obj_t *disabled;
        const cfg_obj_t *obj;
        const cfg_listelt_t *element;
@@ -1784,7 +1778,6 @@ configure_view(dns_view_t *view, cfg_parser_t* parser,
                }
        }
 
-#ifdef DLZ
        /*
         * Create Dynamically Loadable Zone driver.
         */
@@ -1829,7 +1822,6 @@ configure_view(dns_view_t *view, cfg_parser_t* parser,
                                goto cleanup;
                }
        }
-#endif
 
        /*
         * Obtain configuration parameters that affect the decision of whether
index 11c14b18c7c8f5da7adba9240e0092928190de6b..29eb10216ee7ec43a2ffdbe3b70dcd076ed6ddec 100644 (file)
@@ -13,7 +13,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.13 2009/12/05 23:31:40 each Exp $
+# $Id: Makefile.in,v 1.13.244.1 2011/03/10 04:29:15 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -22,14 +22,15 @@ top_srcdir =        @top_srcdir@
 @BIND9_MAKE_INCLUDES@
 
 CINCLUDES =    -I${srcdir}/include -I${srcdir}/../include \
+               ${ISCCFG_INCLUDES} ${ISCCC_INCLUDES} \
                ${DNS_INCLUDES} ${ISC_INCLUDES}
 
 CDEFINES =
 CWARNINGS =
 
-OBJS =         os.@O@
+OBJS =         os.@O@ dlz_dlopen_driver.@O@
 
-SRCS =         os.c
+SRCS =         os.c dlz_dlopen_driver.c
 
 TARGETS =      ${OBJS}
 
diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c
new file mode 100644 (file)
index 0000000..9798624
--- /dev/null
@@ -0,0 +1,642 @@
+/*
+ * Copyright (C) 2010,2011  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Written by Andrew Tridgell
+ *
+ * based on dlz_stub_driver.c
+ * which is:
+ * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ * see dlz_stub_driver.c for details
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
+ * conceived and contributed by Rob Butler.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include <dns/log.h>
+#include <dns/sdlz.h>
+#include <dns/result.h>
+
+#include <isc/mem.h>
+#include <isc/print.h>
+#include <isc/result.h>
+#include <isc/util.h>
+
+#include <named/globals.h>
+
+#include <dlz/dlz_dlopen_driver.h>
+
+#ifdef ISC_DLZ_DLOPEN
+static dns_sdlzimplementation_t *dlz_dlopen = NULL;
+
+
+typedef struct dlopen_data {
+       isc_mem_t *mctx;
+       char *dl_path;
+       char *dlzname;
+       void *dl_handle;
+       void *dbdata;
+       unsigned int flags;
+       isc_mutex_t lock;
+       int version;
+       isc_boolean_t in_configure;
+
+       int (*dlz_version)(unsigned int *flags);
+       isc_result_t (*dlz_create)(const char *dlzname,
+                                  unsigned int argc, char *argv[],
+                                  void **dbdata, ...);
+       isc_result_t (*dlz_findzonedb)(void *dbdata, const char *name);
+       isc_result_t (*dlz_lookup)(const char *zone, const char *name,
+                                  void *dbdata, dns_sdlzlookup_t *lookup);
+       isc_result_t (*dlz_authority)(const char *zone, void *dbdata,
+                                     dns_sdlzlookup_t *lookup);
+       isc_result_t (*dlz_allnodes)(const char *zone, void *dbdata,
+                                    dns_sdlzallnodes_t *allnodes);
+       isc_result_t (*dlz_allowzonexfr)(void *dbdata, const char *name,
+                                        const char *client);
+       isc_result_t (*dlz_newversion)(const char *zone, void *dbdata,
+                                      void **versionp);
+       void         (*dlz_closeversion)(const char *zone, isc_boolean_t commit,
+                                        void *dbdata, void **versionp);
+       isc_result_t (*dlz_configure)(dns_view_t *view, void *dbdata);
+       isc_boolean_t (*dlz_ssumatch)(const char *signer, const char *name,
+                                     const char *tcpaddr, const char *type,
+                                     const char *key, isc_uint32_t keydatalen,
+                                     unsigned char *keydata, void *dbdata);
+       isc_result_t (*dlz_addrdataset)(const char *name, const char *rdatastr,
+                                       void *dbdata, void *version);
+       isc_result_t (*dlz_subrdataset)(const char *name, const char *rdatastr,
+                                       void *dbdata, void *version);
+       isc_result_t (*dlz_delrdataset)(const char *name, const char *type,
+                                       void *dbdata, void *version);
+       void         (*dlz_destroy)(void *dbdata);
+} dlopen_data_t;
+
+/* Modules can choose whether they are lock-safe or not. */
+#define MAYBE_LOCK(cd) \
+       do { \
+               if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
+                   cd->in_configure == ISC_FALSE) \
+                       LOCK(&cd->lock); \
+       } while (0)
+
+#define MAYBE_UNLOCK(cd) \
+       do { \
+               if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
+                   cd->in_configure == ISC_FALSE) \
+                       UNLOCK(&cd->lock); \
+       } while (0)
+
+/*
+ * Log a message at the given level.
+ */
+static void dlopen_log(int level, const char *fmt, ...)
+{
+       va_list ap;
+       va_start(ap, fmt);
+       isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE,
+                      DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(level),
+                      fmt, ap);
+       va_end(ap);
+}
+
+/*
+ * SDLZ methods
+ */
+
+static isc_result_t
+dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
+                   dns_sdlzallnodes_t *allnodes)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_allnodes == NULL) {
+               return (ISC_R_NOPERM);
+       }
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_allnodes(zone, cd->dbdata, allnodes);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+
+static isc_result_t
+dlopen_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
+                       const char *client)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+
+       if (cd->dlz_allowzonexfr == NULL) {
+               return (ISC_R_NOPERM);
+       }
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_allowzonexfr(cd->dbdata, name, client);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+static isc_result_t
+dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
+                  dns_sdlzlookup_t *lookup)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_authority == NULL) {
+               return (ISC_R_NOTIMPLEMENTED);
+       }
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_authority(zone, cd->dbdata, lookup);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+static isc_result_t
+dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_findzonedb(cd->dbdata, name);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+
+static isc_result_t
+dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
+                 void *dbdata, dns_sdlzlookup_t *lookup)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_lookup(zone, name, cd->dbdata, lookup);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+/*
+ * Load a symbol from the library
+ */
+static void *
+dl_load_symbol(dlopen_data_t *cd, const char *symbol, isc_boolean_t mandatory) {
+       void *ptr = dlsym(cd->dl_handle, symbol);
+       if (ptr == NULL && mandatory) {
+               dlopen_log(ISC_LOG_ERROR,
+                          "dlz_dlopen: library '%s' is missing "
+                          "required symbol '%s'", cd->dl_path, symbol);
+       }
+       return (ptr);
+}
+
+/*
+ * Called at startup for each dlopen zone in named.conf
+ */
+static isc_result_t
+dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
+                 void *driverarg, void **dbdata)
+{
+       dlopen_data_t *cd;
+       isc_mem_t *mctx = NULL;
+       isc_result_t result = ISC_R_FAILURE;
+       int dlopen_flags = 0;
+
+       UNUSED(driverarg);
+
+       if (argc < 2) {
+               dlopen_log(ISC_LOG_ERROR,
+                          "dlz_dlopen driver for '%s' needs a path to "
+                          "the shared library", dlzname);
+               return (ISC_R_FAILURE);
+       }
+
+       isc_mem_create(0, 0, &mctx);
+
+       cd = isc_mem_get(mctx, sizeof(*cd));
+       if (cd == NULL) {
+               isc_mem_destroy(&mctx);
+               return (ISC_R_NOMEMORY);
+       }
+       memset(cd, 0, sizeof(*cd));
+
+       cd->mctx = mctx;
+
+       cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);
+       if (cd->dl_path == NULL) {
+               goto failed;
+       }
+
+       cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);
+       if (cd->dlzname == NULL) {
+               goto failed;
+       }
+
+       /* Initialize the lock */
+       isc_mutex_init(&cd->lock);
+
+       /* Open the library */
+       dlopen_flags = RTLD_NOW;
+
+#ifdef RTLD_DEEPBIND
+       /*
+        * If RTLD_DEEPBIND is available then use it. This can avoid
+        * issues with a module using a different version of a system
+        * library than one that bind9 uses. For example, bind9 may link
+        * to MIT kerberos, but the module may use Heimdal. If we don't
+        * use RTLD_DEEPBIND then we could end up with Heimdal functions
+        * calling MIT functions, which leads to bizarre results (usually
+        * a segfault).
+        */
+       dlopen_flags |= RTLD_DEEPBIND;
+#endif
+
+       cd->dl_handle = dlopen(cd->dl_path, dlopen_flags);
+       if (cd->dl_handle == NULL) {
+               dlopen_log(ISC_LOG_ERROR,
+                          "dlz_dlopen failed to open library '%s' - %s",
+                          cd->dl_path, dlerror());
+               goto failed;
+       }
+
+       /* Find the symbols */
+       cd->dlz_version = dl_load_symbol(cd, "dlz_version", ISC_TRUE);
+       cd->dlz_create = dl_load_symbol(cd, "dlz_create", ISC_TRUE);
+       cd->dlz_lookup = dl_load_symbol(cd, "dlz_lookup", ISC_TRUE);
+       cd->dlz_findzonedb = dl_load_symbol(cd, "dlz_findzonedb", ISC_TRUE);
+
+       if (cd->dlz_create == NULL ||
+           cd->dlz_lookup == NULL ||
+           cd->dlz_findzonedb == NULL)
+       {
+               /* We're missing a required symbol */
+               goto failed;
+       }
+
+       cd->dlz_allowzonexfr = dl_load_symbol(cd, "dlz_allowzonexfr",
+                                             ISC_FALSE);
+       cd->dlz_allnodes = dl_load_symbol(cd, "dlz_allnodes",
+                                         ISC_TF(cd->dlz_allowzonexfr != NULL));
+       cd->dlz_authority = dl_load_symbol(cd, "dlz_authority", ISC_FALSE);
+       cd->dlz_newversion = dl_load_symbol(cd, "dlz_newversion", ISC_FALSE);
+       cd->dlz_closeversion = dl_load_symbol(cd, "dlz_closeversion",
+                                           ISC_TF(cd->dlz_newversion != NULL));
+       cd->dlz_configure = dl_load_symbol(cd, "dlz_configure", ISC_FALSE);
+       cd->dlz_ssumatch = dl_load_symbol(cd, "dlz_ssumatch", ISC_FALSE);
+       cd->dlz_addrdataset = dl_load_symbol(cd, "dlz_addrdataset", ISC_FALSE);
+       cd->dlz_subrdataset = dl_load_symbol(cd, "dlz_subrdataset", ISC_FALSE);
+       cd->dlz_delrdataset = dl_load_symbol(cd, "dlz_delrdataset", ISC_FALSE);
+
+       /* Check the version of the API is the same */
+       cd->version = cd->dlz_version(&cd->flags);
+       if (cd->version != DLZ_DLOPEN_VERSION) {
+               dlopen_log(ISC_LOG_ERROR,
+                          "dlz_dlopen: incorrect version %d "
+                          "should be %d in '%s'",
+                          cd->version, DLZ_DLOPEN_VERSION, cd->dl_path);
+               goto failed;
+       }
+
+       /*
+        * Call the library's create function. Note that this is an
+        * extended version of dlz create, with the addition of
+        * named function pointers for helper functions that the
+        * driver will need. This avoids the need for the backend to
+        * link the BIND9 libraries
+        */
+       MAYBE_LOCK(cd);
+       result = cd->dlz_create(dlzname, argc-1, argv+1,
+                               &cd->dbdata,
+                               "log", dlopen_log,
+                               "putrr", dns_sdlz_putrr,
+                               "putnamedrr", dns_sdlz_putnamedrr,
+                               "writeable_zone", dns_dlz_writeablezone,
+                               NULL);
+       MAYBE_UNLOCK(cd);
+       if (result != ISC_R_SUCCESS)
+               goto failed;
+
+       *dbdata = cd;
+
+       return (ISC_R_SUCCESS);
+
+failed:
+       dlopen_log(ISC_LOG_ERROR, "dlz_dlopen of '%s' failed", dlzname);
+       if (cd->dl_path)
+               isc_mem_free(mctx, cd->dl_path);
+       if (cd->dlzname)
+               isc_mem_free(mctx, cd->dlzname);
+       if (dlopen_flags)
+               isc_mutex_destroy(&cd->lock);
+#ifdef HAVE_DLCLOSE
+       if (cd->dl_handle)
+               dlclose(cd->dl_handle);
+#endif
+       isc_mem_put(mctx, cd, sizeof(*cd));
+       isc_mem_destroy(&mctx);
+       return (result);
+}
+
+
+/*
+ * Called when bind is shutting down
+ */
+static void
+dlopen_dlz_destroy(void *driverarg, void *dbdata) {
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_mem_t *mctx;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_destroy) {
+               MAYBE_LOCK(cd);
+               cd->dlz_destroy(cd->dbdata);
+               MAYBE_UNLOCK(cd);
+       }
+
+       if (cd->dl_path)
+               isc_mem_free(cd->mctx, cd->dl_path);
+       if (cd->dlzname)
+               isc_mem_free(cd->mctx, cd->dlzname);
+
+#ifdef HAVE_DLCLOSE
+       if (cd->dl_handle)
+               dlclose(cd->dl_handle);
+#endif
+
+       isc_mutex_destroy(&cd->lock);
+
+       mctx = cd->mctx;
+       isc_mem_put(mctx, cd, sizeof(*cd));
+       isc_mem_destroy(&mctx);
+}
+
+/*
+ * Called to start a transaction
+ */
+static isc_result_t
+dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
+                     void **versionp)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_newversion == NULL)
+               return (ISC_R_NOTIMPLEMENTED);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_newversion(zone, cd->dbdata, versionp);
+       MAYBE_UNLOCK(cd);
+       return (result);
+}
+
+/*
+ * Called to end a transaction
+ */
+static void
+dlopen_dlz_closeversion(const char *zone, isc_boolean_t commit,
+                       void *driverarg, void *dbdata, void **versionp)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_newversion == NULL) {
+               *versionp = NULL;
+               return;
+       }
+
+       MAYBE_LOCK(cd);
+       cd->dlz_closeversion(zone, commit, cd->dbdata, versionp);
+       MAYBE_UNLOCK(cd);
+}
+
+/*
+ * Called on startup to configure any writeable zones
+ */
+static isc_result_t
+dlopen_dlz_configure(dns_view_t *view, void *driverarg, void *dbdata) {
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_configure == NULL)
+               return (ISC_R_SUCCESS);
+
+       MAYBE_LOCK(cd);
+       cd->in_configure = ISC_TRUE;
+       result = cd->dlz_configure(view, cd->dbdata);
+       cd->in_configure = ISC_FALSE;
+       MAYBE_UNLOCK(cd);
+
+       return (result);
+}
+
+
+/*
+ * Check for authority to change a name
+ */
+static isc_boolean_t
+dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
+                   const char *type, const char *key, isc_uint32_t keydatalen,
+                   unsigned char *keydata, void *driverarg, void *dbdata)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_boolean_t ret;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_ssumatch == NULL)
+               return (ISC_FALSE);
+
+       MAYBE_LOCK(cd);
+       ret = cd->dlz_ssumatch(signer, name, tcpaddr, type, key, keydatalen,
+                              keydata, cd->dbdata);
+       MAYBE_UNLOCK(cd);
+
+       return (ret);
+}
+
+
+/*
+ * Add an rdataset
+ */
+static isc_result_t
+dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
+                      void *driverarg, void *dbdata, void *version)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_addrdataset == NULL)
+               return (ISC_R_NOTIMPLEMENTED);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_addrdataset(name, rdatastr, cd->dbdata, version);
+       MAYBE_UNLOCK(cd);
+
+       return (result);
+}
+
+/*
+ * Subtract an rdataset
+ */
+static isc_result_t
+dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
+                      void *driverarg, void *dbdata, void *version)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_subrdataset == NULL)
+               return (ISC_R_NOTIMPLEMENTED);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_subrdataset(name, rdatastr, cd->dbdata, version);
+       MAYBE_UNLOCK(cd);
+
+       return (result);
+}
+
+/*
+  delete a rdataset
+ */
+static isc_result_t
+dlopen_dlz_delrdataset(const char *name, const char *type,
+                      void *driverarg, void *dbdata, void *version)
+{
+       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
+       isc_result_t result;
+
+       UNUSED(driverarg);
+
+       if (cd->dlz_delrdataset == NULL)
+               return (ISC_R_NOTIMPLEMENTED);
+
+       MAYBE_LOCK(cd);
+       result = cd->dlz_delrdataset(name, type, cd->dbdata, version);
+       MAYBE_UNLOCK(cd);
+
+       return (result);
+}
+
+
+static dns_sdlzmethods_t dlz_dlopen_methods = {
+       dlopen_dlz_create,
+       dlopen_dlz_destroy,
+       dlopen_dlz_findzonedb,
+       dlopen_dlz_lookup,
+       dlopen_dlz_authority,
+       dlopen_dlz_allnodes,
+       dlopen_dlz_allowzonexfr,
+       dlopen_dlz_newversion,
+       dlopen_dlz_closeversion,
+       dlopen_dlz_configure,
+       dlopen_dlz_ssumatch,
+       dlopen_dlz_addrdataset,
+       dlopen_dlz_subrdataset,
+       dlopen_dlz_delrdataset
+};
+#endif
+
+/*
+ * Register driver with BIND
+ */
+isc_result_t
+dlz_dlopen_init(isc_mem_t *mctx) {
+#ifndef ISC_DLZ_DLOPEN
+       UNUSED(mctx);
+       return (ISC_R_NOTIMPLEMENTED);
+#else
+       isc_result_t result;
+
+       dlopen_log(2, "Registering DLZ_dlopen driver");
+
+       result = dns_sdlzregister("dlopen", &dlz_dlopen_methods, NULL,
+                                 DNS_SDLZFLAG_RELATIVEOWNER |
+                                 DNS_SDLZFLAG_THREADSAFE,
+                                 mctx, &dlz_dlopen);
+
+       if (result != ISC_R_SUCCESS) {
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "dns_sdlzregister() failed: %s",
+                                isc_result_totext(result));
+               result = ISC_R_UNEXPECTED;
+       }
+
+       return (result);
+#endif
+}
+
+
+/*
+ * Unregister the driver
+ */
+void
+dlz_dlopen_clear(void) {
+#ifdef ISC_DLZ_DLOPEN
+       dlopen_log(2, "Unregistering DLZ_dlopen driver");
+       if (dlz_dlopen != NULL)
+               dns_sdlzunregister(&dlz_dlopen);
+#endif
+}
index d87de5ee3cf52f7a5d817a6bc58dbeb250fd410c..7808ad281d6632d8570803bb74824b67b24a2a15 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: xfrout.c,v 1.139 2010/12/18 01:56:19 each Exp $ */
+/* $Id: xfrout.c,v 1.139.16.1 2011/03/10 04:29:15 each Exp $ */
 
 #include <config.h>
 
@@ -28,9 +28,7 @@
 
 #include <dns/db.h>
 #include <dns/dbiterator.h>
-#ifdef DLZ
 #include <dns/dlz.h>
-#endif
 #include <dns/fixedname.h>
 #include <dns/journal.h>
 #include <dns/message.h>
@@ -752,9 +750,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
        char msg[NS_CLIENT_ACLMSGSIZE("zone transfer")];
        char keyname[DNS_NAME_FORMATSIZE];
        isc_boolean_t is_poll = ISC_FALSE;
-#ifdef DLZ
        isc_boolean_t is_dlz = ISC_FALSE;
-#endif
 
        switch (reqtype) {
        case dns_rdatatype_axfr:
@@ -806,9 +802,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
        result = dns_zt_find(client->view->zonetable, question_name, 0, NULL,
                             &zone);
 
-       if (result != ISC_R_SUCCESS)
-#ifdef DLZ
-       {
+       if (result != ISC_R_SUCCESS) {
                /*
                 * Normal zone table does not have a match.
                 * Try the DLZ database
@@ -836,10 +830,8 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                                goto failure;
                        }
                        if (result != ISC_R_SUCCESS)
-#endif
-                       FAILQ(DNS_R_NOTAUTH, "non-authoritative zone",
-                                 question_name, question_class);
-#ifdef DLZ
+                               FAILQ(DNS_R_NOTAUTH, "non-authoritative zone",
+                                     question_name, question_class);
                        is_dlz = ISC_TRUE;
                        /*
                         * DLZ only support full zone transfer, not incremental
@@ -859,7 +851,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                }
        } else {
                /* zone table has a match */
-#endif
                switch(dns_zone_gettype(zone)) {
                        case dns_zone_master:
                        case dns_zone_slave:
@@ -870,9 +861,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                        }
                CHECK(dns_zone_getdb(zone, &db));
                dns_db_currentversion(db, &ver);
-#ifdef DLZ
        }
-#endif
 
        xfrout_log1(client, question_name, question_class, ISC_LOG_DEBUG(6),
                    "%s question section OK", mnemonic);
@@ -926,22 +915,15 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                    "%s authority section OK", mnemonic);
 
        /*
-        * Decide whether to allow this transfer.
-        */
-#ifdef DLZ
-       /*
-        * if not a DLZ zone decide whether to allow this transfer.
+        * If not a DLZ zone, decide whether to allow this transfer.
         */
        if (!is_dlz) {
-#endif
                ns_client_aclmsg("zone transfer", question_name, reqtype,
                                 client->view->rdclass, msg, sizeof(msg));
                CHECK(ns_client_checkacl(client, NULL, msg,
                                         dns_zone_getxfracl(zone),
                                         ISC_TRUE, ISC_LOG_ERROR));
-#ifdef DLZ
        }
-#endif
 
        /*
         * AXFR over UDP is not possible.
@@ -965,10 +947,9 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
        /*
         * Get a dynamically allocated copy of the current SOA.
         */
-#ifdef DLZ
        if (is_dlz)
                dns_db_currentversion(db, &ver);
-#endif
+
        CHECK(dns_db_createsoatuple(db, ver, mctx, DNS_DIFFOP_EXISTS,
                                    &current_soa_tuple));
 
@@ -1054,7 +1035,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
 
 
 
-#ifdef DLZ
        if (is_dlz)
                CHECK(xfrout_ctx_create(mctx, client, request->id,
                                        question_name, reqtype, question_class,
@@ -1067,7 +1047,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
                                        ISC_TRUE : ISC_FALSE,
                                        &xfr));
        else
-#endif
                CHECK(xfrout_ctx_create(mctx, client, request->id,
                                        question_name, reqtype, question_class,
                                        zone, db, ver, quota, stream,
index 7254eece047ba4b5b0b0545e6140971b78197300..8edae27d113970188069ae55ae52d0a6ec78a5ce 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: zoneconf.c,v 1.170 2011/01/06 23:47:00 tbox Exp $ */
+/* $Id: zoneconf.c,v 1.170.14.1 2011/03/10 04:29:15 each Exp $ */
 
 /*% */
 
@@ -1433,7 +1433,6 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig,
 }
 
 
-#ifdef DLZ
 /*
  * Set up a DLZ zone as writeable
  */
@@ -1455,7 +1454,6 @@ ns_zone_configure_writeable_dlz(dns_dlzdb_t *dlzdatabase, dns_zone_t *zone,
        dns_db_detach(&db);
        return result;
 }
-#endif
 
 isc_boolean_t
 ns_zone_reusable(dns_zone_t *zone, const cfg_obj_t *zconfig) {
index 6db22d1018a45075cc905c4d3915664d2a0cc4d9..3188beed12ce04b7b4e9f318566ba21b0a15d396 100644 (file)
@@ -13,7 +13,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.35 2011/01/13 04:59:24 tbox Exp $
+# $Id: Makefile.in,v 1.35.8.1 2011/03/10 04:29:16 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -21,7 +21,7 @@ top_srcdir =  @top_srcdir@
 
 @BIND9_MAKE_INCLUDES@
 
-SUBDIRS =      filter-aaaa lwresd rpz tkey
+SUBDIRS =      dlzexternal filter-aaaa lwresd rpz tkey
 TARGETS =
 
 @BIND9_MAKE_RULES@
diff --git a/bin/tests/system/dlzexternal/Makefile.in b/bin/tests/system/dlzexternal/Makefile.in
new file mode 100644 (file)
index 0000000..f320403
--- /dev/null
@@ -0,0 +1,58 @@
+# Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+# PERFORMANCE OF THIS SOFTWARE.
+
+# $Id: Makefile.in,v 1.1.4.2 2011/03/10 04:29:16 each Exp $
+
+srcdir =       @srcdir@
+VPATH =                @srcdir@
+top_srcdir =   @top_srcdir@
+
+@BIND9_VERSION@
+
+@BIND9_MAKE_INCLUDES@
+
+CINCLUDES =    ${DNS_INCLUDES} ${ISC_INCLUDES}
+CDEFINES =
+CWARNINGS =
+
+LIBS =         @LIBS@
+
+SO_TARGETS =    driver.@SO@
+TARGETS =      dlopen@EXEEXT@ @SO_TARGETS@
+
+SRCS =         dlopen.c driver.c
+
+DLOPENOBJS      = dlopen.@O@
+
+SO_OBJS         = driver.@O@
+SO_SRCS         = driver.c
+
+OBJS =          ${DLOPENOBJS}
+
+@BIND9_MAKE_RULES@
+
+CFLAGS =       @CFLAGS@ @SO_CFLAGS@
+
+dlopen@EXEEXT@: ${DLOPENOBJS}
+       ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} \
+               -o $@ ${DLOPENOBJS} ${LIBS}
+
+driver.@SO@: ${SO_OBJS}
+       @SO_LD@ -o $@ ${SO_OBJS}
+
+clean distclean::
+       rm -f ${TARGETS}
+
+distclean::
+       rm -f ns1/named.conf
diff --git a/bin/tests/system/dlzexternal/dlopen.c b/bin/tests/system/dlzexternal/dlopen.c
new file mode 100644 (file)
index 0000000..0f9802c
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* $Id: dlopen.c,v 1.1.4.2 2011/03/10 04:29:16 each Exp $ */
+
+#include <config.h>
+
+int
+main() {
+#if defined(HAVE_DLOPEN) && defined(ISC_DLZ_DLOPEN)
+       return (0);
+#else
+       return (1);
+#endif
+}
diff --git a/bin/tests/system/dlzexternal/driver.c b/bin/tests/system/dlzexternal/driver.c
new file mode 100644 (file)
index 0000000..6771299
--- /dev/null
@@ -0,0 +1,561 @@
+/*
+ * Copyright (C) 2010 Andrew Tridgell
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This provides a very simple example of an external loadable DLZ
+ * driver, with update support.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <isc/log.h>
+#include <isc/result.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+#include <dns/types.h>
+
+#include "driver.h"
+
+#ifdef WIN32
+#define strtok_r(a, b, c)      strtok_s(a, b, c)
+#endif
+
+/* For this simple example, use fixed sized strings */
+struct record {
+       char name[100];
+       char type[10];
+       char data[200];
+       dns_ttl_t ttl;
+};
+
+#define MAX_RECORDS 100
+
+struct dlz_example_data {
+       char *zone_name;
+
+       /* An example driver doesn't need good memory management :-) */
+       struct record current[MAX_RECORDS];
+       struct record adds[MAX_RECORDS];
+       struct record deletes[MAX_RECORDS];
+
+       isc_boolean_t transaction_started;
+
+       /* Helper functions from the dlz_dlopen driver */
+       void (*log)(int level, const char *fmt, ...);
+       isc_result_t (*putrr)(dns_sdlzlookup_t *handle, const char *type,
+                             dns_ttl_t ttl, const char *data);
+       isc_result_t (*putnamedrr)(dns_sdlzlookup_t *handle, const char *name,
+                                  const char *type, dns_ttl_t ttl,
+                                  const char *data);
+       isc_result_t (*writeable_zone)(dns_view_t *view, const char *zone_name);
+};
+
+static isc_boolean_t
+single_valued(const char *type) {
+       const char *single[] = { "soa", "cname", NULL };
+       int i;
+
+       for (i = 0; single[i]; i++) {
+               if (strcasecmp(single[i], type) == 0) {
+                       return (ISC_TRUE);
+               }
+       }
+       return (ISC_FALSE);
+}
+
+/*
+ * Add a record to a list
+ */
+static isc_result_t
+add_name(struct dlz_example_data *state, struct record *list,
+        const char *name, const char *type, dns_ttl_t ttl, const char *data)
+{
+       int i;
+       isc_boolean_t single = single_valued(type);
+       int first_empty = -1;
+
+       for (i = 0; i < MAX_RECORDS; i++) {
+               if (first_empty == -1 && strlen(list[i].name) == 0) {
+                       first_empty = i;
+               }
+               if (strcasecmp(list[i].name, name) != 0) 
+                       continue;
+               if (strcasecmp(list[i].type, type) != 0)
+                       continue;
+               if (!single && strcasecmp(list[i].data, data) != 0)
+                       continue;
+               break;
+       }
+       if (i == MAX_RECORDS && first_empty != -1) {
+               i = first_empty;
+       }
+       if (i == MAX_RECORDS) {
+               state->log(ISC_LOG_ERROR, "dlz_example: out of record space");
+               return (ISC_R_FAILURE);
+       }
+       strcpy(list[i].name, name);
+       strcpy(list[i].type, type);
+       strcpy(list[i].data, data);
+       list[i].ttl = ttl;
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Delete a record from a list
+ */
+static isc_result_t
+del_name(struct dlz_example_data *state, struct record *list,
+        const char *name, const char *type, dns_ttl_t ttl,
+        const char *data)
+{
+       int i;
+
+       UNUSED(state);
+
+       for (i = 0; i < MAX_RECORDS; i++) {
+               if (strcasecmp(name, list[i].name) == 0 &&
+                   strcasecmp(type, list[i].type) == 0 &&
+                   strcasecmp(data, list[i].data) == 0 &&
+                   ttl == list[i].ttl) {
+                       break;
+               }
+       }
+       if (i == MAX_RECORDS) {
+               return (ISC_R_NOTFOUND);
+       }
+       memset(&list[i], 0, sizeof(struct record));
+       return (ISC_R_SUCCESS);
+}
+
+
+
+/*
+ * Return the version of the API
+ */
+int
+dlz_version(unsigned int *flags) {
+       UNUSED(flags);
+       return (DLZ_DLOPEN_VERSION);
+}
+
+/*
+ * Remember a helper function from the bind9 dlz_dlopen driver
+ */
+static void
+b9_add_helper(struct dlz_example_data *state,
+             const char *helper_name, void *ptr)
+{
+       if (strcmp(helper_name, "log") == 0)
+               state->log = ptr;
+       if (strcmp(helper_name, "putrr") == 0)
+               state->putrr = ptr;
+       if (strcmp(helper_name, "putnamedrr") == 0)
+               state->putnamedrr = ptr;
+       if (strcmp(helper_name, "writeable_zone") == 0)
+               state->writeable_zone = ptr;
+}
+
+
+/*
+ * Called to initialize the driver
+ */
+isc_result_t
+dlz_create(const char *dlzname, unsigned int argc, char *argv[],
+          void **dbdata, ...)
+{
+       struct dlz_example_data *state;
+       const char *helper_name;
+       va_list ap;
+       char soa_data[200];
+
+       UNUSED(dlzname);
+
+       state = calloc(1, sizeof(struct dlz_example_data));
+       if (state == NULL)
+               return (ISC_R_NOMEMORY);
+
+       /* Fill in the helper functions */
+       va_start(ap, dbdata);
+       while ((helper_name = va_arg(ap, const char *)) != NULL) {
+               b9_add_helper(state, helper_name, va_arg(ap, void*));
+       }
+       va_end(ap);
+
+       if (argc < 2) {
+               state->log(ISC_LOG_ERROR,
+                          "dlz_example: please specify a zone name");
+               return (ISC_R_FAILURE);
+       }
+
+       state->zone_name = strdup(argv[1]);
+
+       sprintf(soa_data, "%s hostmaster.%s 123 900 600 86400 3600",
+               state->zone_name, state->zone_name);
+
+       add_name(state, &state->current[0], state->zone_name,
+                "soa", 3600, soa_data);
+       add_name(state, &state->current[0], state->zone_name,
+                "ns", 3600, state->zone_name);
+       add_name(state, &state->current[0], state->zone_name,
+                "a", 1800, "10.53.0.1");
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: started for zone %s",
+                  state->zone_name);
+
+       *dbdata = state;
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Shut down the backend
+ */
+void
+dlz_destroy(void *dbdata) {
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: shutting down zone %s",
+                  state->zone_name);
+       free(state->zone_name);
+       free(state);
+}
+
+
+/*
+ * See if we handle a given zone
+ */
+isc_result_t
+dlz_findzonedb(void *dbdata, const char *name) {
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (strcasecmp(state->zone_name, name) == 0)
+               return (ISC_R_SUCCESS);
+
+       return (ISC_R_NOTFOUND);
+}
+
+
+
+/*
+ * Look up one record
+ */
+isc_result_t
+dlz_lookup(const char *zone, const char *name, void *dbdata,
+          dns_sdlzlookup_t *lookup)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+       isc_boolean_t found = ISC_FALSE;
+       char full_name[100];
+       int i;
+
+       UNUSED(zone);
+       
+       if (strcmp(name, "@") == 0)
+               strcpy(full_name, state->zone_name);
+       else
+               sprintf(full_name, "%s.%s", name, state->zone_name);
+
+       for (i = 0; i < MAX_RECORDS; i++) {
+               if (strcasecmp(state->current[i].name, full_name) == 0) {
+                       isc_result_t result;
+                       found = ISC_TRUE;
+                       result = state->putrr(lookup, state->current[i].type, 
+                                             state->current[i].ttl,
+                                             state->current[i].data);
+                       if (result != ISC_R_SUCCESS) {
+                               return (result);
+                       }
+               }
+       }
+
+       if (!found)
+               return (ISC_R_NOTFOUND);
+       return (ISC_R_SUCCESS);
+}
+
+
+/*
+ * See if a zone transfer is allowed
+ */
+isc_result_t
+dlz_allowzonexfr(void *dbdata, const char *name, const char *client) {
+       UNUSED(client);
+
+       /* Just say yes for all our zones */
+       return (dlz_findzonedb(dbdata, name));
+}
+
+/*
+ * Perform a zone transfer
+ */
+isc_result_t
+dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes) {
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+       int i;
+
+       UNUSED(zone);
+
+       for (i = 0; i < MAX_RECORDS; i++) {
+               isc_result_t result;
+               if (strlen(state->current[i].name) == 0) {
+                       continue;
+               }
+               result = state->putnamedrr(allnodes, state->current[i].name,
+                                          state->current[i].type,
+                                          state->current[i].ttl,
+                                          state->current[i].data);
+               if (result != ISC_R_SUCCESS)
+                       return (result);
+       }
+
+       return (ISC_R_SUCCESS);
+}
+
+
+/*
+ * Start a transaction
+ */
+isc_result_t
+dlz_newversion(const char *zone, void *dbdata, void **versionp) {
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (state->transaction_started) {
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: transaction already "
+                          "started for zone %s", zone);
+               return (ISC_R_FAILURE);
+       }
+
+       state->transaction_started = ISC_TRUE;
+       *versionp = (void *) &state->transaction_started;
+
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * End a transaction
+ */
+void
+dlz_closeversion(const char *zone, isc_boolean_t commit,
+                void *dbdata, void **versionp)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (!state->transaction_started) {
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: transaction not started for zone %s",
+                          zone);
+               *versionp = NULL;
+               return;
+       }
+
+       state->transaction_started = ISC_FALSE;
+
+       *versionp = NULL;
+
+       if (commit) {
+               int i;
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: committing transaction on zone %s",
+                          zone);
+               for (i = 0; i < MAX_RECORDS; i++) {
+                       if (strlen(state->adds[i].name) > 0) {
+                               add_name(state, &state->current[0], 
+                                        state->adds[i].name, 
+                                        state->adds[i].type, 
+                                        state->adds[i].ttl, 
+                                        state->adds[i].data);
+                       }
+               }
+               for (i = 0; i < MAX_RECORDS; i++) {
+                       if (strlen(state->deletes[i].name) > 0) {
+                               del_name(state, &state->current[0], 
+                                        state->deletes[i].name, 
+                                        state->deletes[i].type, 
+                                        state->deletes[i].ttl, 
+                                        state->deletes[i].data);
+                       }
+               }
+       } else {
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: cancelling transaction on zone %s",
+                          zone);
+       }
+       memset(state->adds, 0, sizeof(state->adds));
+       memset(state->deletes, 0, sizeof(state->deletes));
+}
+
+
+/*
+ * Configure a writeable zone
+ */
+isc_result_t
+dlz_configure(dns_view_t *view, void *dbdata) {
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+       isc_result_t result;
+
+
+       state->log(ISC_LOG_INFO, "dlz_example: starting configure");
+       if (state->writeable_zone == NULL) {
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: no writeable_zone method available");
+               return (ISC_R_FAILURE);
+       }
+
+       result = state->writeable_zone(view, state->zone_name);
+       if (result != ISC_R_SUCCESS) {
+               state->log(ISC_LOG_ERROR,
+                          "dlz_example: failed to configure zone %s",
+                          state->zone_name);
+               return (result);
+       }
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: configured writeable zone %s",
+                  state->zone_name);
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Authorize a zone update
+ */
+isc_boolean_t
+dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
+            const char *type, const char *key, isc_uint32_t keydatalen,
+            unsigned char *keydata, void *dbdata)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       UNUSED(tcpaddr);
+       UNUSED(type);
+       UNUSED(key);
+       UNUSED(keydatalen);
+       UNUSED(keydata);
+
+       if (strncmp(name, "deny.", 5) == 0) {
+               state->log(ISC_LOG_INFO,
+                          "dlz_example: denying update of name=%s by %s", 
+                          name, signer);
+               return (ISC_FALSE);
+       }
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: allowing update of name=%s by %s", 
+                  name, signer);
+       return (ISC_TRUE);
+}
+
+
+static isc_result_t
+modrdataset(struct dlz_example_data *state, const char *name,
+           const char *rdatastr, struct record *list)
+{
+       char *full_name, *dclass, *type, *data, *ttlstr;
+       char *buf = strdup(rdatastr);
+       isc_result_t result;
+       char *saveptr = NULL;
+
+       /*
+        * The format is:
+        * FULLNAME\tTTL\tDCLASS\tTYPE\tDATA
+        *
+        * The DATA field is space separated, and is in the data format
+        * for the type used by dig
+        */
+
+       full_name = strtok_r(buf, "\t", &saveptr);
+       if (full_name == NULL)
+               return (ISC_R_FAILURE);
+
+       ttlstr = strtok_r(NULL, "\t", &saveptr);
+       if (ttlstr == NULL)
+               return (ISC_R_FAILURE);
+
+       dclass = strtok_r(NULL, "\t", &saveptr);
+       if (dclass == NULL)
+               return (ISC_R_FAILURE);
+
+       type = strtok_r(NULL, "\t", &saveptr);
+       if (type == NULL)
+               return (ISC_R_FAILURE);
+
+       data = strtok_r(NULL, "\t", &saveptr);
+       if (data == NULL)
+               return (ISC_R_FAILURE);
+
+       result = add_name(state, list, name, type,
+                         strtoul(ttlstr, NULL, 10), data);
+       free(buf);
+       return (result);
+}
+
+
+isc_result_t
+dlz_addrdataset(const char *name, const char *rdatastr,
+               void *dbdata, void *version)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (version != (void *) &state->transaction_started)
+               return (ISC_R_FAILURE);
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: adding rdataset %s '%s'",
+                  name, rdatastr);
+
+       return (modrdataset(state, name, rdatastr, &state->adds[0]));
+}
+
+isc_result_t
+dlz_subrdataset(const char *name, const char *rdatastr,
+               void *dbdata, void *version)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (version != (void *) &state->transaction_started)
+               return (ISC_R_FAILURE);
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: subtracting rdataset %s '%s'",
+                  name, rdatastr);
+                  
+       return (modrdataset(state, name, rdatastr, &state->deletes[0]));
+}
+
+
+isc_result_t
+dlz_delrdataset(const char *name, const char *type,
+               void *dbdata, void *version)
+{
+       struct dlz_example_data *state = (struct dlz_example_data *)dbdata;
+
+       if (version != (void *) &state->transaction_started)
+               return (ISC_R_FAILURE);
+
+       state->log(ISC_LOG_INFO,
+                  "dlz_example: deleting rdataset %s of type %s",
+                  name, type);
+                  
+       return (ISC_R_SUCCESS);
+}
diff --git a/bin/tests/system/dlzexternal/driver.h b/bin/tests/system/dlzexternal/driver.h
new file mode 100644 (file)
index 0000000..2d9d716
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * Copyright (C) 2011  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * Written by Andrew Tridgell.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
+ * USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * This header provides a minimal set of defines and typedefs needed
+ * for building an external DLZ module for bind9. When creating a new
+ * external DLZ driver, please copy this header into your own source
+ * tree.
+ */
+
+#define DLZ_DLOPEN_VERSION 1
+
+/* Return this in flags to dlz_version() if thread safe */
+#define DNS_SDLZFLAG_THREADSAFE                0x00000001U
+
+#if 0
+/* Result codes */
+#define ISC_R_SUCCESS                  0
+#define ISC_R_NOMEMORY                 1
+#define ISC_R_NOTFOUND                 23
+#define ISC_R_FAILURE                  25
+
+/* Log levels */
+#define ISC_LOG_INFO           (-1)
+#define ISC_LOG_NOTICE         (-2)
+#define ISC_LOG_WARNING        (-3)
+#define ISC_LOG_ERROR          (-4)
+#define ISC_LOG_CRITICAL       (-5)
+#endif
+
+/* Some opaque structures */
+typedef void *dns_sdlzlookup_t;
+typedef void *dns_sdlzallnodes_t;
+
+/*
+ * dlz_version() is required for all DLZ external drivers. It should
+ * return DLZ_DLOPEN_VERSION
+ */
+int
+dlz_version(unsigned int *flags);
+
+/*
+ * dlz_create() is required for all DLZ external drivers.
+ */
+isc_result_t
+dlz_create(const char *dlzname, unsigned int argc,
+                  char *argv[], void **dbdata, ...);
+
+/*
+ * dlz_destroy() is optional, and will be called when the driver is
+ * unloaded if supplied
+ */
+void
+dlz_destroy(void *dbdata);
+
+/*
+ * dlz_findzonedb is required for all DLZ external drivers
+ */
+isc_result_t
+dlz_findzonedb(void *dbdata, const char *name);
+
+/*
+ * dlz_lookup is required for all DLZ external drivers
+ */
+isc_result_t
+dlz_lookup(const char *zone, const char *name,
+                  void *dbdata, dns_sdlzlookup_t *lookup);
+
+/*
+ * dlz_allowzonexfr() is optional, and should be supplied if you want
+ * to support zone transfers
+ */
+isc_result_t
+dlz_allowzonexfr(void *dbdata, const char *name, const char *client);
+
+/*
+ * dlz_allnodes() is optional, but must be supplied if supply a
+ * dlz_allowzonexfr() function
+ */
+isc_result_t
+dlz_allnodes(const char *zone, void *dbdata, dns_sdlzallnodes_t *allnodes);
+
+/*
+ * dlz_newversion() is optional. It should be supplied if you want to
+ * support dynamic updates.
+ */
+isc_result_t
+dlz_newversion(const char *zone, void *dbdata, void **versionp);
+
+/* 
+ *  dlz_closeversion() is optional, but must be supplied if you supply
+ *  a dlz_newversion() function
+ */
+void
+dlz_closeversion(const char *zone, isc_boolean_t commit,
+                                void *dbdata, void **versionp);
+
+/*
+ * dlz_configure() is optional, but must be supplied if you want to
+ * support dynamic updates
+ */
+isc_result_t
+dlz_configure(dns_view_t *view, void *dbdata);
+
+/*
+ * dlz_ssumatch() is optional, but must be supplied if you want to
+ * support dynamic updates
+ */
+isc_boolean_t
+dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
+                        const char *type, const char *key, isc_uint32_t keydatalen,
+                        unsigned char *keydata, void *dbdata);
+
+/*
+ * dlz_addrdataset() is optional, but must be supplied if you want to
+ * support dynamic updates
+ */
+isc_result_t
+dlz_addrdataset(const char *name, const char *rdatastr,
+                               void *dbdata, void *version);
+
+/*
+ * dlz_subrdataset() is optional, but must be supplied if you want to
+ * support dynamic updates
+ */
+isc_result_t
+dlz_subrdataset(const char *name, const char *rdatastr,
+                               void *dbdata, void *version);
+
+/*
+ * dlz_delrdataset() is optional, but must be supplied if you want to
+ * support dynamic updates
+ */
+isc_result_t
+dlz_delrdataset(const char *name, const char *type,
+                               void *dbdata, void *version);
similarity index 89%
rename from bin/tests/system/dlzexternal/ns1/named.conf
rename to bin/tests/system/dlzexternal/ns1/named.conf.in
index 0bb7bcfb3b9f3618dc6ae52bd660528e7b45dbc5..c0fb2bbd47de204ae752a92ae961abda0d8fd52a 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: named.conf,v 1.3 2010/12/20 23:47:20 tbox Exp $ */
+/* $Id: named.conf.in,v 1.1.4.2 2011/03/10 04:29:17 each Exp $ */
 
 controls { };
 
@@ -43,5 +43,5 @@ controls {
 };
 
 dlz "example zone" {
-       database "dlopen ../../../../../contrib/dlz/example/dlz_example.so example.nil";
+       database "dlopen ../driver.@SO@ example.nil";
 };
index fa1727d85ed22197506e66471d6c1c696fe5ab56..a2625ab2611eaa3a428da2ec555907c12a068858 100644 (file)
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: prereq.sh,v 1.4 2010/12/20 23:47:20 tbox Exp $
+# $Id: prereq.sh,v 1.4.14.1 2011/03/10 04:29:16 each Exp $
 
 TOP=${SYSTEMTESTTOP:=.}/../../../..
 
-# enable the dlzexternal test only if it builds and dlz-dlopen was enabled
-$TOP/bin/named/named -V | grep with.dlz.dlopen | grep -v with.dlz.dlopen=no > /dev/null || {
-    echo "I:not built with --with-dlz-dlopen=yes - skipping dlzexternal test"
-    exit 255
-}
-
-cd ../../../../contrib/dlz/example && make all > /dev/null || {
-    echo "I:build of dlz_example.so failed - skipping dlzexternal test"
-    exit 1
+./dlopen ||  {
+        echo "I:dlopen() not supported - skipping dlzexternal test"
+        exit 1
 }
 exit 0
-
-
index cf31d378a7f77ca40f5378ab9860cf936a194918..e8a46f9c9bd1ce5c311933fa8c0ded7cbcbddf6f 100644 (file)
@@ -13,32 +13,43 @@ test_update() {
     type="$2"
     cmd="$3"
     digout="$4"
+    should_fail="$5"
 
     cat <<EOF > ns1/update.txt
 server 10.53.0.1 5300
 update add $host $cmd
 send
 EOF
-    echo "I:testing update for $host $type $cmd"
-    $NSUPDATE -k ns1/ddns.key ns1/update.txt || {
-       echo "I:update failed for $host $type $cmd"
+
+    echo "I:testing update for $host $type $cmd $comment"
+    $NSUPDATE -k ns1/ddns.key ns1/update.txt > /dev/null 2>&1 || {
+       [ "$should_fail" ] || \
+             echo "I:update failed for $host $type $cmd"
        return 1
     }
 
-    out=`$DIG $DIGOPTS -t $type -q $host | egrep ^$host`
+    out=`$DIG $DIGOPTS -t $type -q $host | egrep "^$host"`
     lines=`echo "$out" | grep "$digout" | wc -l`
     [ $lines -eq 1 ] || {
-       echo "I:dig output incorrect for $host $type $cmd: $out"
+       [ "$should_fail" ] || \
+            echo "I:dig output incorrect for $host $type $cmd: $out"
        return 1
     }
     return 0
 }
 
-test_update testdc1.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || status=1
-test_update testdc2.example.nil. A "86400 A 10.53.0.11" "10.53.0.11" || status=1
-test_update testdc3.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || status=1
-test_update deny.example.nil. TXT "86400 TXT helloworld" "helloworld" && status=1
+ret=0
+
+test_update testdc1.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
+status=`expr $status + $ret`
+
+test_update testdc2.example.nil. A "86400 A 10.53.0.11" "10.53.0.11" || ret=1
+status=`expr $status + $ret`
+
+test_update testdc3.example.nil. A "86400 A 10.53.0.10" "10.53.0.10" || ret=1
+status=`expr $status + $ret`
 
-[ $status -eq 0 ] && echo "I:dlzexternal tests all OK"
+test_update deny.example.nil. TXT "86400 TXT helloworld" "helloworld" should_fail && ret=1
+status=`expr $status + $ret`
 
 exit $status
index fb4c0d9637333172b0fad7cebac59f12df6331a1..f6f63d56a90acf8c26c05d6d66b9e6e91e1abc4b 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: named.conf,v 1.2.4.2 2011/03/04 15:06:45 smann Exp $ */
+/* $Id: named.conf,v 1.2.4.3 2011/03/10 04:29:17 each Exp $ */
 
 options {
         query-source address 10.53.0.1;
index 9fdc9da605657dc75f90408653ade03a7990a4bd..dac1dfbb5d96f3b795b552aff283a18a9b5b13e7 100644 (file)
@@ -16,7 +16,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: config.h.in,v 1.143.8.3 2011/02/27 13:30:04 marka Exp $ */
+/* $Id: config.h.in,v 1.143.8.4 2011/03/10 04:29:14 each Exp $ */
 
 /*! \file */
 
@@ -144,9 +144,6 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define if threads need PTHREAD_SCOPE_SYSTEM */
 #undef NEED_PTHREAD_SCOPE_SYSTEM
 
-/* Define if building universal (internal helper macro) */
-#undef AC_APPLE_UNIVERSAL_BUILD
-
 /* Define to enable the "filter-aaaa-on-v4" option. */
 #undef ALLOW_FILTER_AAAA_ON_V4
 
@@ -244,9 +241,6 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to 1 if you have the `c_r' library (-lc_r). */
 #undef HAVE_LIBC_R
 
-/* Define to 1 if you have the `dl' library (-ldl). */
-#undef HAVE_LIBDL
-
 /* Define to 1 if you have the `nsl' library (-lnsl). */
 #undef HAVE_LIBNSL
 
@@ -364,6 +358,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to the flags type used by getnameinfo(3). */
 #undef IRS_GETNAMEINFO_FLAGS_T
 
+/* Define to allow building of objects for dlopen(). */
+#undef ISC_DLZ_DLOPEN
+
 /* Defined if extern char *optarg is not declared. */
 #undef NEED_OPTARG
 
@@ -383,9 +380,6 @@ int sigwait(const unsigned int *set, int *sig);
 /* Define to the one symbol short name of this package. */
 #undef PACKAGE_TARNAME
 
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
@@ -406,17 +400,9 @@ int sigwait(const unsigned int *set, int *sig);
 /* define if idnkit support is to be included. */
 #undef WITH_IDN
 
-/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel). */
-#if defined AC_APPLE_UNIVERSAL_BUILD
-# if defined __BIG_ENDIAN__
-#  define WORDS_BIGENDIAN 1
-# endif
-#else
-# ifndef WORDS_BIGENDIAN
-#  undef WORDS_BIGENDIAN
-# endif
-#endif
+/* Define to 1 if your processor stores words with the most significant byte
+   first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
 
 /* Define to empty if `const' does not conform to ANSI C. */
 #undef const
index 5fafe2c8b4c3bb602580ea427e3ef84b3698ac39..ad0e6fcd2545cdb75e3b65afefbabed0e4897bf3 100644 (file)
@@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl
 esyscmd([sed "s/^/# /" COPYRIGHT])dnl
 AC_DIVERT_POP()dnl
 
-AC_REVISION($Revision: 1.512.8.6 $)
+AC_REVISION($Revision: 1.512.8.7 $)
 
 AC_INIT(lib/dns/name.c)
 AC_PREREQ(2.59)
@@ -3141,28 +3141,95 @@ LIBIRS_API=$srcdir/lib/irs/api
 # Configure any DLZ drivers.
 #
 # If config.dlz.in selects one or more DLZ drivers, it will set
-# USE_DLZ to a non-empty value, which will be our clue to
-# enable the DLZ core functions.
+# CONTRIB_DLZ to a non-empty value, which will be our clue to
+# build DLZ drivers in contrib.
 #
 # This section has to come after the libtool stuff because it needs to
 # know how to name the driver object files.
 #
 
-USE_DLZ=""
+CONTRIB_DLZ=""
 DLZ_DRIVER_INCLUDES=""
 DLZ_DRIVER_LIBS=""
 DLZ_DRIVER_SRCS=""
 DLZ_DRIVER_OBJS=""
 DLZ_SYSTEM_TEST=""
 
-sinclude(contrib/dlz/config.dlz.in)
+# 
+# Configure support for building a shared library object
+#
+# Even when libtool is available it can't always be relied upon
+# to build an object that can be dlopen()'ed, but this is necessary
+# for building the dlzexternal system test, so we'll try it the
+# old-fashioned way.
+#
+SO="so"
+SO_CFLAGS=""
+SO_LD=""
+SO_TARGETS=""
+
+AC_ARG_WITH(dlopen,
+       [  --with-dlopen=ARG       Support dynamically loadable DLZ drivers],
+       dlopen="$withval", dlopen="yes")
+
+if test "$dlopen" = "yes"; then
+        AC_CHECK_LIB(dl, dlclose, have_dl=yes, have_dl=no)
+        AC_CHECK_FUNCS(dlopen dlclose dlsym,,dlopen=no)
+fi
+
+if test "$dlopen" = "yes"; then
+       case $host in
+               *-linux*)
+                       SO_CFLAGS="-fPIC"
+                       if test "$have_dl" = "yes"
+                       then
+                               SO_LD="${CC} -shared"
+                       else
+                               SO_LD="ld -shared"
+                       fi
+                       ;;
+               *-freebsd*|*-openbsd*|*-netbsd*)
+                       SO_CFLAGS="-fpic"
+                       SO_LD="ld -Bshareable -x"
+                       ;;
+               *-solaris*)
+                       SO_CFLAGS="-KPIC"
+                       SO_LD="ld -G -z text"
+                        ;;
+               *-hp-hpux*)
+                       SO=sl
+                       SO_CFLAGS="+z"
+                       SO_LD="ld -b"
+                        ;;
+               *)
+                       SO_CFLAGS="-fPIC"
+                       ;;
+       esac
+
+       if test "X$GCC" = "Xyes"; then
+               SO_CFLAGS="-fPIC"
+                test -n "$SO_LD" || SO_LD="${CC} -shared"
+       fi
 
-AC_MSG_CHECKING(for DLZ)
+       # If we still don't know how to make shared objects, don't make any.
+       if test -n "$SO_LD"; then
+               SO_TARGETS="\${SO_TARGETS}"
+               AC_DEFINE(ISC_DLZ_DLOPEN, 1,
+                         [Define to allow building of objects for dlopen().])
+       fi
+fi
+
+AC_SUBST(SO)
+AC_SUBST(SO_CFLAGS)
+AC_SUBST(SO_LD)
+AC_SUBST(SO_TARGETS)
+
+sinclude(contrib/dlz/config.dlz.in)
+AC_MSG_CHECKING(contributed DLZ drivers)
 
-if test -n "$USE_DLZ"
+if test -n "$CONTRIB_DLZ"
 then
        AC_MSG_RESULT(yes)
-       USE_DLZ="-DDLZ $USE_DLZ"
        DLZ_DRIVER_RULES=contrib/dlz/drivers/rules
        AC_CONFIG_FILES([$DLZ_DRIVER_RULES])
 else
@@ -3170,7 +3237,7 @@ else
        DLZ_DRIVER_RULES=/dev/null
 fi
 
-AC_SUBST(USE_DLZ)
+AC_SUBST(CONTRIB_DLZ)
 AC_SUBST(DLZ_DRIVER_INCLUDES)
 AC_SUBST(DLZ_DRIVER_LIBS)
 AC_SUBST(DLZ_DRIVER_SRCS)
@@ -3333,6 +3400,8 @@ AC_CONFIG_FILES([
        bin/tests/sockaddr/Makefile
        bin/tests/system/Makefile
        bin/tests/system/conf.sh
+       bin/tests/system/dlzexternal/Makefile
+       bin/tests/system/dlzexternal/ns1/named.conf
        bin/tests/system/filter-aaaa/Makefile
        bin/tests/system/gost/prereq.sh
        bin/tests/system/lwresd/Makefile
index 1fef2c7266f579f5b968218c95f7f29c73752c0f..790517a448eed5c17ff38d6d6a7ba2cd8feb9238 100644 (file)
@@ -13,7 +13,7 @@
 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.5 2009/12/05 23:31:40 each Exp $
+# $Id: Makefile.in,v 1.5.244.1 2011/03/10 04:29:17 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -28,7 +28,7 @@ DLZINCLUDES = @DLZ_DRIVER_INCLUDES@
 CINCLUDES =    -I${srcdir}/include -I${srcdir}/unix/include \
                 ${ISC_INCLUDES} ${DLZINCLUDES}
 
-CDEFINES =      @USE_DLZ@
+CDEFINES =      @CONTRIB_DLZ@
 CWARNINGS =
 
 DLZLIBS =      @DLZ_DRIVER_LIBS@
index a49e40b39bf85369e8247ca601523774d8020beb..a693b565663e15b17d561b5cbeb8087728d1b4bf 100644 (file)
@@ -29,7 +29,7 @@ dlzdir='${DLZ_DRIVER_DIR}'
 #   LIBS is any necessary library definitions
 #
 AC_DEFUN(DLZ_ADD_DRIVER, [
-       USE_DLZ="$USE_DLZ -DDLZ_$1"
+       CONTRIB_DLZ="$CONTRIB_DLZ -DDLZ_$1"
        for i in $2
        do
                DLZ_DRIVER_SRCS="$DLZ_DRIVER_SRCS $dlzdir/$i.c"
@@ -456,38 +456,16 @@ case "$use_dlz_stub" in
                ;;
 esac
 
-#
-# Was --with-dlz-dlopen specified?
-#
-
-AC_MSG_CHECKING(for dlopen DLZ driver)
-AC_ARG_WITH(dlz_dlopen,
-[  --with-dlz-dlopen[=PATH]   Build with dlopen DLZ driver [yes|no].
-                               (Required to use dlopen driver with DLZ)],
-    use_dlz_dlopen="$withval", use_dlz_dlopen="no")
-
-case "$use_dlz_dlopen" in
-       no)
-               AC_MSG_RESULT(no)
-               ;;
-       *)
-               AC_CHECK_LIB(dl, dlclose)
-               AC_CHECK_FUNCS(dlopen dlclose dlsym)
-               DLZ_ADD_DRIVER(DLOPEN, dlz_dlopen_driver)
-
-               AC_MSG_RESULT(yes)
-               ;;
-esac
-
-
 # Add any additional DLZ drivers here.
 
 #
 # Finally, some generic stuff that applies to all drivers, assuming
-# we're compiling DLZ at all.
+# we're compiling contrib DLZ drivers at all.
 #
-if test -n "$USE_DLZ"
+if test -n "$CONTRIB_DLZ"
 then
+        CONTRIB_DLZ="-DCONTRIB_DLZ $CONTRIB_DLZ"
+
        #
        # Where to find DLZ driver header files.
        #
index e70601584b656b22b794322678131f9af4d4b80f..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,624 +0,0 @@
-/*
- * Copyright (C) 2010 Andrew Tridgell
- *
- * based on dlz_stub_driver.c
- * which is:
- * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
- * Copyright (C) 1999-2001  Internet Software Consortium.
- * see dlz_stub_driver.c for details
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
- * USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
- * conceived and contributed by Rob Butler.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
- * USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifdef DLZ_DLOPEN
-
-#include <config.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <dlfcn.h>
-
-#include <dns/log.h>
-#include <dns/sdlz.h>
-#include <dns/result.h>
-
-#include <isc/mem.h>
-#include <isc/print.h>
-#include <isc/result.h>
-#include <isc/util.h>
-
-#include <named/globals.h>
-
-#include <dlz/dlz_dlopen_driver.h>
-
-static dns_sdlzimplementation_t *dlz_dlopen = NULL;
-
-
-typedef struct dlopen_data {
-       isc_mem_t *mctx;
-       char *dl_path;
-       char *dlzname;
-       void *dl_handle;
-       void *dbdata;
-       unsigned int flags;
-       isc_mutex_t lock;
-       int version;
-       isc_boolean_t in_configure;
-
-       int (*dlz_version)(unsigned int *flags);
-       isc_result_t (*dlz_create)(const char *dlzname,
-                                  unsigned int argc, char *argv[],
-                                  void **dbdata, ...);
-       isc_result_t (*dlz_findzonedb)(void *dbdata, const char *name);
-       isc_result_t (*dlz_lookup)(const char *zone, const char *name,
-                                  void *dbdata, dns_sdlzlookup_t *lookup);
-       isc_result_t (*dlz_authority)(const char *zone, void *dbdata,
-                                     dns_sdlzlookup_t *lookup);
-       isc_result_t (*dlz_allnodes)(const char *zone, void *dbdata,
-                                    dns_sdlzallnodes_t *allnodes);
-       isc_result_t (*dlz_allowzonexfr)(void *dbdata, const char *name,
-                                        const char *client);
-       isc_result_t (*dlz_newversion)(const char *zone, void *dbdata,
-                                      void **versionp);
-       void         (*dlz_closeversion)(const char *zone, isc_boolean_t commit,
-                                        void *dbdata, void **versionp);
-       isc_result_t (*dlz_configure)(dns_view_t *view, void *dbdata);
-       isc_boolean_t (*dlz_ssumatch)(const char *signer, const char *name,
-                                     const char *tcpaddr, const char *type,
-                                     const char *key, uint32_t keydatalen,
-                                     uint8_t *keydata, void *dbdata);
-       isc_result_t (*dlz_addrdataset)(const char *name, const char *rdatastr,
-                                       void *dbdata, void *version);
-       isc_result_t (*dlz_subrdataset)(const char *name, const char *rdatastr,
-                                       void *dbdata, void *version);
-       isc_result_t (*dlz_delrdataset)(const char *name, const char *type,
-                                       void *dbdata, void *version);
-       void         (*dlz_destroy)(void *dbdata);
-} dlopen_data_t;
-
-/* Modules can choose whether they are lock-safe or not. */
-#define MAYBE_LOCK(cd) \
-       do { \
-               if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
-                   cd->in_configure == ISC_FALSE) \
-                       LOCK(&cd->lock); \
-       } while (0)
-
-#define MAYBE_UNLOCK(cd) \
-       do { \
-               if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
-                   cd->in_configure == ISC_FALSE) \
-                       UNLOCK(&cd->lock); \
-       } while (0)
-
-/*
- * Log a message at the given level.
- */
-static void dlopen_log(int level, const char *fmt, ...)
-{
-       va_list ap;
-       va_start(ap, fmt);
-       isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE,
-                      DNS_LOGMODULE_DLZ, ISC_LOG_DEBUG(level),
-                      fmt, ap);
-       va_end(ap);
-}
-
-/*
- * SDLZ methods
- */
-
-static isc_result_t
-dlopen_dlz_allnodes(const char *zone, void *driverarg, void *dbdata,
-                   dns_sdlzallnodes_t *allnodes)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_allnodes == NULL) {
-               return (ISC_R_NOPERM);
-       }
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_allnodes(zone, cd->dbdata, allnodes);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-
-static isc_result_t
-dlopen_dlz_allowzonexfr(void *driverarg, void *dbdata, const char *name,
-                       const char *client)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-
-       if (cd->dlz_allowzonexfr == NULL) {
-               return (ISC_R_NOPERM);
-       }
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_allowzonexfr(cd->dbdata, name, client);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-static isc_result_t
-dlopen_dlz_authority(const char *zone, void *driverarg, void *dbdata,
-                  dns_sdlzlookup_t *lookup)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_authority == NULL) {
-               return (ISC_R_NOTIMPLEMENTED);
-       }
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_authority(zone, cd->dbdata, lookup);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-static isc_result_t
-dlopen_dlz_findzonedb(void *driverarg, void *dbdata, const char *name)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_findzonedb(cd->dbdata, name);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-
-static isc_result_t
-dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
-                 void *dbdata, dns_sdlzlookup_t *lookup)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_lookup(zone, name, cd->dbdata, lookup);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-/*
- * Load a symbol from the library
- */
-static void *
-dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory) {
-       void *ptr = dlsym(cd->dl_handle, symbol);
-       if (ptr == NULL && mandatory) {
-               dlopen_log(ISC_LOG_ERROR,
-                          "dlz_dlopen: library '%s' is missing "
-                          "required symbol '%s'", cd->dl_path, symbol);
-       }
-       return (ptr);
-}
-
-/*
- * Called at startup for each dlopen zone in named.conf
- */
-static isc_result_t
-dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
-                 void *driverarg, void **dbdata)
-{
-       dlopen_data_t *cd;
-       isc_mem_t *mctx = NULL;
-       isc_result_t result = ISC_R_FAILURE;
-       int dlopen_flags;
-
-       UNUSED(driverarg);
-
-       if (argc < 2) {
-               dlopen_log(ISC_LOG_ERROR,
-                          "dlz_dlopen driver for '%s' needs a path to "
-                          "the shared library", dlzname);
-               return (ISC_R_FAILURE);
-       }
-
-       isc_mem_create(0, 0, &mctx);
-
-       cd = isc_mem_get(mctx, sizeof(*cd));
-       if (cd == NULL) {
-               isc_mem_destroy(&mctx);
-               return (ISC_R_NOMEMORY);
-       }
-       memset(cd, 0, sizeof(*cd));
-
-       cd->mctx = mctx;
-
-       cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);
-       if (cd->dl_path == NULL) {
-               goto failed;
-       }
-
-       cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);
-       if (cd->dlzname == NULL) {
-               goto failed;
-       }
-
-       /* Open the library */
-       dlopen_flags = RTLD_NOW;
-
-#ifdef RTLD_DEEPBIND
-       /*
-        * If RTLD_DEEPBIND is available then use it. This can avoid
-        * issues with a module using a different version of a system
-        * library than one that bind9 uses. For example, bind9 may link
-        * to MIT kerberos, but the module may use Heimdal. If we don't
-        * use RTLD_DEEPBIND then we could end up with Heimdal functions
-        * calling MIT functions, which leads to bizarre results (usually
-        * a segfault).
-        */
-       dlopen_flags |= RTLD_DEEPBIND;
-#endif
-
-       cd->dl_handle = dlopen(cd->dl_path, dlopen_flags);
-       if (cd->dl_handle == NULL) {
-               dlopen_log(ISC_LOG_ERROR,
-                          "dlz_dlopen failed to open library '%s' - %s",
-                          cd->dl_path, dlerror());
-               goto failed;
-       }
-
-       /* Find the symbols */
-       cd->dlz_version      = dl_load_symbol(cd, "dlz_version", true);
-       cd->dlz_create       = dl_load_symbol(cd, "dlz_create", true);
-       cd->dlz_lookup       = dl_load_symbol(cd, "dlz_lookup", true);
-       cd->dlz_findzonedb   = dl_load_symbol(cd, "dlz_findzonedb", true);
-
-       if (cd->dlz_create == NULL || cd->dlz_lookup == NULL ||
-           cd->dlz_findzonedb == NULL)
-       {
-               /* We're missing a required symbol */
-               goto failed;
-       }
-
-       cd->dlz_allowzonexfr = dl_load_symbol(cd, "dlz_allowzonexfr", false);
-       cd->dlz_allnodes     = dl_load_symbol(cd, "dlz_allnodes",
-                                             cd->dlz_allowzonexfr != NULL);
-       cd->dlz_authority    = dl_load_symbol(cd, "dlz_authority", false);
-       cd->dlz_newversion   = dl_load_symbol(cd, "dlz_newversion", false);
-       cd->dlz_closeversion = dl_load_symbol(cd, "dlz_closeversion",
-                                             cd->dlz_newversion != NULL);
-       cd->dlz_configure    = dl_load_symbol(cd, "dlz_configure", false);
-       cd->dlz_ssumatch     = dl_load_symbol(cd, "dlz_ssumatch", false);
-       cd->dlz_addrdataset  = dl_load_symbol(cd, "dlz_addrdataset", false);
-       cd->dlz_subrdataset  = dl_load_symbol(cd, "dlz_subrdataset", false);
-       cd->dlz_delrdataset  = dl_load_symbol(cd, "dlz_delrdataset", false);
-
-       /* Check the version of the API is the same */
-       cd->version = cd->dlz_version(&cd->flags);
-       if (cd->version != DLZ_DLOPEN_VERSION) {
-               dlopen_log(ISC_LOG_ERROR,
-                          "dlz_dlopen: incorrect version %d "
-                          "should be %d in '%s'",
-                          cd->version, DLZ_DLOPEN_VERSION, cd->dl_path);
-               goto failed;
-       }
-
-       /*
-        * Call the library's create function. Note that this is an
-        * extended version of dlz create, with the addition of
-        * named function pointers for helper functions that the
-        * driver will need. This avoids the need for the backend to
-        * link the bind9 libraries
-        */
-       MAYBE_LOCK(cd);
-       result = cd->dlz_create(dlzname, argc-1, argv+1,
-                               &cd->dbdata,
-                               "log", dlopen_log,
-                               "putrr", dns_sdlz_putrr,
-                               "putnamedrr", dns_sdlz_putnamedrr,
-                               "writeable_zone", dns_dlz_writeablezone,
-                               NULL);
-       MAYBE_UNLOCK(cd);
-       if (result != ISC_R_SUCCESS)
-               goto failed;
-
-       *dbdata = cd;
-
-       return (ISC_R_SUCCESS);
-
-failed:
-       dlopen_log(ISC_LOG_ERROR, "dlz_dlopen of '%s' failed", dlzname);
-       if (cd->dl_path)
-               isc_mem_free(mctx, cd->dl_path);
-       if (cd->dlzname)
-               isc_mem_free(mctx, cd->dlzname);
-#ifdef HAVE_DLCLOSE
-       if (cd->dl_handle)
-               dlclose(cd->dl_handle);
-#endif
-       isc_mem_put(mctx, cd, sizeof(*cd));
-       isc_mem_destroy(&mctx);
-       return (result);
-}
-
-
-/*
- * Called when bind is shutting down
- */
-static void
-dlopen_dlz_destroy(void *driverarg, void *dbdata) {
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_mem_t *mctx;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_destroy) {
-               MAYBE_LOCK(cd);
-               cd->dlz_destroy(cd->dbdata);
-               MAYBE_UNLOCK(cd);
-       }
-
-       if (cd->dl_path)
-               isc_mem_free(cd->mctx, cd->dl_path);
-       if (cd->dlzname)
-               isc_mem_free(cd->mctx, cd->dlzname);
-#ifdef HAVE_DLCLOSE
-       if (cd->dl_handle)
-               dlclose(cd->dl_handle);
-#endif
-       mctx = cd->mctx;
-       isc_mem_put(mctx, cd, sizeof(*cd));
-       isc_mem_destroy(&mctx);
-}
-
-/*
- * Called to start a transaction
- */
-static isc_result_t
-dlopen_dlz_newversion(const char *zone, void *driverarg, void *dbdata,
-                     void **versionp)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_newversion == NULL)
-               return (ISC_R_NOTIMPLEMENTED);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_newversion(zone, cd->dbdata, versionp);
-       MAYBE_UNLOCK(cd);
-       return (result);
-}
-
-/*
- * Called to end a transaction
- */
-static void
-dlopen_dlz_closeversion(const char *zone, isc_boolean_t commit,
-                       void *driverarg, void *dbdata, void **versionp)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_newversion == NULL) {
-               *versionp = NULL;
-               return;
-       }
-
-       MAYBE_LOCK(cd);
-       cd->dlz_closeversion(zone, commit, cd->dbdata, versionp);
-       MAYBE_UNLOCK(cd);
-}
-
-/*
- * Called on startup to configure any writeable zones
- */
-static isc_result_t
-dlopen_dlz_configure(dns_view_t *view, void *driverarg, void *dbdata) {
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_configure == NULL)
-               return (ISC_R_SUCCESS);
-
-       MAYBE_LOCK(cd);
-       cd->in_configure = ISC_TRUE;
-       result = cd->dlz_configure(view, cd->dbdata);
-       cd->in_configure = ISC_FALSE;
-       MAYBE_UNLOCK(cd);
-
-       return (result);
-}
-
-
-/*
- * Check for authority to change a name
- */
-static isc_boolean_t
-dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
-                   const char *type, const char *key, uint32_t keydatalen,
-                   uint8_t *keydata, void *driverarg, void *dbdata)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_boolean_t ret;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_ssumatch == NULL)
-               return (ISC_FALSE);
-
-       MAYBE_LOCK(cd);
-       ret = cd->dlz_ssumatch(signer, name, tcpaddr, type, key, keydatalen,
-                              keydata, cd->dbdata);
-       MAYBE_UNLOCK(cd);
-
-       return (ret);
-}
-
-
-/*
- * Add an rdataset
- */
-static isc_result_t
-dlopen_dlz_addrdataset(const char *name, const char *rdatastr,
-                      void *driverarg, void *dbdata, void *version)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_addrdataset == NULL)
-               return (ISC_R_NOTIMPLEMENTED);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_addrdataset(name, rdatastr, cd->dbdata, version);
-       MAYBE_UNLOCK(cd);
-
-       return (result);
-}
-
-/*
- * Subtract an rdataset
- */
-static isc_result_t
-dlopen_dlz_subrdataset(const char *name, const char *rdatastr,
-                      void *driverarg, void *dbdata, void *version)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_subrdataset == NULL)
-               return (ISC_R_NOTIMPLEMENTED);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_subrdataset(name, rdatastr, cd->dbdata, version);
-       MAYBE_UNLOCK(cd);
-
-       return (result);
-}
-
-/*
-  delete a rdataset
- */
-static isc_result_t
-dlopen_dlz_delrdataset(const char *name, const char *type,
-                      void *driverarg, void *dbdata, void *version)
-{
-       dlopen_data_t *cd = (dlopen_data_t *) dbdata;
-       isc_result_t result;
-
-       UNUSED(driverarg);
-
-       if (cd->dlz_delrdataset == NULL)
-               return (ISC_R_NOTIMPLEMENTED);
-
-       MAYBE_LOCK(cd);
-       result = cd->dlz_delrdataset(name, type, cd->dbdata, version);
-       MAYBE_UNLOCK(cd);
-
-       return (result);
-}
-
-
-static dns_sdlzmethods_t dlz_dlopen_methods = {
-       dlopen_dlz_create,
-       dlopen_dlz_destroy,
-       dlopen_dlz_findzonedb,
-       dlopen_dlz_lookup,
-       dlopen_dlz_authority,
-       dlopen_dlz_allnodes,
-       dlopen_dlz_allowzonexfr,
-       dlopen_dlz_newversion,
-       dlopen_dlz_closeversion,
-       dlopen_dlz_configure,
-       dlopen_dlz_ssumatch,
-       dlopen_dlz_addrdataset,
-       dlopen_dlz_subrdataset,
-       dlopen_dlz_delrdataset
-};
-
-/*
- * Register driver with BIND
- */
-isc_result_t
-dlz_dlopen_init(void) {
-       isc_result_t result;
-
-       dlopen_log(2, "Registering DLZ_dlopen driver");
-
-       result = dns_sdlzregister("dlopen", &dlz_dlopen_methods, NULL,
-                                 DNS_SDLZFLAG_RELATIVEOWNER |
-                                 DNS_SDLZFLAG_THREADSAFE,
-                                 ns_g_mctx, &dlz_dlopen);
-
-       if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "dns_sdlzregister() failed: %s",
-                                isc_result_totext(result));
-               result = ISC_R_UNEXPECTED;
-       }
-
-       return (result);
-}
-
-
-/*
- * Unregister the driver
- */
-void
-dlz_dlopen_clear(void) {
-       dlopen_log(2, "Unregistering DLZ_dlopen driver");
-       if (dlz_dlopen != NULL)
-               dns_sdlzunregister(&dlz_dlopen);
-}
-
-#endif
index 568843760d9544ddb99d0bf4ca052c8fa7462df1..5e97bdc269233679a112954e4a8211c02b4fd977 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dlz_drivers.c,v 1.3 2010/12/18 01:56:20 each Exp $ */
+/* $Id: dlz_drivers.c,v 1.3.16.1 2011/03/10 04:29:17 each Exp $ */
 
 /*! \file */
 
 #include <dlz/dlz_odbc_driver.h>
 #endif
 
-#ifdef DLZ_DLOPEN
-#include <dlz/dlz_dlopen_driver.h>
-#endif
-
 /*%
  * Call init functions for all relevant DLZ drivers.
  */
@@ -119,12 +115,6 @@ dlz_drivers_init(void) {
                return (result);
 #endif
 
-#ifdef DLZ_DLOPEN
-       result = dlz_dlopen_init();
-       if (result != ISC_R_SUCCESS)
-               return (result);
-#endif
-
        return (result);
 }
 
@@ -164,8 +154,4 @@ dlz_drivers_clear(void) {
         dlz_odbc_clear();
 #endif
 
-#ifdef DLZ_DLOPEN
-        dlz_dlopen_clear();
-#endif
-
 }
index d155f315dc8ff862bb162729edff5fc81f61bb26..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2010 Andrew Tridgell
- *
- * based on dlz_stub_driver.h
- * which is:
- * Copyright (C) 2002 Stichting NLnet, Netherlands, stichting@nlnet.nl.
- * Copyright (C) 1999-2001  Internet Software Consortium.
- * see dlz_stub_driver.h for details
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * STICHTING NLNET BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
- * USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * The development of Dynamically Loadable Zones (DLZ) for Bind 9 was
- * conceived and contributed by Rob Butler.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the
- * above copyright notice and this permission notice appear in all
- * copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ROB BUTLER
- * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * ROB BUTLER BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE
- * USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#ifndef DLZ_DLOPEN_DRIVER_H
-#define DLZ_DLOPEN_DRIVER_H
-
-isc_result_t
-dlz_dlopen_init(void);
-
-void
-dlz_dlopen_clear(void);
-
-#define DLZ_DLOPEN_VERSION 1
-
-#endif
index bee0e466c0039449ffc08fbd8aaf26e41e370f0a..9befece85501f79aec413d6b57c25f9291f98e37 100644 (file)
@@ -13,7 +13,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.176.8.1 2011/02/26 02:36:45 each Exp $
+# $Id: Makefile.in,v 1.176.8.2 2011/03/10 04:29:17 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -97,6 +97,7 @@ DNSSRCS =     acache.c acl.c adb.c byaddr.c \
                stats.c tcpmsg.c time.c timer.c tkey.c \
                tsec.c tsig.c ttl.c validator.c \
                version.c view.c xfrin.c zone.c zonekey.c zt.c ${OTHERSRCS}
+
 SRCS = ${DSTSRCS} ${DNSSRCS}
 
 SUBDIRS =      include
index 83a1cf62e299c647738a06f9960fbc744a1090c8..a3d96a72c4e1800bf45e3dc4c7323f06e1a1c8cb 100644 (file)
@@ -185,12 +185,14 @@ dns_dispatchmgr_setblackhole
 dns_dispatchmgr_setblackportlist
 dns_dispatchmgr_setstats
 dns_dlzallowzonexfr
+dns_dlzconfigure
 dns_dlzcreate
 dns_dlzdestroy
 dns_dlzfindzone
 dns_dlzregister
 dns_dlzstrtoargv
 dns_dlzunregister
+dns_dlz_writeablezone
 dns_dns64_aaaafroma
 dns_dns64_aaaaok
 dns_dns64_append
@@ -389,6 +391,7 @@ dns_name_tostring
 dns_name_totext
 dns_name_towire
 dns_ncache_add
+dns_ncache_current
 dns_ncache_getrdataset
 dns_ncache_towire
 dns_nsec3_active
@@ -598,6 +601,7 @@ dns_resolver_resetmustbesecure
 dns_resolver_setclientsperquery
 dns_resolver_setlamettl
 dns_resolver_setmustbesecure
+dns_resolver_settimeout
 dns_resolver_setudpsize
 dns_resolver_setzeronosoattl
 dns_resolver_shutdown
@@ -636,6 +640,7 @@ dns_sdb_unregister
 dns_sdlz_putnamedrr
 dns_sdlz_putrr
 dns_sdlz_putsoa
+dns_sdlz_setdb
 dns_sdlzregister
 dns_sdlzunregister
 dns_secalg_format
@@ -758,6 +763,7 @@ dns_zone_clearxfracl
 dns_zone_create
 dns_zone_detach
 dns_zone_dialup
+dns_zone_dlzpostload
 dns_zone_dump
 dns_zone_dumptostream
 dns_zone_dumptostream2
index d7f23c8fe7454f292840eab61b49e9e0dc321c7d..966b7c62a2196a19fdad19662b04230506d9e9bf 100644 (file)
@@ -13,7 +13,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: Makefile.in,v 1.21.244.2 2011/02/28 01:20:04 tbox Exp $
+# $Id: Makefile.in,v 1.21.244.3 2011/03/10 04:29:18 each Exp $
 
 srcdir =       @srcdir@
 VPATH =                @srcdir@
@@ -27,7 +27,7 @@ top_srcdir =  @top_srcdir@
 
 CINCLUDES =    -I. ${DNS_INCLUDES} ${ISC_INCLUDES} ${ISCCFG_INCLUDES}
 
-CDEFINES =     @USE_DLZ@
+CDEFINES =
 CWARNINGS =
 
 ISCLIBS =      ../../lib/isc/libisc.@A@