]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Extend test-dlopen-so to also cover cases when built without support
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 23 May 2025 09:49:31 +0000 (11:49 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 17 Sep 2025 18:40:17 +0000 (19:40 +0100)
Let's make things more consistent and have all dlopen_xxx() functions
return EOPNOTSUPP on failure and verify this behavior in test-dlopen-so.

17 files changed:
src/basic/compress.c
src/basic/compress.h
src/basic/gcrypt-util.c
src/basic/gcrypt-util.h
src/shared/elf-util.c
src/shared/elf-util.h
src/shared/libfido2-util.c
src/shared/libfido2-util.h
src/shared/password-quality-util-passwdqc.c
src/shared/password-quality-util-passwdqc.h
src/shared/password-quality-util-pwquality.c
src/shared/password-quality-util-pwquality.h
src/shared/qrcode-util.c
src/shared/qrcode-util.h
src/shared/tpm2-util.c
src/shared/tpm2-util.h
src/test/test-dlopen-so.c

index 7cb12988dc41c606b6012501877acd541fe07a15..40bf6d4cbea41c81666b1fb56bc99e1311984bbe 100644 (file)
@@ -144,8 +144,8 @@ bool compression_supported(Compression c) {
         return BIT_SET(supported, c);
 }
 
-#if HAVE_XZ
 int dlopen_lzma(void) {
+#if HAVE_XZ
         ELF_NOTE_DLOPEN("lzma",
                         "Support lzma compression in journal and coredump files",
                         COMPRESSION_PRIORITY_XZ,
@@ -160,8 +160,10 @@ int dlopen_lzma(void) {
                         DLSYM_ARG(lzma_stream_buffer_encode),
                         DLSYM_ARG(lzma_lzma_preset),
                         DLSYM_ARG(lzma_stream_decoder));
-}
+#else
+        return -EOPNOTSUPP;
 #endif
+}
 
 int compress_blob_xz(const void *src, uint64_t src_size,
                      void *dst, size_t dst_alloc_size, size_t *dst_size, int level) {
@@ -213,8 +215,8 @@ int compress_blob_xz(const void *src, uint64_t src_size,
 #endif
 }
 
-#if HAVE_LZ4
 int dlopen_lz4(void) {
+#if HAVE_LZ4
         ELF_NOTE_DLOPEN("lz4",
                         "Support lz4 compression in journal and coredump files",
                         COMPRESSION_PRIORITY_LZ4,
@@ -238,8 +240,10 @@ int dlopen_lz4(void) {
                         DLSYM_ARG(LZ4_decompress_safe),
                         DLSYM_ARG(LZ4_decompress_safe_partial),
                         DLSYM_ARG(LZ4_versionNumber));
-}
+#else
+        return -EOPNOTSUPP;
 #endif
+}
 
 int compress_blob_lz4(const void *src, uint64_t src_size,
                       void *dst, size_t dst_alloc_size, size_t *dst_size, int level) {
@@ -278,8 +282,8 @@ int compress_blob_lz4(const void *src, uint64_t src_size,
 #endif
 }
 
-#if HAVE_ZSTD
 int dlopen_zstd(void) {
+#if HAVE_ZSTD
         ELF_NOTE_DLOPEN("zstd",
                         "Support zstd compression in journal and coredump files",
                         COMPRESSION_PRIORITY_ZSTD,
@@ -304,8 +308,10 @@ int dlopen_zstd(void) {
                         DLSYM_ARG(ZSTD_isError),
                         DLSYM_ARG(ZSTD_createDCtx),
                         DLSYM_ARG(ZSTD_createCCtx));
-}
+#else
+        return -EOPNOTSUPP;
 #endif
+}
 
 int compress_blob_zstd(
                 const void *src, uint64_t src_size,
index ce662920eb7c741e6e75a9e81a02ac18b9397d1f..dcd0e4a734206d3e18d69004d462da3de273478a 100644 (file)
@@ -62,17 +62,9 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_size);
 int decompress_stream_lz4(int fdf, int fdt, uint64_t max_size);
 int decompress_stream_zstd(int fdf, int fdt, uint64_t max_size);
 
-#if HAVE_LZ4
 int dlopen_lz4(void);
-#endif
-
-#if HAVE_ZSTD
 int dlopen_zstd(void);
-#endif
-
-#if HAVE_XZ
 int dlopen_lzma(void);
-#endif
 
 static inline int compress_blob(
                 Compression compression,
index bd73621c6fe505cc4a6d9d0aca8c550074a082b7..ebbc3e33bc736763792e66db778d095630316ff5 100644 (file)
@@ -1,11 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#if HAVE_GCRYPT
-
 #include <sys/syslog.h>
 
 #include "gcrypt-util.h"
 
+#if HAVE_GCRYPT
+
 static void *gcrypt_dl = NULL;
 
 static DLSYM_PROTOTYPE(gcry_control) = NULL;
@@ -40,8 +40,10 @@ DLSYM_PROTOTYPE(gcry_mpi_sub_ui) = NULL;
 DLSYM_PROTOTYPE(gcry_prime_check) = NULL;
 DLSYM_PROTOTYPE(gcry_randomize) = NULL;
 DLSYM_PROTOTYPE(gcry_strerror) = NULL;
+#endif
 
-static int dlopen_gcrypt(void) {
+int dlopen_gcrypt(void) {
+#if HAVE_GCRYPT
         ELF_NOTE_DLOPEN("gcrypt",
                         "Support for journald forward-sealing",
                         ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
@@ -82,9 +84,13 @@ static int dlopen_gcrypt(void) {
                         DLSYM_ARG(gcry_prime_check),
                         DLSYM_ARG(gcry_randomize),
                         DLSYM_ARG(gcry_strerror));
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
 int initialize_libgcrypt(bool secmem) {
+#if HAVE_GCRYPT
         int r;
 
         r = dlopen_gcrypt();
@@ -105,5 +111,7 @@ int initialize_libgcrypt(bool secmem) {
         sym_gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
 
         return 0;
-}
+#else
+        return -EOPNOTSUPP;
 #endif
+}
index 83e32babb55b4b93ce3997068df394479eb0c531..9fab3500a53906b5d5dd45dcab5feb04f5634dcf 100644 (file)
@@ -4,6 +4,10 @@
 
 #include "forward.h"
 
+int dlopen_gcrypt(void);
+
+int initialize_libgcrypt(bool secmem);
+
 #if HAVE_GCRYPT
 #include <gcrypt.h> /* IWYU pragma: export */
 
@@ -40,8 +44,6 @@ extern DLSYM_PROTOTYPE(gcry_prime_check);
 extern DLSYM_PROTOTYPE(gcry_randomize);
 extern DLSYM_PROTOTYPE(gcry_strerror);
 
-int initialize_libgcrypt(bool secmem);
-
 /* Copied from gcry_md_putc from gcrypt.h due to the need to call the sym_ variant */
 #define sym_gcry_md_putc(h,c)                              \
         do {                                               \
index a21167980d0f946c422f6d012a5bd9550f7a9ff8..78f8af5b070a65a3641935cbf0805a7ffd962445 100644 (file)
@@ -89,7 +89,10 @@ static DLSYM_PROTOTYPE(elf_version) = NULL;
 static DLSYM_PROTOTYPE(gelf_getphdr) = NULL;
 static DLSYM_PROTOTYPE(gelf_getnote) = NULL;
 
+#endif
+
 int dlopen_dw(void) {
+#if HAVE_ELFUTILS
         int r;
 
         ELF_NOTE_DLOPEN("dw",
@@ -138,9 +141,13 @@ int dlopen_dw(void) {
                 return r;
 
         return 1;
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
 int dlopen_elf(void) {
+#if HAVE_ELFUTILS
         int r;
 
         ELF_NOTE_DLOPEN("elf",
@@ -165,8 +172,13 @@ int dlopen_elf(void) {
                 return r;
 
         return 1;
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
+#if HAVE_ELFUTILS
+
 typedef struct StackContext {
         MemStream m;
         Dwfl *dwfl;
index 2a3251c28b038a189c95e5b44f2486bf322bfa62..41859cd169d27197dad8ecd40508b9af58b4d3a3 100644 (file)
@@ -3,10 +3,8 @@
 
 #include "forward.h"
 
-#if HAVE_ELFUTILS
 int dlopen_dw(void);
 int dlopen_elf(void);
-#endif
 
 /* Parse an ELF object in a forked process, so that errors while iterating over
  * untrusted and potentially malicious data do not propagate to the main caller's process.
index 0cc64c8674eb9a6a73f921718137957ed4e54c12..a4317971e194e16fdc97eca1070fadfe055a1623 100644 (file)
@@ -71,7 +71,10 @@ static void fido_log_propagate_handler(const char *s) {
         log_debug("libfido2: %s", strempty(s));
 }
 
+#endif
+
 int dlopen_libfido2(void) {
+#if HAVE_LIBFIDO2
         int r;
 
         ELF_NOTE_DLOPEN("fido2",
@@ -136,8 +139,13 @@ int dlopen_libfido2(void) {
         sym_fido_set_log_handler(fido_log_propagate_handler);
 
         return 0;
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
+#if HAVE_LIBFIDO2
+
 static int verify_features(
                 fido_dev_t *d,
                 const char *path,
index dbb4f1fc922e148bb3a83b671c1901535fc7aabe..c39cf73160f2bb67fef8965aca7d7ace5eec1038 100644 (file)
@@ -16,6 +16,8 @@ typedef enum Fido2EnrollFlags {
         _FIDO2ENROLL_TYPE_INVALID = -EINVAL,
 } Fido2EnrollFlags;
 
+int dlopen_libfido2(void);
+
 #if HAVE_LIBFIDO2
 #include <fido.h>
 
@@ -70,8 +72,6 @@ extern DLSYM_PROTOTYPE(fido_init);
 extern DLSYM_PROTOTYPE(fido_set_log_handler);
 extern DLSYM_PROTOTYPE(fido_strerr);
 
-int dlopen_libfido2(void);
-
 static inline void fido_cbor_info_free_wrapper(fido_cbor_info_t **p) {
         if (*p)
                 sym_fido_cbor_info_free(p);
index f4ecc6ce66d7ab612b803bf4ec13814b3e01d32b..d74e0fb7f2370e5561bb793dd72b02adc6d6dd3a 100644 (file)
@@ -4,7 +4,7 @@
 #include "errno-util.h"
 #include "log.h"
 #include "memory-util.h"
-#include "password-quality-util.h"
+#include "password-quality-util-passwdqc.h"
 #include "strv.h"
 
 #if HAVE_PASSWDQC
@@ -18,22 +18,6 @@ DLSYM_PROTOTYPE(passwdqc_params_free) = NULL;
 DLSYM_PROTOTYPE(passwdqc_check) = NULL;
 DLSYM_PROTOTYPE(passwdqc_random) = NULL;
 
-int dlopen_passwdqc(void) {
-        ELF_NOTE_DLOPEN("passwdqc",
-                        "Support for password quality checks",
-                        ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
-                        "libpasswdqc.so.1");
-
-        return dlopen_many_sym_or_warn(
-                        &passwdqc_dl, "libpasswdqc.so.1", LOG_DEBUG,
-                        DLSYM_ARG(passwdqc_params_reset),
-                        DLSYM_ARG(passwdqc_params_load),
-                        DLSYM_ARG(passwdqc_params_parse),
-                        DLSYM_ARG(passwdqc_params_free),
-                        DLSYM_ARG(passwdqc_check),
-                        DLSYM_ARG(passwdqc_random));
-}
-
 static int pwqc_allocate_context(passwdqc_params_t **ret) {
 
         _cleanup_(sym_passwdqc_params_freep) passwdqc_params_t *params = NULL;
@@ -144,3 +128,23 @@ int check_password_quality(
 }
 
 #endif
+
+int dlopen_passwdqc(void) {
+#if HAVE_PASSWDQC
+        ELF_NOTE_DLOPEN("passwdqc",
+                        "Support for password quality checks",
+                        ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
+                        "libpasswdqc.so.1");
+
+        return dlopen_many_sym_or_warn(
+                        &passwdqc_dl, "libpasswdqc.so.1", LOG_DEBUG,
+                        DLSYM_ARG(passwdqc_params_reset),
+                        DLSYM_ARG(passwdqc_params_load),
+                        DLSYM_ARG(passwdqc_params_parse),
+                        DLSYM_ARG(passwdqc_params_free),
+                        DLSYM_ARG(passwdqc_check),
+                        DLSYM_ARG(passwdqc_random));
+#else
+        return -EOPNOTSUPP;
+#endif
+}
index 121b75c501953f1669f020142eebf77a37823a2c..bda3be544ce9ea142f471503b1465d02f0b39be2 100644 (file)
@@ -15,11 +15,11 @@ extern DLSYM_PROTOTYPE(passwdqc_params_free);
 extern DLSYM_PROTOTYPE(passwdqc_check);
 extern DLSYM_PROTOTYPE(passwdqc_random);
 
-int dlopen_passwdqc(void);
-
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(passwdqc_params_t*, sym_passwdqc_params_free, NULL);
 
 int suggest_passwords(void);
 int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
 
 #endif
+
+int dlopen_passwdqc(void);
index ac46ac8430e587076781e12fb15562b7270475a6..49ea7d2fe2f20016eb42c45e171167e69f048a44 100644 (file)
@@ -8,6 +8,7 @@
 #include "errno-util.h"
 #include "log.h"
 #include "password-quality-util.h"
+#include "password-quality-util-pwquality.h"
 #include "string-util.h"
 #include "strv.h"
 
@@ -24,24 +25,6 @@ DLSYM_PROTOTYPE(pwquality_read_config) = NULL;
 DLSYM_PROTOTYPE(pwquality_set_int_value) = NULL;
 DLSYM_PROTOTYPE(pwquality_strerror) = NULL;
 
-int dlopen_pwquality(void) {
-        ELF_NOTE_DLOPEN("pwquality",
-                        "Support for password quality checks",
-                        ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
-                        "libpwquality.so.1");
-
-        return dlopen_many_sym_or_warn(
-                        &pwquality_dl, "libpwquality.so.1", LOG_DEBUG,
-                        DLSYM_ARG(pwquality_check),
-                        DLSYM_ARG(pwquality_default_settings),
-                        DLSYM_ARG(pwquality_free_settings),
-                        DLSYM_ARG(pwquality_generate),
-                        DLSYM_ARG(pwquality_get_str_value),
-                        DLSYM_ARG(pwquality_read_config),
-                        DLSYM_ARG(pwquality_set_int_value),
-                        DLSYM_ARG(pwquality_strerror));
-}
-
 static void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq) {
         char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
         const char *path;
@@ -163,3 +146,25 @@ int check_password_quality(const char *password, const char *old, const char *us
 }
 
 #endif
+
+int dlopen_pwquality(void) {
+#if HAVE_PWQUALITY
+        ELF_NOTE_DLOPEN("pwquality",
+                        "Support for password quality checks",
+                        ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
+                        "libpwquality.so.1");
+
+        return dlopen_many_sym_or_warn(
+                        &pwquality_dl, "libpwquality.so.1", LOG_DEBUG,
+                        DLSYM_ARG(pwquality_check),
+                        DLSYM_ARG(pwquality_default_settings),
+                        DLSYM_ARG(pwquality_free_settings),
+                        DLSYM_ARG(pwquality_generate),
+                        DLSYM_ARG(pwquality_get_str_value),
+                        DLSYM_ARG(pwquality_read_config),
+                        DLSYM_ARG(pwquality_set_int_value),
+                        DLSYM_ARG(pwquality_strerror));
+#else
+        return -EOPNOTSUPP;
+#endif
+}
index dbea6d24cad38d7b5edb261a578cb94b1ca05edb..0d12c76ad7b6ba59e64b6e82849d3c9b84a2879a 100644 (file)
@@ -17,11 +17,11 @@ extern DLSYM_PROTOTYPE(pwquality_read_config);
 extern DLSYM_PROTOTYPE(pwquality_set_int_value);
 extern DLSYM_PROTOTYPE(pwquality_strerror);
 
-int dlopen_pwquality(void);
-
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_settings, NULL);
 
 int suggest_passwords(void);
 int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
 
 #endif
+
+int dlopen_pwquality(void);
index 5e61e84a9e2b3f3debda12520c7c6503cfd83e8d..43ef871e74c026ba2e55106ef8f1e744ff80c244 100644 (file)
@@ -4,6 +4,7 @@
 
 #if HAVE_QRENCODE
 #include <qrencode.h>
+#endif
 #include <stdio.h>
 
 #include "ansi-color.h"
 #define UNICODE_LOWER_HALF_BLOCK UTF8("▄")
 #define UNICODE_UPPER_HALF_BLOCK UTF8("▀")
 
+#if HAVE_QRENCODE
 static void *qrcode_dl = NULL;
 
 static DLSYM_PROTOTYPE(QRcode_encodeString) = NULL;
 static DLSYM_PROTOTYPE(QRcode_free) = NULL;
+#endif
 
 int dlopen_qrencode(void) {
+#if HAVE_QRENCODE
         int r;
 
         ELF_NOTE_DLOPEN("qrencode",
@@ -41,8 +45,13 @@ int dlopen_qrencode(void) {
         }
 
         return r;
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
+#if HAVE_QRENCODE
+
 static void print_border(FILE *output, unsigned width, unsigned row, unsigned column) {
         assert(output);
         assert(width);
@@ -176,6 +185,8 @@ static void write_qrcode(FILE *output, QRcode *qr, unsigned row, unsigned column
 
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(QRcode*, sym_QRcode_free, NULL);
 
+#endif
+
 int print_qrcode_full(
                 FILE *out,
                 const char *header,
@@ -186,6 +197,7 @@ int print_qrcode_full(
                 unsigned tty_height,
                 bool check_tty) {
 
+#if HAVE_QRENCODE
         int r;
 
         /* If this is not a UTF-8 system or ANSI colors aren't supported/disabled don't print any QR
@@ -235,5 +247,7 @@ int print_qrcode_full(
         fputc('\n', out);
 
         return 0;
-}
+#else
+        return -EOPNOTSUPP;
 #endif
+}
index 7c9bb498931cacb52862cdec9a7d2b10775eaac2..a635810bfe3516f680731207b203dd71482c9896 100644 (file)
@@ -3,9 +3,6 @@
 
 #include "forward.h"
 
-#if HAVE_QRENCODE
-int dlopen_qrencode(void);
-
 int print_qrcode_full(
                 FILE *out,
                 const char *header,
@@ -15,19 +12,8 @@ int print_qrcode_full(
                 unsigned tty_width,
                 unsigned tty_height,
                 bool check_tty);
-#else
-static inline int print_qrcode_full(
-                FILE *out,
-                const char *header,
-                const char *string,
-                unsigned row,
-                unsigned column,
-                unsigned tty_width,
-                unsigned tty_height,
-                bool check_tty) {
-        return -EOPNOTSUPP;
-}
-#endif
+
+int dlopen_qrencode(void);
 
 static inline int print_qrcode(FILE *out, const char *header, const char *string) {
         return print_qrcode_full(out, header, string, UINT_MAX, UINT_MAX, UINT_MAX, UINT_MAX, true);
index 57e7a91f93345cc928269ba99fcbb68102735296..de1c56a84eedd1b52ec4abb5a762f7fcf7ce9bd5 100644 (file)
@@ -217,7 +217,10 @@ static int dlopen_tpm2_mu(void) {
                         DLSYM_ARG(Tss2_MU_UINT32_Marshal));
 }
 
+#endif
+
 int dlopen_tpm2(void) {
+#if HAVE_TPM2
         int r;
 
         r = dlopen_tpm2_esys();
@@ -233,8 +236,13 @@ int dlopen_tpm2(void) {
                 return r;
 
         return 0;
+#else
+        return -EOPNOTSUPP;
+#endif
 }
 
+#if HAVE_TPM2
+
 void Esys_Freep(void *p) {
         assert(p);
 
index 3205ac446fa39d7aca04352633ed6803b2870aa3..57674133bf216863f1904d7369582ab92cc28ccd 100644 (file)
@@ -39,14 +39,14 @@ static inline bool TPM2_PCR_MASK_VALID(uint32_t pcr_mask) {
 
 #define TPM2_N_HASH_ALGORITHMS 4U
 
+int dlopen_tpm2(void);
+
 #if HAVE_TPM2
 
 #include <tss2/tss2_esys.h>     /* IWYU pragma: export */
 #include <tss2/tss2_mu.h>       /* IWYU pragma: export */
 #include <tss2/tss2_rc.h>       /* IWYU pragma: export */
 
-int dlopen_tpm2(void);
-
 typedef struct Tpm2Context {
         unsigned n_ref;
 
index 97bb3be885328464f5b5a96ae06dcc7b09171664..870b2a67f8980b1b38507578fb10116f36920d21 100644 (file)
@@ -19,6 +19,9 @@
 #include "tests.h"
 #include "tpm2-util.h"
 
+#define ASSERT_DLOPEN(func, cond) \
+        cond ? ASSERT_OK(func()) : ASSERT_ERROR(func(), EOPNOTSUPP)
+
 static int run(int argc, char **argv) {
         test_setup_logging(LOG_DEBUG);
 
@@ -26,78 +29,25 @@ static int run(int argc, char **argv) {
          * where .so versions change and distributions update, but systemd doesn't have the new so names
          * around yet. */
 
-#if HAVE_LIBIDN2 || HAVE_LIBIDN
-        assert_se(dlopen_idn() >= 0);
-#endif
-
-#if HAVE_LIBCRYPTSETUP
-        assert_se(dlopen_cryptsetup() >= 0);
-#endif
-
-#if HAVE_PASSWDQC
-        assert_se(dlopen_passwdqc() >= 0);
-#endif
-
-#if HAVE_PWQUALITY
-        assert_se(dlopen_pwquality() >= 0);
-#endif
-
-#if HAVE_QRENCODE
-        assert_se(dlopen_qrencode() >= 0);
-#endif
-
-#if HAVE_TPM2
-        assert_se(dlopen_tpm2() >= 0);
-#endif
-
-#if HAVE_LIBFIDO2
-        assert_se(dlopen_libfido2() >= 0);
-#endif
-
-#if HAVE_LIBBPF
-        assert_se(dlopen_bpf() >= 0);
-#endif
-
-#if HAVE_ELFUTILS
-        assert_se(dlopen_dw() >= 0);
-        assert_se(dlopen_elf() >= 0);
-#endif
-
-#if HAVE_PCRE2
-        assert_se(dlopen_pcre2() >= 0);
-#endif
-
-#if HAVE_P11KIT
-        assert_se(dlopen_p11kit() >= 0);
-#endif
-
-#if HAVE_LIBARCHIVE
-        assert_se(dlopen_libarchive() >= 0);
-#endif
-
-#if HAVE_LZ4
-        assert_se(dlopen_lz4() >= 0);
-#endif
-
-#if HAVE_ZSTD
-        assert_se(dlopen_zstd() >= 0);
-#endif
-
-#if HAVE_XZ
-        assert_se(dlopen_lzma() >= 0);
-#endif
-
-#if HAVE_GCRYPT
-        assert_se(initialize_libgcrypt(/* secmem= */ false) >= 0);
-#endif
-
-#if HAVE_KMOD
-        assert_se(dlopen_libkmod() >= 0);
-#endif
-
-#if HAVE_APPARMOR
-        assert_se(dlopen_libapparmor() >= 0);
-#endif
+        ASSERT_DLOPEN(dlopen_idn, HAVE_LIBIDN2 || HAVE_LIBIDN);
+        ASSERT_DLOPEN(dlopen_cryptsetup, HAVE_LIBCRYPTSETUP);
+        ASSERT_DLOPEN(dlopen_passwdqc, HAVE_PASSWDQC);
+        ASSERT_DLOPEN(dlopen_pwquality, HAVE_PWQUALITY);
+        ASSERT_DLOPEN(dlopen_qrencode, HAVE_QRENCODE);
+        ASSERT_DLOPEN(dlopen_tpm2, HAVE_TPM2);
+        ASSERT_DLOPEN(dlopen_libfido2, HAVE_LIBFIDO2);
+        ASSERT_DLOPEN(dlopen_bpf, HAVE_LIBBPF);
+        ASSERT_DLOPEN(dlopen_dw, HAVE_ELFUTILS);
+        ASSERT_DLOPEN(dlopen_elf, HAVE_ELFUTILS);
+        ASSERT_DLOPEN(dlopen_pcre2, HAVE_PCRE2);
+        ASSERT_DLOPEN(dlopen_p11kit, HAVE_P11KIT);
+        ASSERT_DLOPEN(dlopen_libarchive, HAVE_LIBARCHIVE);
+        ASSERT_DLOPEN(dlopen_lz4, HAVE_LZ4);
+        ASSERT_DLOPEN(dlopen_zstd, HAVE_ZSTD);
+        ASSERT_DLOPEN(dlopen_lzma, HAVE_XZ);
+        ASSERT_DLOPEN(dlopen_gcrypt, HAVE_GCRYPT);
+        ASSERT_DLOPEN(dlopen_libkmod, HAVE_KMOD);
+        ASSERT_DLOPEN(dlopen_libapparmor, HAVE_APPARMOR);
 
         return 0;
 }