Each dlopen_*() wrapper kept its dl handle as a file-scope 'static void *xxx_dl = NULL;' even though only the wrapper itself ever referenced it. Move each one inside the corresponding function so its scope matches its actual use, leaving the rest of each translation unit free of the unused file-scope name. In pcre2-util.c the assert(pcre2_dl) in pattern_matches_and_log() becomes assert(sym_pcre2_match), which carries the same invariant (pattern_compile_and_log() ran dlopen_pcre2()).
52 lines
2.0 KiB
C
52 lines
2.0 KiB
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#include "sd-dlopen.h"
|
|
|
|
#include "gnutls-util.h"
|
|
#include "log.h" /* IWYU pragma: keep */
|
|
|
|
#if HAVE_GNUTLS
|
|
DLSYM_PROTOTYPE(gnutls_certificate_get_peers) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_certificate_type_get) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_certificate_verification_status_print) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_certificate_verify_peers2) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_free) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_global_set_log_function) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_global_set_log_level) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_x509_crt_deinit) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_x509_crt_get_dn) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_x509_crt_import) = NULL;
|
|
DLSYM_PROTOTYPE(gnutls_x509_crt_init) = NULL;
|
|
#endif
|
|
|
|
int dlopen_gnutls(int log_level) {
|
|
#if HAVE_GNUTLS
|
|
static void *gnutls_dl = NULL;
|
|
|
|
SD_ELF_NOTE_DLOPEN(
|
|
"gnutls",
|
|
"Support for TLS via GnuTLS",
|
|
SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
|
|
"libgnutls.so.30");
|
|
|
|
return dlopen_many_sym_or_warn(
|
|
&gnutls_dl,
|
|
"libgnutls.so.30",
|
|
log_level,
|
|
DLSYM_ARG(gnutls_certificate_get_peers),
|
|
DLSYM_ARG(gnutls_certificate_type_get),
|
|
DLSYM_ARG(gnutls_certificate_verification_status_print),
|
|
DLSYM_ARG(gnutls_certificate_verify_peers2),
|
|
DLSYM_ARG(gnutls_free),
|
|
DLSYM_ARG(gnutls_global_set_log_function),
|
|
DLSYM_ARG(gnutls_global_set_log_level),
|
|
DLSYM_ARG(gnutls_x509_crt_deinit),
|
|
DLSYM_ARG(gnutls_x509_crt_get_dn),
|
|
DLSYM_ARG(gnutls_x509_crt_import),
|
|
DLSYM_ARG(gnutls_x509_crt_init));
|
|
#else
|
|
return log_full_errno(log_level, SYNTHETIC_ERRNO(EOPNOTSUPP),
|
|
"gnutls support is not compiled in.");
|
|
#endif
|
|
}
|