dlz_dlopen_driver.c revision b95504f9a74fb6571124262d1eafd262bd06f7c8
/*
* Copyright (C) 2011-2013 Internet Systems Consortium, Inc. ("ISC")
*
* 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$ */
#include <config.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <dns/dlz_dlopen.h>
#include <dlz/dlz_dlopen_driver.h>
#ifdef ISC_DLZ_DLOPEN
typedef struct dlopen_data {
char *dl_path;
char *dlzname;
void *dl_handle;
void *dbdata;
unsigned int flags;
int version;
/* Modules can choose whether they are lock-safe or not. */
#define MAYBE_LOCK(cd) \
do { \
} while (0)
#define MAYBE_UNLOCK(cd) \
do { \
} while (0)
/*
* Log a message at the given level.
*/
{
}
/*
* SDLZ methods
*/
static isc_result_t
{
return (ISC_R_NOPERM);
}
MAYBE_LOCK(cd);
return (result);
}
static isc_result_t
const char *client)
{
return (ISC_R_NOPERM);
}
MAYBE_LOCK(cd);
return (result);
}
static isc_result_t
{
return (ISC_R_NOTIMPLEMENTED);
}
MAYBE_LOCK(cd);
return (result);
}
static isc_result_t
{
MAYBE_LOCK(cd);
return (result);
}
static isc_result_t
{
MAYBE_LOCK(cd);
return (result);
}
/*
* Load a symbol from the library
*/
static void *
"dlz_dlopen: library '%s' is missing "
}
return (ptr);
}
/*
* Called at startup for each dlopen zone in named.conf
*/
static isc_result_t
{
int dlopen_flags = 0;
if (argc < 2) {
"dlz_dlopen driver for '%s' needs a path to "
"the shared library", dlzname);
return (ISC_R_FAILURE);
}
if (result != ISC_R_SUCCESS)
return (result);
return (ISC_R_NOMEMORY);
}
goto failed;
}
goto failed;
}
/* Initialize the lock */
/* Open the library */
#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).
*/
#endif
"dlz_dlopen failed to open library '%s' - %s",
goto failed;
}
/* Find the symbols */
{
/* We're missing a required symbol */
goto failed;
}
/* Check the version of the API is the same */
{
"dlz_dlopen: %s: incorrect driver API version %d, "
"requires %d",
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);
"log", dlopen_log,
"putrr", dns_sdlz_putrr,
"putnamedrr", dns_sdlz_putnamedrr,
"writeable_zone", dns_dlz_writeablezone,
NULL);
if (result != ISC_R_SUCCESS)
goto failed;
return (ISC_R_SUCCESS);
if (dlopen_flags)
#ifdef HAVE_DLCLOSE
#endif
return (result);
}
/*
* Called when bind is shutting down
*/
static void
if (cd->dlz_destroy) {
MAYBE_LOCK(cd);
}
#ifdef HAVE_DLCLOSE
#endif
}
/*
* Called to start a transaction
*/
static isc_result_t
void **versionp)
{
return (ISC_R_NOTIMPLEMENTED);
MAYBE_LOCK(cd);
return (result);
}
/*
* Called to end a transaction
*/
static void
{
return;
}
MAYBE_LOCK(cd);
}
/*
* Called on startup to configure any writeable zones
*/
static isc_result_t
{
return (ISC_R_SUCCESS);
MAYBE_LOCK(cd);
return (result);
}
/*
* Check for authority to change a name
*/
static isc_boolean_t
{
return (ISC_FALSE);
MAYBE_LOCK(cd);
return (ret);
}
/*
* Add an rdataset
*/
static isc_result_t
{
return (ISC_R_NOTIMPLEMENTED);
MAYBE_LOCK(cd);
return (result);
}
/*
* Subtract an rdataset
*/
static isc_result_t
{
return (ISC_R_NOTIMPLEMENTED);
MAYBE_LOCK(cd);
return (result);
}
/*
delete a rdataset
*/
static isc_result_t
{
return (ISC_R_NOTIMPLEMENTED);
MAYBE_LOCK(cd);
return (result);
}
static dns_sdlzmethods_t dlz_dlopen_methods = {
};
#endif
/*
* Register driver with BIND
*/
#ifndef ISC_DLZ_DLOPEN
return (ISC_R_NOTIMPLEMENTED);
#else
mctx, &dlz_dlopen);
if (result != ISC_R_SUCCESS) {
"dns_sdlzregister() failed: %s",
}
return (result);
#endif
}
/*
* Unregister the driver
*/
void
dlz_dlopen_clear(void) {
#ifdef ISC_DLZ_DLOPEN
if (dlz_dlopen != NULL)
#endif
}