From 37b9511ce1dd9ba66a6620c5ff617016eb81188f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Tue, 20 Oct 2020 23:51:08 +0200 Subject: [PATCH] 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. --- .gitignore | 1 - .gitlab-ci.yml | 6 +-- .lgtm.yml | 1 - Makefile.am | 2 +- Makefile.top | 6 --- README.md | 1 - bin/named/Makefile.am | 1 - bin/named/unix/dlz_dlopen_driver.c | 26 +++++------ bin/plugins/filter-aaaa.c | 5 --- bin/tests/system/dlzexternal/driver/driver.c | 15 ------- .../system/dlzexternal/ns1/named.conf.in | 12 +++--- bin/tests/system/dyndb/driver/driver.c | 4 -- bin/tests/system/dyndb/ns1/named.conf.in | 4 +- bin/tests/system/filter-aaaa/conf/bad1.conf | 2 +- bin/tests/system/filter-aaaa/conf/bad2.conf | 2 +- bin/tests/system/filter-aaaa/conf/bad3.conf | 2 +- bin/tests/system/filter-aaaa/conf/bad4.conf | 2 +- bin/tests/system/filter-aaaa/conf/bad5.conf | 2 +- bin/tests/system/filter-aaaa/conf/good1.conf | 2 +- bin/tests/system/filter-aaaa/conf/good2.conf | 2 +- bin/tests/system/filter-aaaa/conf/good3.conf | 2 +- bin/tests/system/filter-aaaa/conf/good4.conf | 2 +- bin/tests/system/filter-aaaa/conf/good5.conf | 2 +- .../system/filter-aaaa/ns1/named1.conf.in | 2 +- .../system/filter-aaaa/ns1/named2.conf.in | 2 +- .../system/filter-aaaa/ns2/named1.conf.in | 2 +- .../system/filter-aaaa/ns2/named2.conf.in | 2 +- .../system/filter-aaaa/ns3/named1.conf.in | 2 +- .../system/filter-aaaa/ns3/named2.conf.in | 2 +- .../system/filter-aaaa/ns4/named1.conf.in | 2 +- .../system/filter-aaaa/ns4/named2.conf.in | 2 +- .../system/filter-aaaa/ns5/named.conf.in | 2 +- configure.ac | 4 -- lib/dns/Makefile.am | 9 ++-- lib/dns/dyndb.c | 34 +++++++-------- lib/dns/win32/libdns.vcxproj.in | 8 ++-- lib/isc/Makefile.am | 1 - lib/isc/win32/ltdl.h | 43 ------------------- lib/ns/Makefile.am | 7 +-- lib/ns/hooks.c | 36 +++++++--------- lib/ns/win32/libns.vcxproj.in | 8 ++-- util/copyrights | 1 - util/suppressions.txt | 2 - 43 files changed, 90 insertions(+), 185 deletions(-) delete mode 100644 lib/isc/win32/ltdl.h diff --git a/.gitignore b/.gitignore index 871997de02..11d5f33890 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,6 @@ __pycache__/ /depcomp /install-sh /isc-config.sh -/libltdl/* /libtool /ltmain.sh /m4/libtool.m4 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b6fc343daa..99ba57ceeb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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: diff --git a/.lgtm.yml b/.lgtm.yml index faf16513fa..3f36c409fa 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -29,7 +29,6 @@ path_classifiers: - "**/*.5" - "**/*.8" queries: - - exclude: libltdl/ - exclude: fuzz/ - exclude: "bin/tests/system/*/ans*/*.py" - exclude: cpp/use-of-goto diff --git a/Makefile.am b/Makefile.am index 88c72f144d..f2005cfab7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 diff --git a/Makefile.top b/Makefile.top index 66aaecf7bd..c784c17518 100644 --- a/Makefile.top +++ b/Makefile.top @@ -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 diff --git a/README.md b/README.md index 18a2ae3eb6..3921107923 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,6 @@ installed: autoconf (includes autoreconf) automake libtool - libltdl-dev (Debian) / libtool-ltdl-dev (Fedora/CentOS) / libltdl (FreeBSD) #### Compile-time options diff --git a/bin/named/Makefile.am b/bin/named/Makefile.am index ce783b8c30..1c9483a0c5 100644 --- a/bin/named/Makefile.am +++ b/bin/named/Makefile.am @@ -9,7 +9,6 @@ AM_CPPFLAGS += \ $(LIBISCCC_CFLAGS) \ $(LIBISCCFG_CFLAGS) \ $(LIBBIND9_CFLAGS) \ - $(LIBLTDL_CFLAGS) \ $(OPENSSL_CFLAGS) \ $(LIBCAP_CFLAGS) \ $(LMDB_CFLAGS) \ diff --git a/bin/named/unix/dlz_dlopen_driver.c b/bin/named/unix/dlz_dlopen_driver.c index 4cee110f78..df11984970 100644 --- a/bin/named/unix/dlz_dlopen_driver.c +++ b/bin/named/unix/dlz_dlopen_driver.c @@ -10,11 +10,11 @@ */ #include -#include #include #include #include #include +#include #include #include @@ -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); diff --git a/bin/plugins/filter-aaaa.c b/bin/plugins/filter-aaaa.c index 3ba38f8fc2..f530b596ad 100644 --- a/bin/plugins/filter-aaaa.c +++ b/bin/plugins/filter-aaaa.c @@ -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 #include #include diff --git a/bin/tests/system/dlzexternal/driver/driver.c b/bin/tests/system/dlzexternal/driver/driver.c index 952171b38b..3a98a32f5b 100644 --- a/bin/tests/system/dlzexternal/driver/driver.c +++ b/bin/tests/system/dlzexternal/driver/driver.c @@ -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; diff --git a/bin/tests/system/dlzexternal/ns1/named.conf.in b/bin/tests/system/dlzexternal/ns1/named.conf.in index 8eb46cc33f..1fa0d45809 100644 --- a/bin/tests/system/dlzexternal/ns1/named.conf.in +++ b/bin/tests/system/dlzexternal/ns1/named.conf.in @@ -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; }; diff --git a/bin/tests/system/dyndb/driver/driver.c b/bin/tests/system/dyndb/driver/driver.c index 0ed2937bce..1af50c6c14 100644 --- a/bin/tests/system/dyndb/driver/driver.c +++ b/bin/tests/system/dyndb/driver/driver.c @@ -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; diff --git a/bin/tests/system/dyndb/ns1/named.conf.in b/bin/tests/system/dyndb/ns1/named.conf.in index 49828ef620..bc49e5d64a 100644 --- a/bin/tests/system/dyndb/ns1/named.conf.in +++ b/bin/tests/system/dyndb/ns1/named.conf.in @@ -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. }; diff --git a/bin/tests/system/filter-aaaa/conf/bad1.conf b/bin/tests/system/filter-aaaa/conf/bad1.conf index 97ce0dcad7..e09f27e6f3 100644 --- a/bin/tests/system/filter-aaaa/conf/bad1.conf +++ b/bin/tests/system/filter-aaaa/conf/bad1.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/bad2.conf b/bin/tests/system/filter-aaaa/conf/bad2.conf index a9410aa523..bc22c3a9e7 100644 --- a/bin/tests/system/filter-aaaa/conf/bad2.conf +++ b/bin/tests/system/filter-aaaa/conf/bad2.conf @@ -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 diff --git a/bin/tests/system/filter-aaaa/conf/bad3.conf b/bin/tests/system/filter-aaaa/conf/bad3.conf index 091cf147aa..9d4aa9a6fd 100644 --- a/bin/tests/system/filter-aaaa/conf/bad3.conf +++ b/bin/tests/system/filter-aaaa/conf/bad3.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/bad4.conf b/bin/tests/system/filter-aaaa/conf/bad4.conf index a21ac4fdfb..2db334c815 100644 --- a/bin/tests/system/filter-aaaa/conf/bad4.conf +++ b/bin/tests/system/filter-aaaa/conf/bad4.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/bad5.conf b/bin/tests/system/filter-aaaa/conf/bad5.conf index 54c3abb9ee..7aa2633e58 100644 --- a/bin/tests/system/filter-aaaa/conf/bad5.conf +++ b/bin/tests/system/filter-aaaa/conf/bad5.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/good1.conf b/bin/tests/system/filter-aaaa/conf/good1.conf index 9f29bfd15b..d1b26c55d4 100644 --- a/bin/tests/system/filter-aaaa/conf/good1.conf +++ b/bin/tests/system/filter-aaaa/conf/good1.conf @@ -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; }; diff --git a/bin/tests/system/filter-aaaa/conf/good2.conf b/bin/tests/system/filter-aaaa/conf/good2.conf index 93c7abdb48..fb9073a0fc 100644 --- a/bin/tests/system/filter-aaaa/conf/good2.conf +++ b/bin/tests/system/filter-aaaa/conf/good2.conf @@ -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; }; diff --git a/bin/tests/system/filter-aaaa/conf/good3.conf b/bin/tests/system/filter-aaaa/conf/good3.conf index 853f341aa1..4021d34e1e 100644 --- a/bin/tests/system/filter-aaaa/conf/good3.conf +++ b/bin/tests/system/filter-aaaa/conf/good3.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/good4.conf b/bin/tests/system/filter-aaaa/conf/good4.conf index dad7b5bfc3..0cdb747c21 100644 --- a/bin/tests/system/filter-aaaa/conf/good4.conf +++ b/bin/tests/system/filter-aaaa/conf/good4.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/conf/good5.conf b/bin/tests/system/filter-aaaa/conf/good5.conf index c26e57a5d6..0c2cd6e52c 100644 --- a/bin/tests/system/filter-aaaa/conf/good5.conf +++ b/bin/tests/system/filter-aaaa/conf/good5.conf @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns1/named1.conf.in b/bin/tests/system/filter-aaaa/ns1/named1.conf.in index a72007d76e..6996b9601c 100644 --- a/bin/tests/system/filter-aaaa/ns1/named1.conf.in +++ b/bin/tests/system/filter-aaaa/ns1/named1.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns1/named2.conf.in b/bin/tests/system/filter-aaaa/ns1/named2.conf.in index fbc4b721d5..7fcaec11e5 100644 --- a/bin/tests/system/filter-aaaa/ns1/named2.conf.in +++ b/bin/tests/system/filter-aaaa/ns1/named2.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns2/named1.conf.in b/bin/tests/system/filter-aaaa/ns2/named1.conf.in index bd20634170..bb2f6cbfc2 100644 --- a/bin/tests/system/filter-aaaa/ns2/named1.conf.in +++ b/bin/tests/system/filter-aaaa/ns2/named1.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns2/named2.conf.in b/bin/tests/system/filter-aaaa/ns2/named2.conf.in index 831e017f6f..9d779d9870 100644 --- a/bin/tests/system/filter-aaaa/ns2/named2.conf.in +++ b/bin/tests/system/filter-aaaa/ns2/named2.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns3/named1.conf.in b/bin/tests/system/filter-aaaa/ns3/named1.conf.in index db30e0b469..602fadd573 100644 --- a/bin/tests/system/filter-aaaa/ns3/named1.conf.in +++ b/bin/tests/system/filter-aaaa/ns3/named1.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns3/named2.conf.in b/bin/tests/system/filter-aaaa/ns3/named2.conf.in index 48dc568cf1..372cf66b11 100644 --- a/bin/tests/system/filter-aaaa/ns3/named2.conf.in +++ b/bin/tests/system/filter-aaaa/ns3/named2.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns4/named1.conf.in b/bin/tests/system/filter-aaaa/ns4/named1.conf.in index 44fcd7cdbc..0f48a9e541 100644 --- a/bin/tests/system/filter-aaaa/ns4/named1.conf.in +++ b/bin/tests/system/filter-aaaa/ns4/named1.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns4/named2.conf.in b/bin/tests/system/filter-aaaa/ns4/named2.conf.in index 93af1bae13..c11a8024ed 100644 --- a/bin/tests/system/filter-aaaa/ns4/named2.conf.in +++ b/bin/tests/system/filter-aaaa/ns4/named2.conf.in @@ -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; }; }; diff --git a/bin/tests/system/filter-aaaa/ns5/named.conf.in b/bin/tests/system/filter-aaaa/ns5/named.conf.in index 4712c5aef4..4d3aa0b76e 100644 --- a/bin/tests/system/filter-aaaa/ns5/named.conf.in +++ b/bin/tests/system/filter-aaaa/ns5/named.conf.in @@ -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; }; }; diff --git a/configure.ac b/configure.ac index 54ea36f2c3..6c16a76c19 100644 --- a/configure.ac +++ b/configure.ac @@ -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 # diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 78bd453f90..e830aed295 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -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 diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c index b91a2b9f26..d9c536e91d 100644 --- a/lib/dns/dyndb.c +++ b/lib/dns/dyndb.c @@ -9,8 +9,8 @@ * information regarding copyright ownership. */ -#include #include +#include #include #include @@ -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)); } diff --git a/lib/dns/win32/libdns.vcxproj.in b/lib/dns/win32/libdns.vcxproj.in index 6c9fbd62b8..cc008979dd 100644 --- a/lib/dns/win32/libdns.vcxproj.in +++ b/lib/dns/win32/libdns.vcxproj.in @@ -61,7 +61,7 @@ Disabled BIND9;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDNS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions);%(PreprocessorDefinitions) ..\..\..\config.h - .\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) + .\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) true .\$(Configuration)\$(TargetName).pch .\$(Configuration)\ @@ -75,7 +75,7 @@ true ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) ..\..\isc\win32\$(Configuration);%(AdditionalLibraryDirectories) - @OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) + @LIBUV_LIB@@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) $(ProjectName).def .\$(Configuration)\$(ProjectName).lib @@ -91,7 +91,7 @@ @INTRINSIC@ BIND9;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDNS_EXPORTS;%(PreprocessorDefinitions);%(PreprocessorDefinitions);%(PreprocessorDefinitions) ..\..\..\config.h - .\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) + .\;..\..\..\;include;..\include;..\..\isc;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) OnlyExplicitInline true .\$(Configuration)\$(TargetName).pch @@ -108,7 +108,7 @@ true ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) ..\..\isc\win32\$(Configuration);%(AdditionalLibraryDirectories) - @OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) + @LIBUV_LIB@@OPENSSL_LIB@libisc.lib;@LIBXML2_LIB@@GSSAPI_LIB@@KRB5_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) $(ProjectName).def .\$(Configuration)\$(ProjectName).lib Default diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 717da02e56..7b025e1d0d 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -230,7 +230,6 @@ libisc_la_LDFLAGS = \ $(libisc_VERSION_INFO) libisc_la_LIBADD = \ - $(LIBLTDL_LIBS) \ $(LIBUV_LIBS) \ $(OPENSSL_LIBS) \ $(ZLIB_LIBS) diff --git a/lib/isc/win32/ltdl.h b/lib/isc/win32/ltdl.h deleted file mode 100644 index c032524061..0000000000 --- a/lib/isc/win32/ltdl.h +++ /dev/null @@ -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 - -#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); -} diff --git a/lib/ns/Makefile.am b/lib/ns/Makefile.am index 7f79af4292..5c93b2e85b 100644 --- a/lib/ns/Makefile.am +++ b/lib/ns/Makefile.am @@ -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) \ diff --git a/lib/ns/hooks.c b/lib/ns/hooks.c index 4e9bc9e632..9cb2fe4fb8 100644 --- a/lib/ns/hooks.c +++ b/lib/ns/hooks.c @@ -12,9 +12,9 @@ /*! \file */ #include -#include #include #include +#include #include #include @@ -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)); } diff --git a/lib/ns/win32/libns.vcxproj.in b/lib/ns/win32/libns.vcxproj.in index 48488d14e0..41604ba171 100644 --- a/lib/ns/win32/libns.vcxproj.in +++ b/lib/ns/win32/libns.vcxproj.in @@ -60,7 +60,7 @@ Disabled WIN32;_DEBUG;_USRDLL;LIBNS_EXPORTS;%(PreprocessorDefinitions) ..\..\..\config.h - .\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) + .\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) true .\$(Configuration)\$(TargetName).pch .\$(Configuration)\ @@ -74,7 +74,7 @@ true ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) ..\..\isc\win32\$(Configuration);..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories) - @OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) + @LIBUV_LIB@@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) $(ProjectName).def .\$(Configuration)\$(ProjectName).lib @@ -90,7 +90,7 @@ @INTRINSIC@ WIN32;NDEBUG;_USRDLL;LIBNS_EXPORTS;%(PreprocessorDefinitions) ..\..\..\config.h - .\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) + .\;..\..\..\;include;..\include;..\..\isc\win32;..\..\isc\win32\include;..\..\isc\include;..\..\..\lib\dns\include;@LIBXML2_INC@@LIBUV_INC@@OPENSSL_INC@@GSSAPI_INC@@GEOIP_INC@%(AdditionalIncludeDirectories) OnlyExplicitInline true .\$(Configuration)\$(TargetName).pch @@ -107,7 +107,7 @@ true ..\..\..\Build\$(Configuration)\$(TargetName)$(TargetExt) ..\..\isc\win32\$(Configuration);..\..\..\lib\dns\win32\$(Configuration);%(AdditionalLibraryDirectories) - @OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) + @LIBUV_LIB@@OPENSSL_LIB@libisc.lib;libdns.lib;@LIBXML2_LIB@@GSSAPI_LIB@@GEOIP_LIB@ws2_32.lib;%(AdditionalDependencies) $(ProjectName).def .\$(Configuration)\$(ProjectName).lib Default diff --git a/util/copyrights b/util/copyrights index 20d0240542..c3f702b7a7 100644 --- a/util/copyrights +++ b/util/copyrights @@ -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 diff --git a/util/suppressions.txt b/util/suppressions.txt index bb86dd6fb2..ea5ff3b292 100644 --- a/util/suppressions.txt +++ b/util/suppressions.txt @@ -1,5 +1,3 @@ unmatchedSuppression:* preprocessorErrorDirective:* unknownMacro:* -uselessAssignmentPtrArg:libltdl/loaders/preopen.c:201 -deallocret:libltdl/lt__alloc.c:78