[BACK]Return to dlz_dlopen_driver.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / mpl / bind / dist / bin / named / unix

File: [cvs.NetBSD.org] / src / external / mpl / bind / dist / bin / named / unix / Attic / dlz_dlopen_driver.c (download)

Revision 1.1.1.6 (vendor branch), Mon Aug 3 17:07:03 2020 UTC (3 years, 8 months ago) by christos
Branch: ISC
CVS Tags: bind-9-16-5
Changes since 1.1.1.5: +2 -2 lines

	--- 9.16.5 released ---

5458.	[bug]		Prevent a theoretically possible NULL dereference caused
			by a data race between zone_maintenance() and
			dns_zone_setview_helper(). [GL #1627]

5455.	[bug]		named could crash when cleaning dead nodes in
			lib/dns/rbtdb.c that were being reused. [GL #1968]

5454.	[bug]		Address a startup crash that occurred when the server
			was under load and the root zone had not yet been
			loaded. [GL #1862]

5453.	[bug]		named crashed on shutdown when a new rndc connection was
			received during shutdown. [GL #1747]

5452.	[bug]		The "blackhole" ACL was accidentally disabled for client
			queries. [GL #1936]

5451.	[func]		Add 'rndc dnssec -status' command. [GL #1612]

5449.	[bug]		Fix a socket shutdown race in netmgr udp. [GL #1938]

5448.	[bug]		Fix a race condition in isc__nm_tcpdns_send().
			[GL #1937]

5447.	[bug]		IPv6 addresses ending in "::" could break YAML
			parsing. A "0" is now appended to such addresses
			in YAML output from dig, mdig, delv, and dnstap-read.
			[GL #1952]

5446.	[bug]		The validator could fail to accept a properly signed
			RRset if an unsupported algorithm appeared earlier in
			the DNSKEY RRset than a supported algorithm. It could
			also stop if it detected a malformed public key.
			[GL #1689]

5444.	[bug]		'rndc dnstap -roll <value>' did not limit the number of
			saved files to <value>. [GL !3728]

5443.	[bug]		The "primary" and "secondary" keywords, when used
			as parameters for "check-names", were not
			processed correctly and were being ignored. [GL #1949]

5441.	[bug]		${LMDB_CFLAGS} was missing from make/includes.in.
			[GL #1955]

5440.	[test]		Properly handle missing kyua. [GL #1950]

5439.	[bug]		The DS RRset returned by dns_keynode_dsset() was used in
			a non-thread-safe manner. [GL #1926]

	--- 9.16.4 released ---

5438.	[bug]		Fix a race in TCP accepting code. [GL #1930]

5437.	[bug]		Fix a data race in lib/dns/resolver.c:log_formerr().
			[GL #1808]

5436.	[security]	It was possible to trigger an INSIST when determining
			whether a record would fit into a TCP message buffer.
			(CVE-2020-8618) [GL #1850]

5435.	[tests]		Add RFC 4592 responses examples to the wildcard system
			test. [GL #1718]

5434.	[security]	It was possible to trigger an INSIST in
			lib/dns/rbtdb.c:new_reference() with a particular zone
			content and query patterns. (CVE-2020-8619) [GL #1111]
			[GL #1718]

5431.	[func]		Reject DS records at the zone apex when loading
			master files. Log but otherwise ignore attempts to
			add DS records at the zone apex via UPDATE. [GL #1798]

5430.	[doc]		Update docs - with netmgr, a separate listening socket
			is created for each IPv6 interface (just as with IPv4).
			[GL #1782]

5428.	[bug]		Clean up GSSAPI resources in nsupdate only after taskmgr
			has been destroyed. Thanks to Petr Menšík. [GL !3316]

5426.	[bug]		Don't abort() when setting SO_INCOMING_CPU on the socket
			fails. [GL #1911]

5425.	[func]		The default value of "max-stale-ttl" has been changed
			from 1 week to 12 hours. [GL #1877]

5424.	[bug]		With KASP, when creating a successor key, the "goal"
			state of the current active key (predecessor) was not
			changed and thus never removed from the zone. [GL #1846]

5423.	[bug]		Fix a bug in keymgr_key_has_successor(): it incorrectly
			returned true if any other key in the keyring had a
			successor. [GL #1845]

5422.	[bug]		When using dnssec-policy, print correct key timing
			metadata. [GL #1843]

5421.	[bug]		Fix a race that could cause named to crash when looking
			up the nodename of an RBT node if the tree was modified.
			[GL #1857]

5420.	[bug]		Add missing isc_{mutex,conditional}_destroy() calls
			that caused a memory leak on FreeBSD. [GL #1893]

5418.	[bug]		delv failed to parse deprecated trusted-keys-style
			trust anchors. [GL #1860]

5416.	[bug]		Fix a lock order inversion in lib/isc/unix/socket.c.
			[GL #1859]

5415.	[test]		Address race in dnssec system test that led to
			test failures. [GL #1852]

5414.	[test]		Adjust time allowed for journal truncation to occur
			in nsupdate system test to avoid test failure.
			[GL #1855]

5413.	[test]		Address race in autosign system test that led to
			test failures. [GL #1852]

5412.	[bug]		'provide-ixfr no;' failed to return up-to-date responses
			when the serial was greater than or equal to the
			current serial. [GL #1714]

5411.	[cleanup]	TCP accept code has been refactored to use a single
			accept() and pass the accepted socket to child threads
			for processing. [GL !3320]

5409.	[performance]	When looking up NSEC3 data in a zone database, skip the
			check for empty non-terminal nodes; the NSEC3 tree does
			not have any. [GL #1834]

5408.	[protocol]	Print Extended DNS Errors if present in OPT record.
			[GL #1835]

5407.	[func]		Zone timers are now exported via statistics channel.
			Thanks to Paul Frieden, Verizon Media. [GL #1232]

5405.	[bug]		'named-checkconf -p' could include spurious text in
			server-addresses statements due to an uninitialized DSCP
			value. [GL #1812]

/*	$NetBSD: dlz_dlopen_driver.c,v 1.1.1.6 2020/08/03 17:07:03 christos Exp $	*/

/*
 * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * See the COPYRIGHT file distributed with this work for additional
 * information regarding copyright ownership.
 */

#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_DLFCN_H
#include <dlfcn.h>
#endif /* if HAVE_DLFCN_H */

#include <isc/mem.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/util.h>

#include <dns/dlz_dlopen.h>
#include <dns/log.h>
#include <dns/result.h>

#include <dlz/dlz_dlopen_driver.h>
#include <named/globals.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;
	bool in_configure;

	dlz_dlopen_version_t *dlz_version;
	dlz_dlopen_create_t *dlz_create;
	dlz_dlopen_findzonedb_t *dlz_findzonedb;
	dlz_dlopen_lookup_t *dlz_lookup;
	dlz_dlopen_authority_t *dlz_authority;
	dlz_dlopen_allnodes_t *dlz_allnodes;
	dlz_dlopen_allowzonexfr_t *dlz_allowzonexfr;
	dlz_dlopen_newversion_t *dlz_newversion;
	dlz_dlopen_closeversion_t *dlz_closeversion;
	dlz_dlopen_configure_t *dlz_configure;
	dlz_dlopen_ssumatch_t *dlz_ssumatch;
	dlz_dlopen_addrdataset_t *dlz_addrdataset;
	dlz_dlopen_subrdataset_t *dlz_subrdataset;
	dlz_dlopen_delrdataset_t *dlz_delrdataset;
	dlz_dlopen_destroy_t *dlz_destroy;
} 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)                            \
			LOCK(&cd->lock);                          \
	} while (0)

#define MAYBE_UNLOCK(cd)                                          \
	do {                                                      \
		if ((cd->flags & DNS_SDLZFLAG_THREADSAFE) == 0 && \
		    !cd->in_configure)                            \
			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,
		      dns_clientinfomethods_t *methods,
		      dns_clientinfo_t *clientinfo) {
	dlopen_data_t *cd = (dlopen_data_t *)dbdata;
	isc_result_t result;

	UNUSED(driverarg);

	MAYBE_LOCK(cd);
	result = cd->dlz_findzonedb(cd->dbdata, name, methods, clientinfo);
	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,
		  dns_clientinfomethods_t *methods,
		  dns_clientinfo_t *clientinfo) {
	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, methods,
				clientinfo);
	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 = 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(&mctx);

	cd = isc_mem_get(mctx, sizeof(*cd));
	memset(cd, 0, sizeof(*cd));

	cd->mctx = mctx;

	cd->dl_path = isc_mem_strdup(cd->mctx, argv[1]);

	cd->dlzname = isc_mem_strdup(cd->mctx, dlzname);

	/* Initialize the lock */
	isc_mutex_init(&cd->lock);

	/* Open the library */
	dlopen_flags = RTLD_NOW | RTLD_GLOBAL;

#if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__
	/*
	 * 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 /* if defined(RTLD_DEEPBIND) && !__SANITIZE_ADDRESS__ */

	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());
		result = ISC_R_FAILURE;
		goto failed;
	}

	/* Find the symbols */
	cd->dlz_version =
		(dlz_dlopen_version_t *)dl_load_symbol(cd, "dlz_version", true);
	cd->dlz_create = (dlz_dlopen_create_t *)dl_load_symbol(cd, "dlz_create",
							       true);
	cd->dlz_lookup = (dlz_dlopen_lookup_t *)dl_load_symbol(cd, "dlz_lookup",
							       true);
	cd->dlz_findzonedb = (dlz_dlopen_findzonedb_t *)dl_load_symbol(
		cd, "dlz_findzonedb", true);

	if (cd->dlz_create == NULL || cd->dlz_version == NULL ||
	    cd->dlz_lookup == NULL || cd->dlz_findzonedb == NULL)
	{
		/* We're missing a required symbol */
		result = ISC_R_FAILURE;
		goto failed;
	}

	cd->dlz_allowzonexfr = (dlz_dlopen_allowzonexfr_t *)dl_load_symbol(
		cd, "dlz_allowzonexfr", false);
	cd->dlz_allnodes = (dlz_dlopen_allnodes_t *)dl_load_symbol(
		cd, "dlz_allnodes", (cd->dlz_allowzonexfr != NULL));
	cd->dlz_authority = (dlz_dlopen_authority_t *)dl_load_symbol(
		cd, "dlz_authority", false);
	cd->dlz_newversion = (dlz_dlopen_newversion_t *)dl_load_symbol(
		cd, "dlz_newversion", false);
	cd->dlz_closeversion = (dlz_dlopen_closeversion_t *)dl_load_symbol(
		cd, "dlz_closeversion", (cd->dlz_newversion != NULL));
	cd->dlz_configure = (dlz_dlopen_configure_t *)dl_load_symbol(
		cd, "dlz_configure", false);
	cd->dlz_ssumatch = (dlz_dlopen_ssumatch_t *)dl_load_symbol(
		cd, "dlz_ssumatch", false);
	cd->dlz_addrdataset = (dlz_dlopen_addrdataset_t *)dl_load_symbol(
		cd, "dlz_addrdataset", false);
	cd->dlz_subrdataset = (dlz_dlopen_subrdataset_t *)dl_load_symbol(
		cd, "dlz_subrdataset", false);
	cd->dlz_delrdataset = (dlz_dlopen_delrdataset_t *)dl_load_symbol(
		cd, "dlz_delrdataset", false);
	cd->dlz_destroy = (dlz_dlopen_destroy_t *)dl_load_symbol(
		cd, "dlz_destroy", false);

	/* Check the version of the API is the same */
	cd->version = cd->dlz_version(&cd->flags);
	if (cd->version < (DLZ_DLOPEN_VERSION - DLZ_DLOPEN_AGE) ||
	    cd->version > DLZ_DLOPEN_VERSION)
	{
		dlopen_log(ISC_LOG_ERROR,
			   "dlz_dlopen: %s: incorrect driver API version %d, "
			   "requires %d",
			   cd->dl_path, cd->version, DLZ_DLOPEN_VERSION);
		result = ISC_R_FAILURE;
		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 != NULL) {
		isc_mem_free(mctx, cd->dl_path);
	}
	if (cd->dlzname != NULL) {
		isc_mem_free(mctx, cd->dlzname);
	}
	if (dlopen_flags != 0) {
		isc_mutex_destroy(&cd->lock);
	}
#ifdef HAVE_DLCLOSE
	if (cd->dl_handle) {
		dlclose(cd->dl_handle);
	}
#endif /* ifdef HAVE_DLCLOSE */
	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 /* ifdef HAVE_DLCLOSE */

	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, bool 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, dns_dlzdb_t *dlzdb, 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 = true;
	result = cd->dlz_configure(view, dlzdb, cd->dbdata);
	cd->in_configure = false;
	MAYBE_UNLOCK(cd);

	return (result);
}

/*
 * Check for authority to change a name.
 */
static bool
dlopen_dlz_ssumatch(const char *signer, const char *name, const char *tcpaddr,
		    const char *type, const char *key, uint32_t keydatalen,
		    unsigned char *keydata, void *driverarg, void *dbdata) {
	dlopen_data_t *cd = (dlopen_data_t *)dbdata;
	bool ret;

	UNUSED(driverarg);

	if (cd->dlz_ssumatch == NULL) {
		return (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 /* ifdef ISC_DLZ_DLOPEN */

/*
 * 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  /* ifndef ISC_DLZ_DLOPEN */
	isc_result_t result;

	dlopen_log(2, "Registering DLZ_dlopen driver");

	result = dns_sdlzregister("dlopen", &dlz_dlopen_methods, NULL,
				  DNS_SDLZFLAG_RELATIVEOWNER |
					  DNS_SDLZFLAG_RELATIVERDATA |
					  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 /* ifndef ISC_DLZ_DLOPEN */
}

/*
 * 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 /* ifdef ISC_DLZ_DLOPEN */
}