2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 14:07:59 +00:00

Use libuv's shared library handling capabilities

While libltdl is a feature-rich library, BIND 9 code only uses its basic
capabilities, which are also provided by libuv and which BIND 9 already
uses for other purposes.  As libuv's cross-platform shared library
handling interface is modeled after the POSIX dlopen() interface,
converting code using the latter to the former is simple.  Replace
libltdl function calls with their libuv counterparts, refactoring the
code as necessary.  Remove all use of libltdl from the BIND 9 source
tree.
This commit is contained in:
Ondřej Surý 2020-10-20 23:51:08 +02:00 committed by Michał Kępień
parent e2436159ab
commit 37b9511ce1
43 changed files with 90 additions and 185 deletions

1
.gitignore vendored
View File

@ -39,7 +39,6 @@ __pycache__/
/depcomp
/install-sh
/isc-config.sh
/libltdl/*
/libtool
/ltmain.sh
/m4/libtool.m4

View File

@ -1527,9 +1527,9 @@ gcov:
# Generate XML file in the Cobertura XML format suitable for use by GitLab
# for the purpose of displaying code coverage information in the diff view
# of a given merge request.
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --xml -o coverage.xml
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --html-details -o coverage.html
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories libltdl --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' -o coverage.txt
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --xml -o coverage.xml
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' --html-details -o coverage.html
- gcovr --root . --exclude-directories bin/tests --exclude-directories doc --exclude-directories lib/samples --exclude 'lib/.*/tests/.*' -o coverage.txt
- tail -n 3 coverage.txt
artifacts:
paths:

View File

@ -29,7 +29,6 @@ path_classifiers:
- "**/*.5"
- "**/*.8"
queries:
- exclude: libltdl/
- exclude: fuzz/
- exclude: "bin/tests/system/*/ans*/*.py"
- exclude: cpp/use-of-goto

View File

@ -1,6 +1,6 @@
include $(top_srcdir)/Makefile.top
SUBDIRS = . libltdl lib doc bin fuzz
SUBDIRS = . lib doc bin fuzz
BUILT_SOURCES = bind.keys.h
CLEANFILES = bind.keys.h

View File

@ -93,9 +93,3 @@ LIBBIND9_CFLAGS = \
LIBBIND9_LIBS = \
$(top_builddir)/lib/bind9/libbind9.la
LIBLTDL_CFLAGS = \
-I$(top_srcdir)/libltdl
LIBLTDL_LIBS = \
$(top_builddir)/libltdl/libltdlc.la

View File

@ -201,7 +201,6 @@ installed:
autoconf (includes autoreconf)
automake
libtool
libltdl-dev (Debian) / libtool-ltdl-dev (Fedora/CentOS) / libltdl (FreeBSD)
#### <a name="opts"/> Compile-time options

View File

@ -9,7 +9,6 @@ AM_CPPFLAGS += \
$(LIBISCCC_CFLAGS) \
$(LIBISCCFG_CFLAGS) \
$(LIBBIND9_CFLAGS) \
$(LIBLTDL_CFLAGS) \
$(OPENSSL_CFLAGS) \
$(LIBCAP_CFLAGS) \
$(LMDB_CFLAGS) \

View File

@ -10,11 +10,11 @@
*/
#include <inttypes.h>
#include <ltdl.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uv.h>
#include <isc/mem.h>
#include <isc/print.h>
@ -34,7 +34,7 @@ typedef struct dlopen_data {
isc_mem_t *mctx;
char *dl_path;
char *dlzname;
void *dl_handle;
uv_lib_t dl_handle;
void *dbdata;
unsigned int flags;
isc_mutex_t lock;
@ -180,9 +180,10 @@ dlopen_dlz_lookup(const char *zone, const char *name, void *driverarg,
*/
static void *
dl_load_symbol(dlopen_data_t *cd, const char *symbol, bool mandatory) {
void *ptr = lt_dlsym((lt_dlhandle)cd->dl_handle, symbol);
if (ptr == NULL) {
const char *errmsg = lt_dlerror();
void *ptr = NULL;
int r = uv_dlsym(&cd->dl_handle, symbol, &ptr);
if (r != 0) {
const char *errmsg = uv_dlerror(&cd->dl_handle);
if (errmsg == NULL) {
errmsg = "returned function pointer is NULL";
}
@ -209,6 +210,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
dlopen_data_t *cd;
isc_mem_t *mctx = NULL;
isc_result_t result = ISC_R_FAILURE;
int r;
UNUSED(driverarg);
@ -220,10 +222,6 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
return (ISC_R_FAILURE);
}
if (lt_dlinit() != 0) {
return (ISC_R_FAILURE);
}
isc_mem_create(&mctx);
cd = isc_mem_get(mctx, sizeof(*cd));
memset(cd, 0, sizeof(*cd));
@ -236,9 +234,9 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
/* Initialize the lock */
isc_mutex_init(&cd->lock);
cd->dl_handle = lt_dlopenext(cd->dl_path);
if (cd->dl_handle == NULL) {
const char *errmsg = lt_dlerror();
r = uv_dlopen(cd->dl_path, &cd->dl_handle);
if (r != 0) {
const char *errmsg = uv_dlerror(&cd->dl_handle);
if (errmsg == NULL) {
errmsg = "unknown error";
}
@ -347,9 +345,7 @@ dlopen_dlz_destroy(void *driverarg, void *dbdata) {
MAYBE_UNLOCK(cd);
}
if (cd->dl_handle) {
lt_dlclose(cd->dl_handle);
}
uv_dlclose(&cd->dl_handle);
isc_mutex_destroy(&cd->lock);
isc_mem_free(cd->mctx, cd->dl_path);
isc_mem_free(cd->mctx, cd->dlzname);

View File

@ -13,11 +13,6 @@
/* aliases for the exported symbols */
#define plugin_destroy filter_aaaa_LTX_plugin_destroy
#define plugin_register filter_aaaa_LTX_plugin_register
#define plugin_version filter_aaaa_LTX_plugin_version
#define plugin_check filter_aaaa_LTX_plugin_check
#include <inttypes.h>
#include <stdbool.h>
#include <string.h>

View File

@ -32,21 +32,6 @@
/* aliases for exported symbols */
#define dlz_version dlzexternal_LTX_dlz_version
#define dlz_create dlzexternal_LTX_dlz_create
#define dlz_destroy dlzexternal_LTX_dlz_destroy
#define dlz_findzonedb dlzexternal_LTX_dlz_findzonedb
#define dlz_lookup dlzexternal_LTX_dlz_lookup
#define dlz_allowzonexfr dlzexternal_LTX_dlz_allowzonexfr
#define dlz_allnodes dlzexternal_LTX_dlz_allnodes
#define dlz_newversion dlzexternal_LTX_dlz_newversion
#define dlz_closeversion dlzexternal_LTX_dlz_closeversion
#define dlz_configure dlzexternal_LTX_dlz_configure
#define dlz_ssumatch dlzexternal_LTX_dlz_ssumatch
#define dlz_addrdataset dlzexternal_LTX_dlz_addrdataset
#define dlz_sbrdataset dlzexternal_LTX_dlz_sbrdataset
#define dlz_delrdataset dlzexternal_LTX_dlz_delrdataset
dlz_dlopen_version_t dlz_version;
dlz_dlopen_create_t dlz_create;
dlz_dlopen_destroy_t dlz_destroy;

View File

@ -35,29 +35,29 @@ controls {
};
dlz "example one" {
database "dlopen ../driver/dlzexternal.la example.nil";
database "dlopen ../driver/.libs/dlzexternal.so example.nil";
};
dlz "example two" {
database "dlopen ../driver/dlzexternal.la alternate.nil";
database "dlopen ../driver/.libs/dlzexternal.so alternate.nil";
};
dlz "example three" {
database "dlopen ../driver/dlzexternal.la example.org";
database "dlopen ../driver/.libs/dlzexternal.so example.org";
};
dlz "unsearched1" {
database "dlopen ../driver/dlzexternal.la other.nil";
database "dlopen ../driver/.libs/dlzexternal.so other.nil";
search no;
};
dlz "unsearched2" {
database "dlopen ../driver/dlzexternal.la zone.nil";
database "dlopen ../driver/.libs/dlzexternal.so zone.nil";
search no;
};
dlz redzone {
database "dlopen ../driver/dlzexternal.la .";
database "dlopen ../driver/.libs/dlzexternal.so .";
search no;
};

View File

@ -33,10 +33,6 @@
/* aliases for the exported symbols */
#define dyndb_init sample_LTX_dyndb_init
#define dyndb_destroy sample_LTX_dyndb_destroy
#define dyndb_version sample_LTX_dyndb_version
dns_dyndb_destroy_t dyndb_destroy;
dns_dyndb_register_t dyndb_init;
dns_dyndb_version_t dyndb_version;

View File

@ -33,5 +33,5 @@ controls {
inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
};
dyndb sample "../driver/sample.la" { ipv4.example.nil. in-addr.arpa. };
dyndb sample2 "../driver/sample.la" { ipv6.example.nil. 8.b.d.0.1.0.0.2.ip6.arpa. };
dyndb sample "../driver/.libs/sample.so" { ipv4.example.nil. in-addr.arpa. };
dyndb sample2 "../driver/.libs/sample.so" { ipv6.example.nil. 8.b.d.0.1.0.0.2.ip6.arpa. };

View File

@ -9,7 +9,7 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { none; };
};

View File

@ -9,7 +9,7 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
/*
* While this matches the defaults, it is not a good configuration
* to have in named.conf as the two options contradict each other

View File

@ -10,7 +10,7 @@
*/
view myview {
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 no;
filter-aaaa { any; };
};

View File

@ -10,7 +10,7 @@
*/
view myview {
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { none; };
};

View File

@ -9,7 +9,7 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { 1.0.0.0/8; };
};

View File

@ -9,6 +9,6 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
};

View File

@ -9,6 +9,6 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 break-dnssec;
};

View File

@ -9,7 +9,7 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 break-dnssec;
filter-aaaa { 1.0.0.0/8; };
};

View File

@ -9,7 +9,7 @@
* information regarding copyright ownership.
*/
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { 1.0.0.0/8; };
};

View File

@ -10,7 +10,7 @@
*/
view myview {
plugin query "../../../plugins/filter-aaaa.la" {
plugin query "../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { 1.0.0.0/8; };
};

View File

@ -25,7 +25,7 @@ options {
acl filterees { 10.53.0.1; };
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { filterees; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v6 yes;
filter-aaaa { fd92:7065:b8e:ffff::1; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 yes;
filter-aaaa { 10.53.0.2; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v6 yes;
filter-aaaa { fd92:7065:b8e:ffff::2; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 break-dnssec;
filter-aaaa { 10.53.0.3; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v6 break-dnssec;
filter-aaaa { fd92:7065:b8e:ffff::3; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 break-dnssec;
filter-aaaa { 10.53.0.4; };
};

View File

@ -23,7 +23,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v6 break-dnssec;
filter-aaaa { fd92:7065:b8e:ffff::4; };
};

View File

@ -28,7 +28,7 @@ options {
minimal-responses no;
};
plugin query "../../../../plugins/filter-aaaa.la" {
plugin query "../../../../plugins/.libs/filter-aaaa.so" {
filter-aaaa-on-v4 break-dnssec;
filter-aaaa { any; };
};

View File

@ -124,10 +124,6 @@ LT_INIT([disable-static dlopen pic-only])
AS_IF([test "$enable_static" != "no" && test "$enable_developer" != "yes"],
[AC_MSG_ERROR([Static linking is not supported as it disables dlopen() and certain security features (e.g. RELRO, ASLR)])])
LT_CONFIG_LTDL_DIR([libltdl])
LTDL_INIT([recursive])
AC_CONFIG_FILES([libltdl/Makefile])
#
# Set the default CFLAGS and CPPFLAGS
#

View File

@ -25,7 +25,7 @@ gen_SOURCES = gen.c gen-unix.h
gen_CPPFLAGS = \
$(AM_CPPFLAGS)
EXTRA_DIST = \
EXTRA_DIST = \
api \
dnstap.proto \
gen-win32.h \
@ -277,10 +277,10 @@ endif
libdns_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBISC_CFLAGS) \
$(LIBDNS_CFLAGS) \
$(OPENSSL_CFLAGS) \
$(LIBLTDL_CFLAGS)
$(LIBISC_CFLAGS) \
$(LIBUV_CFLAGS) \
$(OPENSSL_CFLAGS)
libdns_la_LDFLAGS = \
$(AM_LDFLAGS) \
@ -288,6 +288,7 @@ libdns_la_LDFLAGS = \
libdns_la_LIBADD = \
$(LIBISC_LIBS) \
$(LIBUV_LIBS) \
$(OPENSSL_LIBS)
if HAVE_JSON_C

View File

@ -9,8 +9,8 @@
* information regarding copyright ownership.
*/
#include <ltdl.h>
#include <string.h>
#include <uv.h>
#include <isc/buffer.h>
#include <isc/mem.h>
@ -38,7 +38,7 @@
typedef struct dyndb_implementation dyndb_implementation_t;
struct dyndb_implementation {
isc_mem_t *mctx;
void *handle;
uv_lib_t handle;
dns_dyndb_register_t *register_func;
dns_dyndb_destroy_t *destroy_func;
char *name;
@ -79,16 +79,17 @@ impfind(const char *name) {
}
static isc_result_t
load_symbol(lt_dlhandle handle, const char *filename, const char *symbol_name,
load_symbol(uv_lib_t *handle, const char *filename, const char *symbol_name,
void **symbolp) {
void *symbol;
int r;
REQUIRE(handle != NULL);
REQUIRE(symbolp != NULL && *symbolp == NULL);
symbol = lt_dlsym(handle, symbol_name);
if (symbol == NULL) {
const char *errmsg = lt_dlerror();
r = uv_dlsym(handle, symbol_name, &symbol);
if (r != 0) {
const char *errmsg = uv_dlerror(handle);
if (errmsg == NULL) {
errmsg = "returned function pointer is NULL";
}
@ -115,6 +116,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
dyndb_implementation_t *imp = NULL;
dns_dyndb_version_t *version_func = NULL;
int version;
int r;
REQUIRE(impp != NULL && *impp == NULL);
@ -130,13 +132,9 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
INIT_LINK(imp, link);
if (lt_dlinit() != 0) {
CHECK(ISC_R_FAILURE);
}
imp->handle = lt_dlopen(filename);
if (imp->handle == NULL) {
const char *errmsg = lt_dlerror();
r = uv_dlopen(filename, &imp->handle);
if (r != 0) {
const char *errmsg = uv_dlerror(&imp->handle);
if (errmsg == NULL) {
errmsg = "unknown error";
}
@ -148,7 +146,7 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
CHECK(ISC_R_FAILURE);
}
CHECK(load_symbol(imp->handle, filename, "dyndb_version",
CHECK(load_symbol(&imp->handle, filename, "dyndb_version",
(void **)&version_func));
version = version_func(NULL);
@ -162,9 +160,9 @@ load_library(isc_mem_t *mctx, const char *filename, const char *instname,
CHECK(ISC_R_FAILURE);
}
CHECK(load_symbol(imp->handle, filename, "dyndb_init",
CHECK(load_symbol(&imp->handle, filename, "dyndb_init",
(void **)&imp->register_func));
CHECK(load_symbol(imp->handle, filename, "dyndb_destroy",
CHECK(load_symbol(&imp->handle, filename, "dyndb_destroy",
(void **)&imp->destroy_func));
*impp = imp;
@ -196,9 +194,7 @@ unload_library(dyndb_implementation_t **impp) {
* This is a resource leak, but there is nothing we can currently do
* about it due to how configuration loading/reloading is designed.
*/
if (imp->handle != NULL) {
(void)lt_dlclose(imp->handle);
}
/* uv_dlclose(&imp->handle); */
isc_mem_free(imp->mctx, imp->name);
isc_mem_putanddetach(&imp->mctx, imp, sizeof(*imp));
}

View File

@ -61,7 +61,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BIND9;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDNS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
@ -75,7 +75,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>@LIBUV_LIB@@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(ProjectName).def</ModuleDefinitionFile>
<ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary>
</Link>
@ -91,7 +91,7 @@
<IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
<PreprocessorDefinitions>BIND9;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDNS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<StringPooling>true</StringPooling>
<PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
@ -108,7 +108,7 @@
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>@LIBUV_LIB@@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(ProjectName).def</ModuleDefinitionFile>
<ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>

View File

@ -230,7 +230,6 @@ libisc_la_LDFLAGS = \
$(libisc_VERSION_INFO)
libisc_la_LIBADD = \
$(LIBLTDL_LIBS) \
$(LIBUV_LIBS) \
$(OPENSSL_LIBS) \
$(ZLIB_LIBS)

View File

@ -1,43 +0,0 @@
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#pragma once
#include <windows.h>
#define lt_dlhandle HMODULE
#define lt_dlinit() ISC_R_SUCCESS
#define lt_dlopen(f) LoadLibraryW(f)
#define lt_dlsym(h, s) GetProcAddress(h, s)
#define lt_dlclose(h) FreeLibrary(h)
__declspec(thread) LPSTR __dlerror_message[1024] = { 0 };
static const char *
lt_dlerror(void) {
DWORD errorMessageID = GetLastError();
if (errorMessageID == 0) {
return (NULL);
}
LPSTR messageBuffer = NULL;
size_t size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, errorMessageID, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&messageBuffer, 0, NULL);
strlcpy(__dlerror_message, messageBuffer, sizeof(__dlerror_message));
LocalFree(messageBuffer);
return ((const char *)__dlerror_message);
}

View File

@ -41,14 +41,15 @@ libns_la_SOURCES = \
libns_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
$(LIBISC_CFLAGS) \
$(LIBDNS_CFLAGS) \
$(LIBISC_CFLAGS) \
$(LIBNS_CFLAGS) \
$(LIBLTDL_CFLAGS)
$(LIBUV_CFLAGS)
libns_la_LIBADD = \
$(LIBDNS_LIBS) \
$(LIBISC_LIBS) \
$(LIBDNS_LIBS)
$(LIBUV_LIBS)
libns_la_LDFLAGS = \
$(AM_LDFLAGS) \

View File

@ -12,9 +12,9 @@
/*! \file */
#include <errno.h>
#include <ltdl.h>
#include <stdio.h>
#include <string.h>
#include <uv.h>
#include <isc/errno.h>
#include <isc/list.h>
@ -43,7 +43,7 @@
struct ns_plugin {
isc_mem_t *mctx;
void *handle;
uv_lib_t handle;
void *inst;
char *modpath;
ns_plugin_check_t *check_func;
@ -91,16 +91,17 @@ ns_plugin_expandpath(const char *src, char *dst, size_t dstsize) {
}
static isc_result_t
load_symbol(void *handle, const char *modpath, const char *symbol_name,
load_symbol(uv_lib_t *handle, const char *modpath, const char *symbol_name,
void **symbolp) {
void *symbol = NULL;
int r;
REQUIRE(handle != NULL);
REQUIRE(symbolp != NULL && *symbolp == NULL);
symbol = lt_dlsym(handle, symbol_name);
if (symbol == NULL) {
const char *errmsg = lt_dlerror();
r = uv_dlsym(handle, symbol_name, &symbol);
if (r != 0) {
const char *errmsg = uv_dlerror(handle);
if (errmsg == NULL) {
errmsg = "returned function pointer is NULL";
}
@ -126,6 +127,7 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
ns_plugin_t *plugin = NULL;
ns_plugin_version_t *version_func = NULL;
int version;
int r;
REQUIRE(pluginp != NULL && *pluginp == NULL);
@ -137,13 +139,9 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
ISC_LINK_INIT(plugin, link);
if (lt_dlinit() != 0) {
CHECK(ISC_R_FAILURE);
}
plugin->handle = lt_dlopen(modpath);
if (plugin->handle == NULL) {
const char *errmsg = lt_dlerror();
r = uv_dlopen(modpath, &plugin->handle);
if (r != 0) {
const char *errmsg = uv_dlerror(&plugin->handle);
if (errmsg == NULL) {
errmsg = "unknown error";
}
@ -154,7 +152,7 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
CHECK(ISC_R_FAILURE);
}
CHECK(load_symbol(plugin->handle, modpath, "plugin_version",
CHECK(load_symbol(&plugin->handle, modpath, "plugin_version",
(void **)&version_func));
version = version_func();
@ -168,11 +166,11 @@ load_plugin(isc_mem_t *mctx, const char *modpath, ns_plugin_t **pluginp) {
CHECK(ISC_R_FAILURE);
}
CHECK(load_symbol(plugin->handle, modpath, "plugin_check",
CHECK(load_symbol(&plugin->handle, modpath, "plugin_check",
(void **)&plugin->check_func));
CHECK(load_symbol(plugin->handle, modpath, "plugin_register",
CHECK(load_symbol(&plugin->handle, modpath, "plugin_register",
(void **)&plugin->register_func));
CHECK(load_symbol(plugin->handle, modpath, "plugin_destroy",
CHECK(load_symbol(&plugin->handle, modpath, "plugin_destroy",
(void **)&plugin->destroy_func));
*pluginp = plugin;
@ -207,9 +205,7 @@ unload_plugin(ns_plugin_t **pluginp) {
plugin->destroy_func(&plugin->inst);
}
if (plugin->handle != NULL) {
(void)lt_dlclose(plugin->handle);
}
uv_dlclose(&plugin->handle);
isc_mem_free(plugin->mctx, plugin->modpath);
isc_mem_putanddetach(&plugin->mctx, plugin, sizeof(*plugin));
}

View File

@ -60,7 +60,7 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_USRDLL;LIBNS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\$(Configuration)\</AssemblerListingLocation>
@ -74,7 +74,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>@LIBUV_LIB@@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(ProjectName).def</ModuleDefinitionFile>
<ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary>
</Link>
@ -90,7 +90,7 @@
<IntrinsicFunctions>@INTRINSIC@</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_USRDLL;LIBNS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>..\..\..\config.h</ForcedIncludeFiles>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>.\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<StringPooling>true</StringPooling>
<PrecompiledHeaderOutputFile>.\$(Configuration)\$(TargetName).pch</PrecompiledHeaderOutputFile>
@ -107,7 +107,7 @@
<OptimizeReferences>true</OptimizeReferences>
<OutputFile>..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt)</OutputFile>
<AdditionalLibraryDirectories>..\..\isc\win32\$(Configuration);..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>@LIBUV_LIB@@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(ProjectName).def</ModuleDefinitionFile>
<ImportLibrary>.\$(Configuration)\$(ProjectName).lib</ImportLibrary>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>

View File

@ -2023,7 +2023,6 @@
./lib/isc/win32/libisc.vcxproj.filters.in X 2013,2014,2015,2016,2018,2019,2020
./lib/isc/win32/libisc.vcxproj.in X 2013,2014,2015,2016,2017,2018,2019,2020
./lib/isc/win32/libisc.vcxproj.user X 2013,2018,2019,2020
./lib/isc/win32/ltdl.h C 2020
./lib/isc/win32/meminfo.c C 2015,2016,2018,2019,2020
./lib/isc/win32/net.c C 1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2011,2012,2013,2014,2015,2016,2018,2019,2020
./lib/isc/win32/netdb.h C 2000,2001,2004,2006,2007,2009,2013,2016,2018,2019,2020

View File

@ -1,5 +1,3 @@
unmatchedSuppression:*
preprocessorErrorDirective:*
unknownMacro:*
uselessAssignmentPtrArg:libltdl/loaders/preopen.c:201
deallocret:libltdl/lt__alloc.c:78