From 422009fe5b15e31e7f5d09212bd1480121a1464e Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Thu, 10 Mar 2011 04:36:16 +0000 Subject: [PATCH] 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] --- CHANGES | 5 + bin/named/Makefile.in | 6 +- bin/named/include/dlz/dlz_dlopen_driver.h | 54 ++ bin/named/main.c | 32 +- bin/named/query.c | 17 +- bin/named/server.c | 10 +- bin/named/unix/Makefile.in | 7 +- bin/named/unix/dlz_dlopen_driver.c | 642 ++++++++++++++++++ bin/named/win32/dlz_dlopen_driver.c | 628 +++++++++++++++++ bin/named/win32/named.dsp | 4 + bin/named/win32/named.mak | 22 + bin/named/xfrout.c | 33 +- bin/named/zoneconf.c | 4 +- bin/tests/system/Makefile.in | 4 +- bin/tests/system/dlzexternal/Makefile.in | 58 ++ bin/tests/system/dlzexternal/dlopen.c | 28 + bin/tests/system/dlzexternal/driver.c | 561 +++++++++++++++ bin/tests/system/dlzexternal/driver.h | 153 +++++ .../ns1/{named.conf => named.conf.in} | 4 +- bin/tests/system/dlzexternal/prereq.sh | 16 +- bin/tests/system/dlzexternal/tests.sh | 31 +- config.h.in | 28 +- config.h.win32 | 9 +- configure.in | 87 ++- contrib/dlz/bin/dlzbdb/Makefile.in | 4 +- contrib/dlz/config.dlz.in | 32 +- contrib/dlz/drivers/dlz_dlopen_driver.c | 624 ----------------- contrib/dlz/drivers/dlz_drivers.c | 16 +- .../drivers/include/dlz/dlz_dlopen_driver.h | 53 -- contrib/dlz/example/win32/DLLMain.c | 57 ++ contrib/dlz/example/win32/dxdriver.def | 20 + contrib/dlz/example/win32/dxdriver.dsp | 121 ++++ contrib/dlz/example/win32/dxdriver.dsw | 29 + contrib/dlz/example/win32/dxdriver.mak | 298 ++++++++ lib/dns/Makefile.in | 3 +- lib/dns/win32/libdns.def | 4 + lib/isccfg/Makefile.in | 4 +- 37 files changed, 2859 insertions(+), 849 deletions(-) create mode 100644 bin/named/include/dlz/dlz_dlopen_driver.h create mode 100644 bin/named/unix/dlz_dlopen_driver.c create mode 100644 bin/named/win32/dlz_dlopen_driver.c create mode 100644 bin/tests/system/dlzexternal/Makefile.in create mode 100644 bin/tests/system/dlzexternal/dlopen.c create mode 100644 bin/tests/system/dlzexternal/driver.c create mode 100644 bin/tests/system/dlzexternal/driver.h rename bin/tests/system/dlzexternal/ns1/{named.conf => named.conf.in} (89%) create mode 100644 contrib/dlz/example/win32/DLLMain.c create mode 100644 contrib/dlz/example/win32/dxdriver.def create mode 100644 contrib/dlz/example/win32/dxdriver.dsp create mode 100644 contrib/dlz/example/win32/dxdriver.dsw create mode 100644 contrib/dlz/example/win32/dxdriver.mak diff --git a/CHANGES b/CHANGES index df00017d9a..c7fe08ba11 100644 --- 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". + Driver also supported on win32. [RT #23467] + 3065. [bug] RRSIG could have time stamps too far in the future. [RT #23356] diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in index f1915a5494..9151adc8fc 100644 --- a/bin/named/Makefile.in +++ b/bin/named/Makefile.in @@ -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@ diff --git a/bin/named/include/dlz/dlz_dlopen_driver.h b/bin/named/include/dlz/dlz_dlopen_driver.h new file mode 100644 index 0000000000..7883a50592 --- /dev/null +++ b/bin/named/include/dlz/dlz_dlopen_driver.h @@ -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 diff --git a/bin/named/main.c b/bin/named/main.c index 693aec9b24..8ae670d85c 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -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 +#include + /* * 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 #endif @@ -856,9 +858,19 @@ setup(void) { */ /* xxdb_init(); */ -#ifdef DLZ +#ifdef ISC_DLZ_DLOPEN /* - * Register any DLZ drivers. + * 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 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(); diff --git a/bin/named/query.c b/bin/named/query.c index d2f6b13ff8..b626dfbb54 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -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 #include #include -#ifdef DLZ #include -#endif #include #include #include @@ -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)); diff --git a/bin/named/server.c b/bin/named/server.c index 49855fecfd..c6ba0dd209 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -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 #include #include -#ifdef DLZ #include -#endif #include #include #include @@ -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 diff --git a/bin/named/unix/Makefile.in b/bin/named/unix/Makefile.in index 11c14b18c7..d8969aefe6 100644 --- a/bin/named/unix/Makefile.in +++ b/bin/named/unix/Makefile.in @@ -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} diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c new file mode 100644 index 0000000000..9798624f0f --- /dev/null +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -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 + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#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 +} diff --git a/bin/named/win32/dlz_dlopen_driver.c b/bin/named/win32/dlz_dlopen_driver.c new file mode 100644 index 0000000000..0c8f6beb71 --- /dev/null +++ b/bin/named/win32/dlz_dlopen_driver.c @@ -0,0 +1,628 @@ +/* + * 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 + +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#ifdef ISC_DLZ_DLOPEN +static dns_sdlzimplementation_t *dlz_dlopen = NULL; + + +typedef struct dlopen_data { + isc_mem_t *mctx; + char *dl_path; + char *dlzname; + HMODULE 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 = GetProcAddress(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; + isc_boolean_t triedload = ISC_FALSE; + + 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; + } + + triedload = ISC_TRUE; + + /* Initialize the lock */ + isc_mutex_init(&cd->lock); + + /* Open the library */ + cd->dl_handle = LoadLibraryA(cd->dl_path); + if (cd->dl_handle == NULL) { + unsigned int error = GetLastError(); + + dlopen_log(ISC_LOG_ERROR, + "dlz_dlopen failed to open library '%s' - %u", + cd->dl_path, error); + 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 (triedload) + isc_mutex_destroy(&cd->lock); + if (cd->dl_handle) + FreeLibrary(cd->dl_handle); + 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); + + if (cd->dl_handle) + FreeLibrary(cd->dl_handle); + + 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 +} diff --git a/bin/named/win32/named.dsp b/bin/named/win32/named.dsp index 401d64f5a1..2a15064d9d 100644 --- a/bin/named/win32/named.dsp +++ b/bin/named/win32/named.dsp @@ -110,6 +110,10 @@ SOURCE=..\controlconf.c # End Source File # Begin Source File +SOURCE=.\dlz_dlopen_driver.c +# End Source File +# Begin Source File + SOURCE=..\interfacemgr.c # End Source File # Begin Source File diff --git a/bin/named/win32/named.mak b/bin/named/win32/named.mak index f01195ed58..a51468bce1 100644 --- a/bin/named/win32/named.mak +++ b/bin/named/win32/named.mak @@ -129,6 +129,7 @@ CLEAN : -@erase "$(INTDIR)\config.obj" -@erase "$(INTDIR)\control.obj" -@erase "$(INTDIR)\controlconf.obj" + -@erase "$(INTDIR)\dlz_dlopen_driver.obj" -@erase "$(INTDIR)\interfacemgr.obj" -@erase "$(INTDIR)\listenlist.obj" -@erase "$(INTDIR)\log.obj" @@ -174,6 +175,7 @@ LINK32_OBJS= \ "$(INTDIR)\config.obj" \ "$(INTDIR)\control.obj" \ "$(INTDIR)\controlconf.obj" \ + "$(INTDIR)\dlz_dlopen_driver.obj" \ "$(INTDIR)\interfacemgr.obj" \ "$(INTDIR)\listenlist.obj" \ "$(INTDIR)\log.obj" \ @@ -247,6 +249,8 @@ CLEAN : -@erase "$(INTDIR)\control.sbr" -@erase "$(INTDIR)\controlconf.obj" -@erase "$(INTDIR)\controlconf.sbr" + -@erase "$(INTDIR)\dlz_dlopen_driver.obj" + -@erase "$(INTDIR)\dlz_dlopen_driver.sbr" -@erase "$(INTDIR)\interfacemgr.obj" -@erase "$(INTDIR)\interfacemgr.sbr" -@erase "$(INTDIR)\listenlist.obj" @@ -319,6 +323,7 @@ BSC32_SBRS= \ "$(INTDIR)\config.sbr" \ "$(INTDIR)\control.sbr" \ "$(INTDIR)\controlconf.sbr" \ + "$(INTDIR)\dlz_dlopen_driver.sbr" \ "$(INTDIR)\interfacemgr.sbr" \ "$(INTDIR)\listenlist.sbr" \ "$(INTDIR)\log.sbr" \ @@ -359,6 +364,7 @@ LINK32_OBJS= \ "$(INTDIR)\config.obj" \ "$(INTDIR)\control.obj" \ "$(INTDIR)\controlconf.obj" \ + "$(INTDIR)\dlz_dlopen_driver.obj" \ "$(INTDIR)\interfacemgr.obj" \ "$(INTDIR)\listenlist.obj" \ "$(INTDIR)\log.obj" \ @@ -530,6 +536,22 @@ SOURCE=..\controlconf.c $(CPP) $(CPP_PROJ) $(SOURCE) +!ENDIF + +SOURCE=.\dlz_dlopen_driver.c + +!IF "$(CFG)" == "named - Win32 Release" + + +"$(INTDIR)\dlz_dlopen_driver.obj" : $(SOURCE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "named - Win32 Debug" + + +"$(INTDIR)\dlz_dlopen_driver.obj" "$(INTDIR)\dlz_dlopen_driver.sbr" : $(SOURCE) "$(INTDIR)" + + !ENDIF SOURCE=..\interfacemgr.c diff --git a/bin/named/xfrout.c b/bin/named/xfrout.c index d87de5ee3c..0f7836a387 100644 --- a/bin/named/xfrout.c +++ b/bin/named/xfrout.c @@ -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.140 2011/03/10 04:36:14 each Exp $ */ #include @@ -28,9 +28,7 @@ #include #include -#ifdef DLZ #include -#endif #include #include #include @@ -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, ¤t_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, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index f32e654505..5b5ac27578 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.171 2011/02/23 03:08:09 marka Exp $ */ +/* $Id: zoneconf.c,v 1.172 2011/03/10 04:36:14 each Exp $ */ /*% */ @@ -1461,7 +1461,6 @@ ns_zone_configure(const cfg_obj_t *config, const cfg_obj_t *vconfig, } -#ifdef DLZ /* * Set up a DLZ zone as writeable */ @@ -1483,7 +1482,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) { diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index 6db22d1018..b7f5a824c6 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -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.36 2011/03/10 04:36:15 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 index 0000000000..295747abc5 --- /dev/null +++ b/bin/tests/system/dlzexternal/Makefile.in @@ -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.2 2011/03/10 04:36:15 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 index 0000000000..c9610e904c --- /dev/null +++ b/bin/tests/system/dlzexternal/dlopen.c @@ -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.2 2011/03/10 04:36:15 each Exp $ */ + +#include + +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 index 0000000000..677129987b --- /dev/null +++ b/bin/tests/system/dlzexternal/driver.c @@ -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 + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#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 index 0000000000..2d9d716a12 --- /dev/null +++ b/bin/tests/system/dlzexternal/driver.h @@ -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); diff --git a/bin/tests/system/dlzexternal/ns1/named.conf b/bin/tests/system/dlzexternal/ns1/named.conf.in similarity index 89% rename from bin/tests/system/dlzexternal/ns1/named.conf rename to bin/tests/system/dlzexternal/ns1/named.conf.in index 0bb7bcfb3b..dd8f45f4ea 100644 --- a/bin/tests/system/dlzexternal/ns1/named.conf +++ b/bin/tests/system/dlzexternal/ns1/named.conf.in @@ -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.2 2011/03/10 04:36:15 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"; }; diff --git a/bin/tests/system/dlzexternal/prereq.sh b/bin/tests/system/dlzexternal/prereq.sh index fa1727d85e..4d9855a370 100644 --- a/bin/tests/system/dlzexternal/prereq.sh +++ b/bin/tests/system/dlzexternal/prereq.sh @@ -14,20 +14,12 @@ # 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.5 2011/03/10 04:36:15 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 - - diff --git a/bin/tests/system/dlzexternal/tests.sh b/bin/tests/system/dlzexternal/tests.sh index cf31d378a7..e8a46f9c9b 100644 --- a/bin/tests/system/dlzexternal/tests.sh +++ b/bin/tests/system/dlzexternal/tests.sh @@ -13,32 +13,43 @@ test_update() { type="$2" cmd="$3" digout="$4" + should_fail="$5" cat < 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 -[ $status -eq 0 ] && echo "I:dlzexternal tests all OK" +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` + +test_update deny.example.nil. TXT "86400 TXT helloworld" "helloworld" should_fail && ret=1 +status=`expr $status + $ret` exit $status diff --git a/config.h.in b/config.h.in index a57cfa2b4b..ee4f320923 100644 --- a/config.h.in +++ b/config.h.in @@ -16,7 +16,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.h.in,v 1.145 2011/02/27 06:21:53 marka Exp $ */ +/* $Id: config.h.in,v 1.146 2011/03/10 04:36:13 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 diff --git a/config.h.win32 b/config.h.win32 index 3bb98cc3d5..0cbab551b4 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.h.win32,v 1.26 2011/01/13 08:50:28 tbox Exp $ */ +/* $Id: config.h.win32,v 1.27 2011/03/10 04:36:13 each Exp $ */ /* * win32 configuration file @@ -126,6 +126,13 @@ /* Define if you have DH_generate_parameters(). */ #define HAVE_DH_GENERATE_PARAMETERS +/* + * Define to 1 if you want to use the DLZ "dlopen" driver + * (which has the same name on windows even though it uses + * LoadLibrary() instead of dlopen()). + */ +#define ISC_DLZ_DLOPEN 1 + #define WANT_IPV6 #define S_IFMT _S_IFMT /* file type mask */ diff --git a/configure.in b/configure.in index e3cc6d7c46..01092e501f 100644 --- a/configure.in +++ b/configure.in @@ -18,7 +18,7 @@ AC_DIVERT_PUSH(1)dnl esyscmd([sed "s/^/# /" COPYRIGHT])dnl AC_DIVERT_POP()dnl -AC_REVISION($Revision: 1.518 $) +AC_REVISION($Revision: 1.519 $) 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="" +# +# 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 + + # 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) -AC_MSG_CHECKING(for DLZ) - -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 diff --git a/contrib/dlz/bin/dlzbdb/Makefile.in b/contrib/dlz/bin/dlzbdb/Makefile.in index 1fef2c7266..67244c98f9 100644 --- a/contrib/dlz/bin/dlzbdb/Makefile.in +++ b/contrib/dlz/bin/dlzbdb/Makefile.in @@ -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.6 2011/03/10 04:36:15 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@ diff --git a/contrib/dlz/config.dlz.in b/contrib/dlz/config.dlz.in index a49e40b39b..a693b56566 100644 --- a/contrib/dlz/config.dlz.in +++ b/contrib/dlz/config.dlz.in @@ -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. # diff --git a/contrib/dlz/drivers/dlz_dlopen_driver.c b/contrib/dlz/drivers/dlz_dlopen_driver.c index e70601584b..e69de29bb2 100644 --- a/contrib/dlz/drivers/dlz_dlopen_driver.c +++ b/contrib/dlz/drivers/dlz_dlopen_driver.c @@ -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 -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -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 diff --git a/contrib/dlz/drivers/dlz_drivers.c b/contrib/dlz/drivers/dlz_drivers.c index 568843760d..7ad166c7f4 100644 --- a/contrib/dlz/drivers/dlz_drivers.c +++ b/contrib/dlz/drivers/dlz_drivers.c @@ -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.4 2011/03/10 04:36:16 each Exp $ */ /*! \file */ @@ -61,10 +61,6 @@ #include #endif -#ifdef DLZ_DLOPEN -#include -#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 - } diff --git a/contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h b/contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h index d155f315dc..e69de29bb2 100644 --- a/contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h +++ b/contrib/dlz/drivers/include/dlz/dlz_dlopen_driver.h @@ -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 diff --git a/contrib/dlz/example/win32/DLLMain.c b/contrib/dlz/example/win32/DLLMain.c new file mode 100644 index 0000000000..fad7b85c22 --- /dev/null +++ b/contrib/dlz/example/win32/DLLMain.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2001 Internet Software Consortium. + * + * 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: DLLMain.c,v 1.2 2011/03/10 04:36:16 each Exp $ */ + +#include +#include + +/* + * Called when we enter the DLL + */ +__declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, + DWORD fdwReason, LPVOID lpvReserved) +{ + switch (fdwReason) { + /* + * The DLL is loading due to process + * initialization or a call to LoadLibrary. + */ + case DLL_PROCESS_ATTACH: + break; + + /* The attached process creates a new thread. */ + case DLL_THREAD_ATTACH: + break; + + /* The thread of the attached process terminates. */ + case DLL_THREAD_DETACH: + break; + + /* + * The DLL is unloading from a process due to + * process termination or a call to FreeLibrary. + */ + case DLL_PROCESS_DETACH: + break; + + default: + break; + } + return (TRUE); +} + diff --git a/contrib/dlz/example/win32/dxdriver.def b/contrib/dlz/example/win32/dxdriver.def new file mode 100644 index 0000000000..6d97466d79 --- /dev/null +++ b/contrib/dlz/example/win32/dxdriver.def @@ -0,0 +1,20 @@ +LIBRARY dxdriver + +; Exported Functions +EXPORTS +dlz_addrdataset +dlz_allnodes +dlz_allowzonexfr +dlz_closeversion +dlz_configure +dlz_create +dlz_delrdataset +dlz_destroy +dlz_findzonedb +dlz_lookup +dlz_newversion +dlz_ssumatch +dlz_subrdataset +dlz_version + + diff --git a/contrib/dlz/example/win32/dxdriver.dsp b/contrib/dlz/example/win32/dxdriver.dsp new file mode 100644 index 0000000000..c096b0810c --- /dev/null +++ b/contrib/dlz/example/win32/dxdriver.dsp @@ -0,0 +1,121 @@ +# Microsoft Developer Studio Project File - Name="dxdriver" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=dxdriver - Win32 Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "dxdriver.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "dxdriver.mak" CFG="dxdriver - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "dxdriver - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "dxdriver - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "dxdriver - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I "../" /I "../../../../../" /I "../../../../../lib/isc/win32" /I "../../../../../lib/isc/win32/include" /I "../../../../../lib/isc/include" /I "../../../../../lib/dns/include" /D "NDEBUG" /D "WIN32" /D "__STDC__" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c +# SUBTRACT CPP /X +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 user32.lib advapi32.lib ws2_32.lib /nologo /dll /machine:I386 /out:"../../../../../Build/Release/dxdriver.dll" + +!ELSEIF "$(CFG)" == "dxdriver - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "../" /I "../../../../../" /I "../../../../../lib/isc/win32" /I "../../../../../lib/isc/win32/include" /I "../../../../../lib/isc/include" /I "../../../../../lib/dns/include" /D "_DEBUG" /D "WIN32" /D "__STDC__" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c +# SUBTRACT CPP /X +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 user32.lib advapi32.lib ws2_32.lib /nologo /dll /debug /machine:I386 /out:"../../../../../Build/Debug/dxdriver.dll" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "dxdriver - Win32 Release" +# Name "dxdriver - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\driver.c +# End Source File +# Begin Source File + +SOURCE=.\DLLMain.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\driver.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\dxdriver.def +# End Source File +# End Target +# End Project diff --git a/contrib/dlz/example/win32/dxdriver.dsw b/contrib/dlz/example/win32/dxdriver.dsw new file mode 100644 index 0000000000..b0212fe72e --- /dev/null +++ b/contrib/dlz/example/win32/dxdriver.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "dxdriver"=.\dxdriver.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/contrib/dlz/example/win32/dxdriver.mak b/contrib/dlz/example/win32/dxdriver.mak new file mode 100644 index 0000000000..1d8506b15e --- /dev/null +++ b/contrib/dlz/example/win32/dxdriver.mak @@ -0,0 +1,298 @@ +# Microsoft Developer Studio Generated NMAKE File, Based on dxdriver.dsp +!IF "$(CFG)" == "" +CFG=dxdriver - Win32 Release +!MESSAGE No configuration specified. Defaulting to dxdriver - Win32 Release. +!ENDIF + +!IF "$(CFG)" != "dxdriver - Win32 Release" && "$(CFG)" != "dxdriver - Win32 Debug" +!MESSAGE Invalid configuration "$(CFG)" specified. +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "dxdriver.mak" CFG="dxdriver - Win32 Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "dxdriver - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "dxdriver - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE +!ERROR An invalid configuration is specified. +!ENDIF + +!IF "$(OS)" == "Windows_NT" +NULL= +!ELSE +NULL=nul +!ENDIF + +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "dxdriver - Win32 Release" +_VC_MANIFEST_INC=0 +_VC_MANIFEST_BASENAME=__VC80 +!ELSE +_VC_MANIFEST_INC=1 +_VC_MANIFEST_BASENAME=__VC80.Debug +!ENDIF + +#################################################### +# Specifying name of temporary resource file used only in incremental builds: + +!if "$(_VC_MANIFEST_INC)" == "1" +_VC_MANIFEST_AUTO_RES=$(_VC_MANIFEST_BASENAME).auto.res +!else +_VC_MANIFEST_AUTO_RES= +!endif + +#################################################### +# _VC_MANIFEST_EMBED_EXE - command to embed manifest in EXE: + +!if "$(_VC_MANIFEST_INC)" == "1" + +#MT_SPECIAL_RETURN=1090650113 +#MT_SPECIAL_SWITCH=-notify_resource_update +MT_SPECIAL_RETURN=0 +MT_SPECIAL_SWITCH= +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -out:$(_VC_MANIFEST_BASENAME).auto.manifest $(MT_SPECIAL_SWITCH) & \ +if "%ERRORLEVEL%" == "$(MT_SPECIAL_RETURN)" \ +rc /r $(_VC_MANIFEST_BASENAME).auto.rc & \ +link $** /out:$@ $(LFLAGS) + +!else + +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;1 + +!endif + +#################################################### +# _VC_MANIFEST_EMBED_DLL - command to embed manifest in DLL: + +!if "$(_VC_MANIFEST_INC)" == "1" + +#MT_SPECIAL_RETURN=1090650113 +#MT_SPECIAL_SWITCH=-notify_resource_update +MT_SPECIAL_RETURN=0 +MT_SPECIAL_SWITCH= +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -out:$(_VC_MANIFEST_BASENAME).auto.manifest $(MT_SPECIAL_SWITCH) & \ +if "%ERRORLEVEL%" == "$(MT_SPECIAL_RETURN)" \ +rc /r $(_VC_MANIFEST_BASENAME).auto.rc & \ +link $** /out:$@ $(LFLAGS) + +!else + +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest mt.exe -manifest $@.manifest -outputresource:$@;2 + +!endif +#################################################### +# _VC_MANIFEST_CLEAN - command to clean resources files generated temporarily: + +!if "$(_VC_MANIFEST_INC)" == "1" + +_VC_MANIFEST_CLEAN=-del $(_VC_MANIFEST_BASENAME).auto.res \ + $(_VC_MANIFEST_BASENAME).auto.rc \ + $(_VC_MANIFEST_BASENAME).auto.manifest + +!else + +_VC_MANIFEST_CLEAN= + +!endif + +!IF "$(CFG)" == "dxdriver - Win32 Release" + +OUTDIR=.\Release +INTDIR=.\Release + +ALL : "..\..\..\..\..\Build\Release\dxdriver.dll" + +CLEAN : + -@erase "$(INTDIR)\DLLMain.obj" + -@erase "$(INTDIR)\driver.obj" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(OUTDIR)\dxdriver.exp" + -@erase "$(OUTDIR)\dxdriver.lib" + -@erase "..\..\..\..\..\Build\Release\dxdriver.dll" + -@$(_VC_MANIFEST_CLEAN) + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "../" /I "../../../../../" /I "../../../../../lib/isc/win32" /I "../../../../../lib/isc/win32/include" /I "../../../../../lib/isc/include" /I "../../../../../lib/dns/include" /D "NDEBUG" /D "WIN32" /D "__STDC__" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /Fp"$(INTDIR)\dxdriver.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c +MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\dxdriver.bsc" +BSC32_SBRS= \ + +LINK32=link.exe +LINK32_FLAGS=user32.lib advapi32.lib ws2_32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\dxdriver.pdb" /machine:I386 /def:".\dxdriver.def" /out:"../../../../../Build/Release/dxdriver.dll" /implib:"$(OUTDIR)\dxdriver.lib" +DEF_FILE= \ + ".\dxdriver.def" +LINK32_OBJS= \ + "$(INTDIR)\DLLMain.obj" \ + "$(INTDIR)\driver.obj" + +"..\..\..\..\..\Build\Release\dxdriver.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + $(_VC_MANIFEST_EMBED_DLL) + +!ELSEIF "$(CFG)" == "dxdriver - Win32 Debug" + +OUTDIR=.\Debug +INTDIR=.\Debug +# Begin Custom Macros +OutDir=.\Debug +# End Custom Macros + +ALL : "..\..\..\..\..\Build\Debug\dxdriver.dll" "$(OUTDIR)\dxdriver.bsc" + +CLEAN : + -@erase "$(INTDIR)\DLLMain.obj" + -@erase "$(INTDIR)\DLLMain.sbr" + -@erase "$(INTDIR)\driver.obj" + -@erase "$(INTDIR)\driver.sbr" + -@erase "$(INTDIR)\vc60.idb" + -@erase "$(INTDIR)\vc60.pdb" + -@erase "$(OUTDIR)\dxdriver.bsc" + -@erase "$(OUTDIR)\dxdriver.exp" + -@erase "$(OUTDIR)\dxdriver.lib" + -@erase "$(OUTDIR)\dxdriver.pdb" + -@erase "..\..\..\..\..\Build\Debug\dxdriver.dll" + -@erase "..\..\..\..\..\Build\Debug\dxdriver.ilk" + -@$(_VC_MANIFEST_CLEAN) + +"$(OUTDIR)" : + if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" + +CPP_PROJ=/nologo /MDd /W3 /Gm /GX /ZI /Od /I "../" /I "../../../../../" /I "../../../../../lib/isc/win32" /I "../../../../../lib/isc/win32/include" /I "../../../../../lib/isc/include" /I "../../../../../lib/dns/include" /D "_DEBUG" /D "WIN32" /D "__STDC__" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\dxdriver.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /GZ /c +MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32 +BSC32=bscmake.exe +BSC32_FLAGS=/nologo /o"$(OUTDIR)\dxdriver.bsc" +BSC32_SBRS= \ + "$(INTDIR)\DLLMain.sbr" \ + "$(INTDIR)\driver.sbr" + +"$(OUTDIR)\dxdriver.bsc" : "$(OUTDIR)" $(BSC32_SBRS) + $(BSC32) @<< + $(BSC32_FLAGS) $(BSC32_SBRS) +<< + +LINK32=link.exe +LINK32_FLAGS=user32.lib advapi32.lib ws2_32.lib /nologo /dll /incremental:yes /pdb:"$(OUTDIR)\dxdriver.pdb" /debug /machine:I386 /def:".\dxdriver.def" /out:"../../../../../Build/Debug/dxdriver.dll" /implib:"$(OUTDIR)\dxdriver.lib" /pdbtype:sept +DEF_FILE= \ + ".\dxdriver.def" +LINK32_OBJS= \ + "$(INTDIR)\DLLMain.obj" \ + "$(INTDIR)\driver.obj" + +"..\..\..\..\..\Build\Debug\dxdriver.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) + $(LINK32) @<< + $(LINK32_FLAGS) $(LINK32_OBJS) +<< + $(_VC_MANIFEST_EMBED_DLL) + +!ENDIF + +.c{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.c{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cpp{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + +.cxx{$(INTDIR)}.sbr:: + $(CPP) @<< + $(CPP_PROJ) $< +<< + + +!IF "$(NO_EXTERNAL_DEPS)" != "1" +!IF EXISTS("dxdriver.dep") +!INCLUDE "dxdriver.dep" +!ELSE +!MESSAGE Warning: cannot find "dxdriver.dep" +!ENDIF +!ENDIF + + +!IF "$(CFG)" == "dxdriver - Win32 Release" || "$(CFG)" == "dxdriver - Win32 Debug" +SOURCE=.\DLLMain.c + +!IF "$(CFG)" == "dxdriver - Win32 Release" + + +"$(INTDIR)\DLLMain.obj" : $(SOURCE) "$(INTDIR)" + + +!ELSEIF "$(CFG)" == "dxdriver - Win32 Debug" + + +"$(INTDIR)\DLLMain.obj" "$(INTDIR)\DLLMain.sbr" : $(SOURCE) "$(INTDIR)" + + +!ENDIF + +SOURCE=..\driver.c + +!IF "$(CFG)" == "dxdriver - Win32 Release" + + +"$(INTDIR)\driver.obj" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ELSEIF "$(CFG)" == "dxdriver - Win32 Debug" + + +"$(INTDIR)\driver.obj" "$(INTDIR)\driver.sbr" : $(SOURCE) "$(INTDIR)" + $(CPP) $(CPP_PROJ) $(SOURCE) + + +!ENDIF + + +!ENDIF + +#################################################### +# Commands to generate initial empty manifest file and the RC file +# that references it, and for generating the .res file: + +$(_VC_MANIFEST_BASENAME).auto.res : $(_VC_MANIFEST_BASENAME).auto.rc + +$(_VC_MANIFEST_BASENAME).auto.rc : $(_VC_MANIFEST_BASENAME).auto.manifest + type <<$@ +#include +1RT_MANIFEST"$(_VC_MANIFEST_BASENAME).auto.manifest" +<< KEEP + +$(_VC_MANIFEST_BASENAME).auto.manifest : + type <<$@ + + + +<< KEEP diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index d011b00050..e38bb54cb7 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -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.177 2011/02/26 02:26:10 each Exp $ +# $Id: Makefile.in,v 1.178 2011/03/10 04:36:16 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 diff --git a/lib/dns/win32/libdns.def b/lib/dns/win32/libdns.def index 847cc1e6ab..e125fb8de9 100644 --- a/lib/dns/win32/libdns.def +++ b/lib/dns/win32/libdns.def @@ -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 @@ -636,6 +638,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 +761,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 diff --git a/lib/isccfg/Makefile.in b/lib/isccfg/Makefile.in index 35e04b8b77..883f5d5bb0 100644 --- a/lib/isccfg/Makefile.in +++ b/lib/isccfg/Makefile.in @@ -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.23 2011/02/19 23:47:38 tbox Exp $ +# $Id: Makefile.in,v 1.24 2011/03/10 04:36:16 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@