From 29e5df821d523ede3f8815d1fe9d4b8a796168d3 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Mon, 27 Apr 2009 19:11:49 +0200 Subject: Look into /usr/lib{,64}/bind/ for plugins. --- lib/dns/Makefile.in | 5 +++++ lib/dns/dynamic_db.c | 25 +++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/dns/Makefile.in b/lib/dns/Makefile.in index 0f7abba..97cc9fa 100644 --- a/lib/dns/Makefile.in +++ b/lib/dns/Makefile.in @@ -115,6 +115,11 @@ version.@O@: version.c -DLIBAGE=${LIBAGE} \ -c ${srcdir}/version.c +dynamic_db.@O@: dynamic_db.c + ${LIBTOOL_MODE_COMPILE} ${CC} ${ALL_CFLAGS} \ + -DDYNDB_LIBDIR=\"@libdir@/bind/\" \ + -c ${srcdir}/dynamic_db.c + libdns.@SA@: ${OBJS} ${AR} ${ARFLAGS} $@ ${OBJS} ${RANLIB} $@ diff --git a/lib/dns/dynamic_db.c b/lib/dns/dynamic_db.c index de2daf7..25afaf5 100644 --- a/lib/dns/dynamic_db.c +++ b/lib/dns/dynamic_db.c @@ -17,10 +17,12 @@ #include +#include #include #include #include #include +#include #include #include #include @@ -37,6 +39,10 @@ #include #endif +#ifndef DYNDB_LIBDIR +#define DYNDB_LIBDIR "" +#endif + #define CHECK(op) \ do { result = (op); \ if (result != ISC_R_SUCCESS) goto cleanup; \ @@ -109,6 +115,9 @@ static isc_result_t load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **impp) { isc_result_t result; + size_t module_size; + isc_buffer_t *module_buf = NULL; + isc_region_t module_region; void *handle; dyndb_implementation_t *imp; register_func_t register_function = NULL; @@ -116,7 +125,15 @@ load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **imp REQUIRE(impp != NULL && *impp == NULL); - handle = dlopen(filename, RTLD_LAZY); + /* Build up the full path. */ + module_size = strlen(DYNDB_LIBDIR) + strlen(filename) + 1; + CHECK(isc_buffer_allocate(mctx, &module_buf, module_size)); + isc_buffer_putstr(module_buf, DYNDB_LIBDIR); + isc_buffer_putstr(module_buf, filename); + isc_buffer_putuint8(module_buf, 0); + isc_buffer_region(module_buf, &module_region); + + handle = dlopen((char *)module_region.base, RTLD_LAZY); if (handle == NULL) { isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, ISC_LOG_ERROR, @@ -147,11 +164,11 @@ load_library(isc_mem_t *mctx, const char *filename, dyndb_implementation_t **imp *impp = imp; - return ISC_R_SUCCESS; - cleanup: - if (handle != NULL) + if (result != ISC_R_SUCCESS && handle != NULL) dlclose(handle); + if (module_buf != NULL) + isc_buffer_free(&module_buf); return result; } -- cgit