Commit 422009fe authored by Evan Hunt's avatar Evan Hunt

3066. [func] The DLZ "dlopen" driver is now built by default,

			no longer requiring a configure option.  To
			disable it, use "configure --without-dlopen".
                        Driver also supported on win32.  [RT #23467]
parent b53bd951
3066. [func] The DLZ "dlopen" driver is now built by default,
no longer requiring a configure option. To
disable it, use "configure --without-dlopen".
Driver also supported on win32. [RT #23467]
3065. [bug] RRSIG could have time stamps too far in the future.
[RT #23356]
......
......@@ -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.115 2011/03/10 04:36: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@
......
/*
* 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
......@@ -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.181 2011/03/10 04:36: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.
......@@ -81,10 +83,10 @@
*/
/* #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();
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: query.c,v 1.357 2011/02/23 23:47:19 tbox Exp $ */
/* $Id: query.c,v 1.358 2011/03/10 04:36:14 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
*/
......@@ -5293,17 +5284,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;
......@@ -5971,9 +5958,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));
......
......@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: server.c,v 1.606 2011/03/03 16:16:43 each Exp $ */
/* $Id: server.c,v 1.607 2011/03/10 04:36:14 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
......
......@@ -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.14 2011/03/10 04:36:14 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}
......
/*
* 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);