diff --git a/meson.build b/meson.build index b9de4656b70..30ed31b03c7 100644 --- a/meson.build +++ b/meson.build @@ -1416,11 +1416,11 @@ endif # In the dlopen ELF note we save the default compression library with a # higher priority, so that packages can give it priority over the # secondary libraries. -conf.set_quoted('COMPRESSION_PRIORITY_ZSTD', +conf.set('COMPRESSION_PRIORITY_ZSTD', compression == 'zstd' ? 'recommended' : 'suggested') -conf.set_quoted('COMPRESSION_PRIORITY_LZ4', +conf.set('COMPRESSION_PRIORITY_LZ4', compression == 'lz4' ? 'recommended' : 'suggested') -conf.set_quoted('COMPRESSION_PRIORITY_XZ', +conf.set('COMPRESSION_PRIORITY_XZ', compression == 'xz' ? 'recommended' : 'suggested') conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper())) diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c index fbef7e3d2e8..c0481c72ec4 100644 --- a/src/analyze/analyze-security.c +++ b/src/analyze/analyze-security.c @@ -626,7 +626,7 @@ static int assess_system_call_filter( uint64_t b; int r; - r = DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended); if (r < 0) { *ret_badness = UINT64_MAX; *ret_description = NULL; @@ -2604,7 +2604,7 @@ static int get_security_info(Unit *u, ExecContext *c, CGroupContext *g, RuntimeS info->_umask = c->umask; #if HAVE_SECCOMP - if (DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) >= 0) { + if (DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended) >= 0) { SET_FOREACH(key, c->syscall_archs) { const char *name; diff --git a/src/basic/compress.c b/src/basic/compress.c index 70d0b7ced31..350c612eae7 100644 --- a/src/basic/compress.c +++ b/src/basic/compress.c @@ -43,12 +43,11 @@ #include #endif -#include "sd-dlopen.h" - #include "alloc-util.h" #include "bitfield.h" #include "compress.h" #include "dlfcn-util.h" +#include "dlopen-note.h" #include "io-util.h" #include "log.h" #include "string-table.h" @@ -293,11 +292,7 @@ int dlopen_xz(int log_level) { #if HAVE_XZ static void *lzma_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "lzma", - "Support lzma compression in journal and coredump files", - COMPRESSION_PRIORITY_XZ, - "liblzma.so.5"); + LIBLZMA_NOTE(COMPRESSION_PRIORITY_XZ); return dlopen_many_sym_or_warn( &lzma_dl, @@ -318,11 +313,7 @@ int dlopen_lz4(int log_level) { #if HAVE_LZ4 static void *lz4_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "lz4", - "Support lz4 compression in journal and coredump files", - COMPRESSION_PRIORITY_LZ4, - "liblz4.so.1"); + LIBLZ4_NOTE(COMPRESSION_PRIORITY_LZ4); return dlopen_many_sym_or_warn( &lz4_dl, @@ -352,11 +343,7 @@ int dlopen_zstd(int log_level) { #if HAVE_ZSTD static void *zstd_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "zstd", - "Support zstd compression in journal and coredump files", - COMPRESSION_PRIORITY_ZSTD, - "libzstd.so.1"); + LIBZSTD_NOTE(COMPRESSION_PRIORITY_ZSTD); return dlopen_many_sym_or_warn( &zstd_dl, @@ -387,11 +374,7 @@ int dlopen_zlib(int log_level) { #if HAVE_ZLIB static void *zlib_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "zlib", - "Support gzip compression and decompression", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libz.so.1"); + LIBZ_NOTE(suggested); return dlopen_many_sym_or_warn( &zlib_dl, @@ -412,11 +395,7 @@ int dlopen_bzip2(int log_level) { #if HAVE_BZIP2 static void *bzip2_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "bzip2", - "Support bzip2 compression and decompression", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libbz2.so.1"); + LIBBZ2_NOTE(suggested); return dlopen_many_sym_or_warn( &bzip2_dl, diff --git a/src/basic/dlopen-note.h b/src/basic/dlopen-note.h new file mode 100644 index 00000000000..302dd0999a0 --- /dev/null +++ b/src/basic/dlopen-note.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "sd-dlopen.h" + +#include "basic-forward.h" +#include "strv.h" + +/* Avoid invalid priority. */ +#define _DLOPEN_CHECK_PRIORITY_required 1 +#define _DLOPEN_CHECK_PRIORITY_recommended 1 +#define _DLOPEN_CHECK_PRIORITY_suggested 1 + +/* Unlike SD_ELF_NOTE_DLOPEN_ANCHORED(), this takes feature and priority without quotation. */ +#define ELF_NOTE_DLOPEN_ANCHORED(feature, description, priority, ...) \ + assert_cc(_DLOPEN_CHECK_PRIORITY_##priority); \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + feature##_##priority, \ + STRINGIFY(feature), \ + description, \ + STRINGIFY(priority), \ + __VA_ARGS__) + +#if HAVE_BZIP2 +# define LIBBZ2_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + bzip2, \ + "Support bzip2 compression and decompression", \ + priority, \ + "libbz2.so.1") +#else +# define LIBBZ2_NOTE(priority) +#endif + +#if HAVE_LZ4 +# define LIBLZ4_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + lz4, \ + "Support lz4 compression in journal and coredump files", \ + priority, \ + "liblz4.so.1") +#else +# define LIBLZ4_NOTE(priority) +#endif + +#if HAVE_XZ +# define LIBLZMA_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + lzma, \ + "Support lzma compression in journal and coredump files", \ + priority, \ + "liblzma.so.5") +#else +# define LIBLZMA_NOTE(priority) +#endif + +#if HAVE_ZLIB +# define LIBZ_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + zlib, \ + "Support gzip compression and decompression", \ + priority, \ + "libz.so.1") +#else +# define LIBZ_NOTE(priority) +#endif + +#if HAVE_ZSTD +# define LIBZSTD_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + zstd, \ + "Support zstd compression in journal and coredump files", \ + priority, \ + "libzstd.so.1") +#else +# define LIBZSTD_NOTE(priority) +#endif + +#define COMPRESS_NOTE(priority) \ + LIBBZ2_NOTE(priority); \ + LIBLZ4_NOTE(priority); \ + LIBLZMA_NOTE(priority); \ + LIBZ_NOTE(priority); \ + LIBZSTD_NOTE(priority) + +#define COMPRESS_DEFAULT_NOTE \ + LIBBZ2_NOTE(suggested); \ + LIBLZ4_NOTE(COMPRESSION_PRIORITY_LZ4); \ + LIBLZMA_NOTE(COMPRESSION_PRIORITY_XZ); \ + LIBZ_NOTE(suggested); \ + LIBZSTD_NOTE(COMPRESSION_PRIORITY_ZSTD) diff --git a/src/bootctl/bootctl-install.c b/src/bootctl/bootctl-install.c index 3d8b0e65315..3453609792e 100644 --- a/src/bootctl/bootctl-install.c +++ b/src/bootctl/bootctl-install.c @@ -1085,7 +1085,7 @@ static int install_secure_boot_auto_enroll(InstallContext *c) { if (!c->secure_boot_certificate || !c->secure_boot_private_key) return 0; - r = DLOPEN_LIBCRYPTO(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/core/bpf-bind-iface.c b/src/core/bpf-bind-iface.c index 6d9ecadcec7..4b492f77ba4 100644 --- a/src/core/bpf-bind-iface.c +++ b/src/core/bpf-bind-iface.c @@ -31,7 +31,7 @@ int bpf_bind_network_interface_supported(void) { if (supported >= 0) return supported; - if (DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_BPF(LOG_WARNING, recommended) < 0) return (supported = false); obj = bind_iface_bpf__open(); diff --git a/src/core/bpf-restrict-fs.c b/src/core/bpf-restrict-fs.c index 5cae80a3135..33dba6d8dae 100644 --- a/src/core/bpf-restrict-fs.c +++ b/src/core/bpf-restrict-fs.c @@ -78,7 +78,7 @@ bool bpf_restrict_fs_supported(bool initialize) { if (!initialize) return false; - if (DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_BPF(LOG_WARNING, recommended) < 0) return (supported = false); r = lsm_supported("bpf"); diff --git a/src/core/bpf-restrict-fsaccess.c b/src/core/bpf-restrict-fsaccess.c index d132c34164d..18d291795e1 100644 --- a/src/core/bpf-restrict-fsaccess.c +++ b/src/core/bpf-restrict-fsaccess.c @@ -171,7 +171,7 @@ bool bpf_restrict_fsaccess_supported(void) { if (supported >= 0) return supported; - if (DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_BPF(LOG_WARNING, recommended) < 0) return (supported = false); r = lsm_supported("bpf"); @@ -340,7 +340,7 @@ static int restrict_fsaccess_validate_deserialized_fds(Manager *m) { assert(m); - r = DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_BPF(LOG_WARNING, recommended); if (r < 0) return log_error_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE), "bpf-restrict-fsaccess: Failed to load libbpf for FD validation, aborting."); diff --git a/src/core/bpf-restrict-ifaces.c b/src/core/bpf-restrict-ifaces.c index 9ca144a334e..e6b32923805 100644 --- a/src/core/bpf-restrict-ifaces.c +++ b/src/core/bpf-restrict-ifaces.c @@ -86,7 +86,7 @@ int bpf_restrict_ifaces_supported(void) { if (supported >= 0) return supported; - if (DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_BPF(LOG_WARNING, recommended) < 0) return (supported = false); r = prepare_restrict_ifaces_bpf(NULL, true, NULL, &obj); diff --git a/src/core/bpf-socket-bind.c b/src/core/bpf-socket-bind.c index 3751d624308..47f0d209f75 100644 --- a/src/core/bpf-socket-bind.c +++ b/src/core/bpf-socket-bind.c @@ -125,7 +125,7 @@ int bpf_socket_bind_supported(void) { _cleanup_(socket_bind_bpf_freep) struct socket_bind_bpf *obj = NULL; int r; - if (DLOPEN_BPF(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_BPF(LOG_WARNING, recommended) < 0) return false; r = prepare_socket_bind_bpf(/* unit= */ NULL, /* allow_rules= */ NULL, /* deny_rules= */ NULL, &obj); diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index 7a7f7f2a709..b232cd015cc 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -1310,7 +1310,7 @@ static int setup_pam( * parent process will exec() the actual daemon. We do things this way to ensure that the main PID of * the daemon is the one we initially fork()ed. */ - r = DLOPEN_LIBPAM(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBPAM(LOG_ERR, recommended); if (r < 0) return r; @@ -1576,7 +1576,7 @@ static bool seccomp_allows_drop_privileges(const ExecContext *c) { assert(c); /* No libseccomp, all is fine */ - if (DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended) < 0) return true; /* No syscall filter, we are allowed to drop privileges */ @@ -1886,7 +1886,7 @@ static int apply_restrict_filesystems(const ExecContext *c, const ExecParameters } /* We are in a new binary, so dl-open again */ - r = DLOPEN_BPF(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_BPF(LOG_DEBUG, recommended); if (r < 0) return r; @@ -6000,12 +6000,12 @@ int exec_invoke( } /* Load a bunch of libraries we'll possibly need later, before we turn off dlopen() */ - (void) DLOPEN_BPF(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + (void) DLOPEN_BPF(LOG_DEBUG, recommended); + (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, recommended); + (void) DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended); /* Needed for userspace verity verification fallback */ - (void) DLOPEN_LIBCRYPTO(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + (void) DLOPEN_LIBCRYPTO(LOG_DEBUG, recommended); /* Let's now disable further dlopen()ing of libraries, since we are about to do namespace * shenanigans, and do not want to mix resources from host and namespace */ diff --git a/src/core/execute.c b/src/core/execute.c index 4240e01d0be..f581b5c120b 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -1575,7 +1575,7 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { fputc('~', f); #if HAVE_SECCOMP - if (DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) >= 0) { + if (DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended) >= 0) { void *id, *val; bool first = true; HASHMAP_FOREACH_KEY(val, id, c->syscall_filter) { @@ -1994,7 +1994,7 @@ char** exec_context_get_syscall_filter(const ExecContext *c) { assert(c); #if HAVE_SECCOMP - if (DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended) < 0) return strv_new(NULL); void *id, *val; @@ -2063,7 +2063,7 @@ char** exec_context_get_syscall_log(const ExecContext *c) { assert(c); #if HAVE_SECCOMP - if (DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) < 0) + if (DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended) < 0) return strv_new(NULL); void *id, *val; diff --git a/src/core/main.c b/src/core/main.c index 5c02e308800..a05715dcfce 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -3814,7 +3814,7 @@ static int run_systemd(int argc, char *argv[]) { } /* Building without libmount is allowed, but if it is compiled in, then we must be able to load it */ - r = DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBMOUNT(LOG_DEBUG, required); if (r < 0 && !ERRNO_IS_NEG_NOT_SUPPORTED(r)) { error_message = "Failed to load libmount.so"; goto finish; diff --git a/src/core/mount.c b/src/core/mount.c index cf2d839347b..45a84e63506 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -2407,7 +2407,7 @@ static int mount_test_startable(Unit *u) { } static bool mount_supported(void) { - return DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) >= 0; + return DLOPEN_LIBMOUNT(LOG_DEBUG, recommended) >= 0; } static int mount_subsystem_ratelimited(Manager *m) { diff --git a/src/core/namespace.c b/src/core/namespace.c index 04257d82f34..ff9a975b08b 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -3986,7 +3986,7 @@ int refresh_extensions_in_namespace( if (r > 0) return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Target namespace is not separate, cannot reload extensions"); - (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); extension_dir = path_join(p->private_namespace_dir, "unit-extensions"); if (!extension_dir) diff --git a/src/core/selinux-setup.c b/src/core/selinux-setup.c index 886b00cbf56..fa65567ab05 100644 --- a/src/core/selinux-setup.c +++ b/src/core/selinux-setup.c @@ -17,7 +17,7 @@ int mac_selinux_setup(bool *loaded_policy) { assert(loaded_policy); - r = DLOPEN_LIBSELINUX(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBSELINUX(LOG_DEBUG, recommended); if (r < 0) return 0; diff --git a/src/creds/creds.c b/src/creds/creds.c index 9d17e30ac1f..455b157a02c 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -188,7 +188,7 @@ static int is_tmpfs_with_noswap(dev_t devno) { _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL; int r; - r = DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBMOUNT(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/cryptenroll/cryptenroll-varlink.c b/src/cryptenroll/cryptenroll-varlink.c index 77ead096731..83d448dc656 100644 --- a/src/cryptenroll/cryptenroll-varlink.c +++ b/src/cryptenroll/cryptenroll-varlink.c @@ -344,7 +344,7 @@ static int vl_method_enroll( if (FLAGS_SET(flags, SD_VARLINK_METHOD_MORE)) c.link = sd_varlink_ref(link); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; @@ -421,7 +421,7 @@ static int vl_method_list_slots( if (strdup_to(&c.node, node) < 0) return -ENOMEM; - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c index 6c3ee9b039a..1b5bbc3016f 100644 --- a/src/cryptenroll/cryptenroll.c +++ b/src/cryptenroll/cryptenroll.c @@ -1036,7 +1036,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, required); if (r < 0) return r; diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c index 4cf6b7654c2..800b297ae84 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-fido2.c @@ -37,7 +37,7 @@ _public_ int cryptsetup_token_open_pin( assert(pin || pin_size == 0); assert(token >= 0); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; @@ -102,7 +102,7 @@ _public_ void cryptsetup_token_dump( assert(json); - if (DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED) < 0) + if (DLOPEN_CRYPTSETUP(LOG_DEBUG, required) < 0) return; r = parse_luks2_fido2_data(cd, json, &rp_id, &salt, &salt_size, &cid, &cid_size, &required); @@ -169,7 +169,7 @@ _public_ int cryptsetup_token_validate( assert(json); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c index 6952bb7ca23..483686f671e 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-pkcs11.c @@ -36,7 +36,7 @@ _public_ int cryptsetup_token_open_pin( assert(pin || pin_size == 0); assert(token >= 0); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; @@ -94,7 +94,7 @@ _public_ void cryptsetup_token_dump( _cleanup_free_ void *pkcs11_key = NULL; Pkcs11RsaPadding rsa_padding = PKCS11_RSA_PADDING_PKCS1V15; - if (DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED) < 0) + if (DLOPEN_CRYPTSETUP(LOG_DEBUG, required) < 0) return; r = parse_luks2_pkcs11_data(cd, json, &pkcs11_uri, &pkcs11_key, &pkcs11_key_size, &rsa_padding); @@ -124,7 +124,7 @@ _public_ int cryptsetup_token_validate( sd_json_variant *w; _cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL; - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c index af2b2b74776..dd1cb77d8c3 100644 --- a/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c +++ b/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c @@ -70,7 +70,7 @@ _public_ int cryptsetup_token_open_pin( assert(ret_password); assert(ret_password_len); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; @@ -210,7 +210,7 @@ _public_ void cryptsetup_token_dump( assert(json); - if (DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED) < 0) + if (DLOPEN_CRYPTSETUP(LOG_DEBUG, required) < 0) return; r = sd_json_parse(json, SD_JSON_PARSE_MUST_BE_OBJECT, &v, /* reterr_line= */ NULL, /* reterr_column= */ NULL); @@ -304,7 +304,7 @@ _public_ int cryptsetup_token_validate( assert(json); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c index 36058b249d0..9be25d004d7 100644 --- a/src/cryptsetup/cryptsetup.c +++ b/src/cryptsetup/cryptsetup.c @@ -538,7 +538,7 @@ static int parse_one_option(const char *option) { #if HAVE_OPENSSL _cleanup_strv_free_ char **l = NULL; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -2893,7 +2893,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, required); if (r < 0) return r; diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 7a82d905da2..e3db8470b65 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -493,7 +493,7 @@ static int parse_argv(int argc, char *argv[]) { break; OPTION_LONG("make-archive", NULL, "Convert the DDI to an archive file"): - r = DLOPEN_LIBARCHIVE(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBARCHIVE(LOG_ERR, recommended); if (r < 0) return r; diff --git a/src/growfs/growfs.c b/src/growfs/growfs.c index f5a1b7b969f..f54266a1102 100644 --- a/src/growfs/growfs.c +++ b/src/growfs/growfs.c @@ -33,7 +33,7 @@ static int resize_crypt_luks_device(dev_t devno, const char *fstype, dev_t main_ uint64_t size; int r; - r = DLOPEN_CRYPTSETUP(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_WARNING, recommended); if (r < 0) return r; diff --git a/src/home/homectl.c b/src/home/homectl.c index 0da671bca65..84e3ea12053 100644 --- a/src/home/homectl.c +++ b/src/home/homectl.c @@ -2501,7 +2501,7 @@ static int verb_list_signing_keys(int argc, char *argv[], uintptr_t _data, void /* Let's decode the PEM key to DER (so that we lose prefix/suffix), then truncate it * for display reasons. */ - r = DLOPEN_LIBCRYPTO(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c index 81b2e837638..b949c4b8fdb 100644 --- a/src/home/homed-manager.c +++ b/src/home/homed-manager.c @@ -1537,7 +1537,7 @@ int manager_startup(Manager *m) { assert(m); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/home/homework-fscrypt.c b/src/home/homework-fscrypt.c index 6f51f493289..6c9692ff823 100644 --- a/src/home/homework-fscrypt.c +++ b/src/home/homework-fscrypt.c @@ -232,7 +232,7 @@ static int fscrypt_slot_try_v1( assert(encrypted_size > 0); assert(match_key_descriptor); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -331,7 +331,7 @@ static int fscrypt_slot_try_v2( assert(iovec_is_set(tag)); assert(match_key_descriptor); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -700,7 +700,7 @@ static int fscrypt_slot_set( size_t encrypted_size; ssize_t ss; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -813,7 +813,7 @@ int home_create_fscrypt( assert(setup); assert(ret_home); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c index 4a56551b9cf..7b9bd0d71a5 100644 --- a/src/home/homework-luks.c +++ b/src/home/homework-luks.c @@ -146,7 +146,7 @@ static int probe_file_system_by_fd( assert(ret_fstype); assert(ret_uuid); - r = DLOPEN_LIBBLKID(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBBLKID(LOG_DEBUG, recommended); if (r < 0) return r; @@ -529,7 +529,7 @@ static int acquire_open_luks_device( assert(setup); assert(!setup->crypt_device); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; @@ -684,7 +684,7 @@ static int luks_validate( assert(ret_size); assert(sector_size > 0); - r = DLOPEN_LIBBLKID(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBBLKID(LOG_DEBUG, recommended); if (r < 0) return r; @@ -805,7 +805,7 @@ static int crypt_device_to_evp_cipher(struct crypt_device *cd, const EVP_CIPHER assert(cd); assert(ret); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -1293,7 +1293,7 @@ int home_setup_luks( assert(setup); assert(user_record_storage(h) == USER_LUKS); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; @@ -1594,7 +1594,7 @@ int home_activate_luks( assert(setup); assert(ret_home); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; @@ -2211,11 +2211,11 @@ int home_create_luks( assert(setup->image_fd < 0); assert(ret_home); - r = DLOPEN_FDISK(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_FDISK(LOG_DEBUG, recommended); if (r < 0) return r; - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; @@ -3250,11 +3250,11 @@ int home_resize_luks( assert(user_record_storage(h) == USER_LUKS); assert(setup); - r = DLOPEN_FDISK(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_FDISK(LOG_DEBUG, recommended); if (r < 0) return r; - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; @@ -3712,7 +3712,7 @@ int home_passwd_luks( assert(user_record_storage(h) == USER_LUKS); assert(setup); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/home/homework.c b/src/home/homework.c index a5fca5a1188..81775e88726 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -1328,7 +1328,7 @@ static int determine_default_storage(UserStorage *ret) { if (r < 0) log_warning_errno(r, "Failed to determine if %s is encrypted, ignoring: %m", get_home_root()); - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) log_info("Not using '%s' storage, since libcryptsetup could not be loaded.", user_storage_to_string(USER_LUKS)); else { diff --git a/src/home/pam_systemd_home.c b/src/home/pam_systemd_home.c index bbfee76f070..c9a6a6ab289 100644 --- a/src/home/pam_systemd_home.c +++ b/src/home/pam_systemd_home.c @@ -786,7 +786,7 @@ _public_ PAM_EXTERN int pam_sm_authenticate( bool debug = false; int r; - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; @@ -851,7 +851,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( bool debug = false; int r; - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; @@ -908,7 +908,7 @@ _public_ PAM_EXTERN int pam_sm_close_session( bool debug = false; int r; - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; @@ -973,7 +973,7 @@ _public_ PAM_EXTERN int pam_sm_acct_mgmt( usec_t t; int r; - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; @@ -1092,7 +1092,7 @@ _public_ PAM_EXTERN int pam_sm_chauthtok( bool debug = false; int r; - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; diff --git a/src/imds/imdsd.c b/src/imds/imdsd.c index ea079fdbd27..6eb10480341 100644 --- a/src/imds/imdsd.c +++ b/src/imds/imdsd.c @@ -3053,7 +3053,7 @@ static int run(int argc, char* argv[]) { if (r <= 0) return r; - r = DLOPEN_CURL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CURL(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/import/import-common.c b/src/import/import-common.c index c7465147c46..41e945f1fb7 100644 --- a/src/import/import-common.c +++ b/src/import/import-common.c @@ -32,7 +32,7 @@ int import_fork_tar_x(int tree_fd, int userns_fd, PidRef *ret_pid) { assert(tree_fd >= 0); assert(ret_pid); - r = DLOPEN_LIBARCHIVE(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBARCHIVE(LOG_DEBUG, recommended); if (r < 0) return r; @@ -99,7 +99,7 @@ int import_fork_tar_c(int tree_fd, int userns_fd, PidRef *ret_pid) { assert(tree_fd >= 0); assert(ret_pid); - r = DLOPEN_LIBARCHIVE(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBARCHIVE(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/import/pull-job.c b/src/import/pull-job.c index 119bb752861..d86c47039fb 100644 --- a/src/import/pull-job.c +++ b/src/import/pull-job.c @@ -281,7 +281,7 @@ static int pull_job_open_disk(PullJob *j) { } if (j->calc_checksum) { - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; diff --git a/src/integritysetup/integritysetup.c b/src/integritysetup/integritysetup.c index 619c3b10db5..f29fcda0ab5 100644 --- a/src/integritysetup/integritysetup.c +++ b/src/integritysetup/integritysetup.c @@ -204,7 +204,7 @@ static int run(int argc, char *argv[]) { log_setup(); - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, required); if (r < 0) return r; diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c index 25465507208..a6ef7c77fa0 100644 --- a/src/journal-remote/journal-gatewayd.c +++ b/src/journal-remote/journal-gatewayd.c @@ -1265,7 +1265,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_MICROHTTPD(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_MICROHTTPD(LOG_ERR, required); if (r < 0) return r; diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c index 44b169c5919..ff283a2ea56 100644 --- a/src/journal-remote/journal-remote-main.c +++ b/src/journal-remote/journal-remote-main.c @@ -468,7 +468,7 @@ static int setup_microhttpd_server(RemoteServer *s, #if HAVE_MICROHTTPD int r; - r = DLOPEN_MICROHTTPD(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_MICROHTTPD(LOG_ERR, required); if (r < 0) return r; diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c index 2eb47d21300..a24f577c892 100644 --- a/src/journal-remote/journal-upload.c +++ b/src/journal-remote/journal-upload.c @@ -879,7 +879,7 @@ static int run(int argc, char **argv) { if (r <= 0) return r; - r = DLOPEN_CURL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CURL(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/journal/journalctl-authenticate.c b/src/journal/journalctl-authenticate.c index 73c1579b88f..180291ce34e 100644 --- a/src/journal/journalctl-authenticate.c +++ b/src/journal/journalctl-authenticate.c @@ -70,7 +70,7 @@ int action_setup_keys(void) { assert(arg_action == ACTION_SETUP_KEYS); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; diff --git a/src/keyutil/keyutil.c b/src/keyutil/keyutil.c index 9fa706e1bc4..4915e9c95dc 100644 --- a/src/keyutil/keyutil.c +++ b/src/keyutil/keyutil.c @@ -233,7 +233,7 @@ static int verb_extract_public(int argc, char *argv[], uintptr_t _data, void *us return r; } - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/locale/xkbcommon-util.c b/src/locale/xkbcommon-util.c index 181d14dd17c..55ff67588e9 100644 --- a/src/locale/xkbcommon-util.c +++ b/src/locale/xkbcommon-util.c @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "dlfcn-util.h" +#include "dlopen-note.h" #include "log.h" #include "string-util.h" #include "xkbcommon-util.h" @@ -17,10 +16,7 @@ DLSYM_PROTOTYPE(xkb_keymap_unref) = NULL; static int dlopen_xkbcommon(int log_level) { static void *xkbcommon_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "xkbcommon", - "Support for keyboard locale descriptions", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, "libxkbcommon.so.0"); + LIBXKBCOMMON_NOTE(suggested); return dlopen_many_sym_or_warn( &xkbcommon_dl, "libxkbcommon.so.0", log_level, diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c index 06d19607b2f..fa603ba015f 100644 --- a/src/login/pam_systemd.c +++ b/src/login/pam_systemd.c @@ -1807,7 +1807,7 @@ _public_ PAM_EXTERN int pam_sm_open_session( assert(pamh); - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; @@ -1915,7 +1915,7 @@ _public_ PAM_EXTERN int pam_sm_close_session( assert(pamh); - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; diff --git a/src/login/pam_systemd_loadkey.c b/src/login/pam_systemd_loadkey.c index c93dedf5ea8..ee17e650a79 100644 --- a/src/login/pam_systemd_loadkey.c +++ b/src/login/pam_systemd_loadkey.c @@ -19,7 +19,7 @@ _public_ PAM_EXTERN int pam_sm_authenticate( assert(pamh); - r = DLOPEN_LIBPAM(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBPAM(LOG_DEBUG, required); if (r < 0) return PAM_SERVICE_ERR; diff --git a/src/measure/measure-tool.c b/src/measure/measure-tool.c index 0e5762a682b..893fd4e593a 100644 --- a/src/measure/measure-tool.c +++ b/src/measure/measure-tool.c @@ -178,7 +178,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { "Select TPM bank (SHA1, SHA256, SHA384, SHA512)"): { const EVP_MD *implementation; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; @@ -1137,7 +1137,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c index ab4c03609a2..7d12360fa84 100644 --- a/src/network/networkd-sysctl.c +++ b/src/network/networkd-sysctl.c @@ -108,7 +108,7 @@ int manager_install_sysctl_monitor(Manager *manager) { assert(manager); - r = DLOPEN_BPF(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_BPF(LOG_DEBUG, recommended); if (ERRNO_IS_NEG_NOT_SUPPORTED(r)) return log_debug_errno(r, "sysctl monitor disabled, as BPF support is not available."); if (r < 0) diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c index 0f206bd7067..3e4fd468560 100644 --- a/src/nspawn/nspawn-oci.c +++ b/src/nspawn/nspawn-oci.c @@ -1826,7 +1826,7 @@ static int oci_seccomp(const char *name, sd_json_variant *v, sd_json_dispatch_fl if (r < 0) return json_log(def, flags, r, "Unknown default action: %s", sd_json_variant_string(def)); - r = DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended); if (r < 0) return json_log(def, flags, r, "No support for libseccomp: %m"); diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index add7c9146b1..c4dfc9584ec 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -6141,9 +6141,9 @@ static int run(int argc, char *argv[]) { if (arg_cleanup) return do_cleanup(); - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBSECCOMP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBSELINUX(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, recommended); + (void) DLOPEN_LIBSECCOMP(LOG_DEBUG, recommended); + (void) DLOPEN_LIBSELINUX(LOG_DEBUG, recommended); r = cg_has_legacy(); if (r < 0) diff --git a/src/nsresourced/userns-restrict.c b/src/nsresourced/userns-restrict.c index 1b82c797f09..dc2ab9b67e5 100644 --- a/src/nsresourced/userns-restrict.c +++ b/src/nsresourced/userns-restrict.c @@ -68,7 +68,7 @@ int userns_restrict_install( if (r == 0) return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "bpf-lsm not supported, can't lock down user namespace."); - r = DLOPEN_BPF(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_BPF(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/pcrextend/pcrextend.c b/src/pcrextend/pcrextend.c index 782f8632726..ab212600dfd 100644 --- a/src/pcrextend/pcrextend.c +++ b/src/pcrextend/pcrextend.c @@ -90,7 +90,7 @@ static int parse_argv(int argc, char *argv[], char ***ret_args) { OPTION_LONG("bank", "DIGEST", "Select TPM PCR bank (SHA1, SHA256)"): { const EVP_MD *implementation; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/pcrlock/pcrlock.c b/src/pcrlock/pcrlock.c index a1bc5c2bea3..d51215d522a 100644 --- a/src/pcrlock/pcrlock.c +++ b/src/pcrlock/pcrlock.c @@ -5709,7 +5709,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/portable/portable.c b/src/portable/portable.c index 2b398ec0756..6779ddd5514 100644 --- a/src/portable/portable.c +++ b/src/portable/portable.c @@ -610,8 +610,8 @@ static int portable_extract_by_path( * there, and extract the metadata we need. The metadata is sent from the child back to us. */ /* Load some libraries before we fork workers off that want to use them */ - (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, required); r = mkdtemp_malloc("/tmp/inspect-XXXXXX", &tmpdir); if (r < 0) diff --git a/src/repart/repart.c b/src/repart/repart.c index e0e494a6f29..099b901226d 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -3120,7 +3120,7 @@ static int partition_read_definition( "Cannot format %s filesystem without source files, refusing.", p->format); if (p->verity != VERITY_OFF || p->encrypt != ENCRYPT_OFF) { - r = DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); if (r < 0) return log_syntax(NULL, LOG_ERR, path, 1, r, "libcryptsetup not found, Verity=/Encrypt= are not supported: %m"); @@ -4739,7 +4739,7 @@ static int context_wipe_range(Context *context, uint64_t offset, uint64_t size) assert(offset != UINT64_MAX); assert(size != UINT64_MAX); - r = DLOPEN_LIBBLKID(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBBLKID(LOG_ERR, required); if (r < 0) return r; @@ -5431,7 +5431,7 @@ static int partition_encrypt(Context *context, Partition *p, PartitionTarget *ta assert(p); assert(p->encrypt != ENCRYPT_OFF); - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, recommended); if (r < 0) return r; @@ -5973,7 +5973,7 @@ static int partition_format_verity_hash( (void) partition_hint(p, node, &hint); - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, recommended); if (r < 0) return r; @@ -6075,7 +6075,7 @@ static int sign_verity_roothash( assert(iovec_is_set(roothash)); assert(ret_signature); - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, recommended); if (r < 0) return r; @@ -7167,7 +7167,7 @@ static int partition_populate_filesystem(Context *context, Partition *p, const c * appear in the host namespace. Hence we fork a child that has its own file system namespace and * detached mount propagation. */ - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, required); r = pidref_safe_fork( "(sd-copy)", @@ -8798,7 +8798,7 @@ static int resolve_copy_blocks_auto_candidate( return log_error_errno(r, "Failed to open block device " DEVNUM_FORMAT_STR ": %m", DEVNUM_FORMAT_VAL(whole_devno)); - r = DLOPEN_LIBBLKID(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBBLKID(LOG_ERR, required); if (r < 0) return r; @@ -11620,7 +11620,7 @@ static int run(int argc, char *argv[]) { if (r <= 0) return r; - r = DLOPEN_FDISK(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_FDISK(LOG_ERR, required); if (r < 0) return r; diff --git a/src/report/report-sign-plain.c b/src/report/report-sign-plain.c index 6aca27810c7..41b342cad63 100644 --- a/src/report/report-sign-plain.c +++ b/src/report/report-sign-plain.c @@ -304,7 +304,7 @@ static int vl_server(void) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *vs = NULL; int r; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/report/report-upload.c b/src/report/report-upload.c index e21c0044e63..01981c3ecf4 100644 --- a/src/report/report-upload.c +++ b/src/report/report-upload.c @@ -64,7 +64,7 @@ static int http_upload_report(Context *context, sd_json_variant *report) { char error[CURL_ERROR_SIZE] = {}; int r; - r = DLOPEN_CURL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CURL(LOG_DEBUG, required); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c index 575f100809d..c8821f189c6 100644 --- a/src/resolve/resolved-dns-dnssec.c +++ b/src/resolve/resolved-dns-dnssec.c @@ -735,7 +735,7 @@ int dnssec_verify_rrset( assert(dnskey); assert(result); - r = DLOPEN_LIBCRYPTO(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_WARNING, recommended); if (r < 0) return r; @@ -1092,7 +1092,7 @@ int dnssec_verify_dnskey_by_ds(DnsResourceRecord *dnskey, DnsResourceRecord *ds, assert(dnskey); assert(ds); - r = DLOPEN_LIBCRYPTO(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_WARNING, recommended); if (r < 0) return r; @@ -1232,7 +1232,7 @@ int dnssec_nsec3_hash(DnsResourceRecord *nsec3, const char *name, void *ret) { assert(name); assert(ret); - r = DLOPEN_LIBCRYPTO(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_WARNING, recommended); if (r < 0) return r; diff --git a/src/resolve/resolved-dnstls.c b/src/resolve/resolved-dnstls.c index f39e0447c21..a8d823af1e5 100644 --- a/src/resolve/resolved-dnstls.c +++ b/src/resolve/resolved-dnstls.c @@ -412,11 +412,11 @@ int dnstls_manager_init(Manager *manager) { if (manager->dnstls_data.ctx) return 0; - r = DLOPEN_LIBCRYPTO(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBCRYPTO(LOG_WARNING, recommended); if (r < 0) return r; - r = DLOPEN_LIBSSL(LOG_WARNING, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBSSL(LOG_WARNING, recommended); if (r < 0) return r; diff --git a/src/resolve/resolved-util.c b/src/resolve/resolved-util.c index 7b591ebbb90..6fd6c049f91 100644 --- a/src/resolve/resolved-util.c +++ b/src/resolve/resolved-util.c @@ -36,7 +36,7 @@ int resolve_system_hostname(char **full_hostname, char **first_label) { #if HAVE_LIBIDN2 _cleanup_free_ char *utf8 = NULL; - if (DLOPEN_IDN(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED) >= 0) { + if (DLOPEN_IDN(LOG_DEBUG, recommended) >= 0) { r = sym_idn2_to_unicode_8z8z(label, &utf8, 0); if (r != IDN2_OK) return log_debug_errno(SYNTHETIC_ERRNO(EUCLEAN), diff --git a/src/sbsign/sbsign.c b/src/sbsign/sbsign.c index e7a519404c8..0d86f8544f3 100644 --- a/src/sbsign/sbsign.c +++ b/src/sbsign/sbsign.c @@ -406,7 +406,7 @@ static int verb_sign(int argc, char *argv[], uintptr_t _data, void *userdata) { _cleanup_(iovec_done) struct iovec signed_attributes_signature = {}; int r; - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; diff --git a/src/shared/acl-util.c b/src/shared/acl-util.c index 84fca4da0e4..68457e16367 100644 --- a/src/shared/acl-util.c +++ b/src/shared/acl-util.c @@ -3,8 +3,6 @@ #include #include -#include "sd-dlopen.h" - #include "acl-util.h" #include "alloc-util.h" #include "errno-util.h" @@ -49,7 +47,7 @@ int dlopen_libacl(int log_level) { #if HAVE_ACL static void *libacl_dl = NULL; - LIBACL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBACL_NOTE(recommended); return dlopen_many_sym_or_warn( &libacl_dl, diff --git a/src/shared/acl-util.h b/src/shared/acl-util.h index 2b9ac817366..c06900008d7 100644 --- a/src/shared/acl-util.h +++ b/src/shared/acl-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_ACL @@ -66,17 +65,6 @@ static inline int acl_set_perm(acl_permset_t ps, acl_perm_t p, bool b) { return (b ? sym_acl_add_perm : sym_acl_delete_perm)(ps, p); } -#define LIBACL_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("acl", \ - "Support for file Access Control Lists (ACLs)", \ - priority, \ - "libacl.so.1") - -#define DLOPEN_LIBACL(log_level, priority) \ - ({ \ - LIBACL_NOTE(priority); \ - dlopen_libacl(log_level); \ - }) #else typedef void* acl_t; @@ -107,12 +95,16 @@ static inline int devnode_acl(int fd, const Set *uids) { static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) { return -EOPNOTSUPP; } - -#define DLOPEN_LIBACL(log_level, priority) dlopen_libacl(log_level) #endif int dlopen_libacl(int log_level); +#define DLOPEN_LIBACL(log_level, priority) \ + ({ \ + LIBACL_NOTE(priority); \ + dlopen_libacl(log_level); \ + }) + int fd_acl_make_read_only(int fd); int fd_acl_make_writable(int fd); diff --git a/src/shared/apparmor-util.c b/src/shared/apparmor-util.c index c2e874553e3..a2b3179c90e 100644 --- a/src/shared/apparmor-util.c +++ b/src/shared/apparmor-util.c @@ -1,14 +1,13 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include "apparmor-util.h" +#include "dlopen-note.h" #include "log.h" #if HAVE_APPARMOR #include -#include "sd-dlopen.h" - #include "fileio.h" DLSYM_PROTOTYPE(aa_change_onexec) = NULL; @@ -48,11 +47,7 @@ int dlopen_libapparmor(int log_level) { #if HAVE_APPARMOR static void *libapparmor_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "apparmor", - "Support for AppArmor policies", - SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, - "libapparmor.so.1"); + LIBAPPARMOR_NOTE(recommended); return dlopen_many_sym_or_warn( &libapparmor_dl, diff --git a/src/shared/blkid-util.c b/src/shared/blkid-util.c index 233d45c4f0c..98648917f12 100644 --- a/src/shared/blkid-util.c +++ b/src/shared/blkid-util.c @@ -1,6 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" #include "sd-id128.h" #include "blkid-util.h" @@ -99,7 +98,7 @@ int dlopen_libblkid(int log_level) { #if HAVE_BLKID static void *libblkid_dl = NULL; - LIBBLKID_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBBLKID_NOTE(recommended); return dlopen_many_sym_or_warn( &libblkid_dl, diff --git a/src/shared/blkid-util.h b/src/shared/blkid-util.h index 97356477fad..91f6e9c8c29 100644 --- a/src/shared/blkid-util.h +++ b/src/shared/blkid-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_BLKID @@ -68,20 +67,12 @@ enum { int blkid_probe_lookup_value_id128(blkid_probe b, const char *field, sd_id128_t *ret); int blkid_probe_lookup_value_u64(blkid_probe b, const char *field, uint64_t *ret); +#endif -#define LIBBLKID_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("blkid", \ - "Support for block device identification", \ - priority, \ - "libblkid.so.1") +int dlopen_libblkid(int log_level); #define DLOPEN_LIBBLKID(log_level, priority) \ ({ \ LIBBLKID_NOTE(priority); \ dlopen_libblkid(log_level); \ }) -#else -#define DLOPEN_LIBBLKID(log_level, priority) dlopen_libblkid(log_level) -#endif - -int dlopen_libblkid(int log_level); diff --git a/src/shared/bpf-util.c b/src/shared/bpf-util.c index 6cd4069580a..ebfc9b30bb1 100644 --- a/src/shared/bpf-util.c +++ b/src/shared/bpf-util.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "bpf-util.h" #include "dlfcn-util.h" #include "initrd-util.h" @@ -90,7 +88,7 @@ int dlopen_bpf(int log_level) { if (cached < 0) return cached; /* Already tried, and failed. */ - BPF_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBBPF_NOTE(suggested); DISABLE_WARNING_DEPRECATED_DECLARATIONS; diff --git a/src/shared/bpf-util.h b/src/shared/bpf-util.h index 6c2e7a2c98e..88ef204af0e 100644 --- a/src/shared/bpf-util.h +++ b/src/shared/bpf-util.h @@ -3,7 +3,8 @@ #include -#include "sd-dlopen.h" +#include "dlopen-note.h" +#include "shared-forward.h" #if HAVE_LIBBPF #ifndef SYSTEMD_CFLAGS_MARKER_LIBBPF @@ -14,7 +15,6 @@ #include /* IWYU pragma: export */ #include "dlfcn-util.h" -#include "shared-forward.h" /* Always redeclare these so DLSYM_PROTOTYPE's typeof() resolves regardless of libbpf version; * suppress the warning when the libbpf headers already declare them. @@ -92,20 +92,12 @@ static inline int compat_bpf_map_create( * this helper instead of libbpf_get_error() to ensure some of the known ones are translated into errnos * we understand. */ int bpf_get_error_translated(const void *ptr); - -#define BPF_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("bpf", \ - "Support firewalling and sandboxing with BPF", \ - priority, \ - "libbpf.so.1", "libbpf.so.0") - -#define DLOPEN_BPF(log_level, priority) \ - ({ \ - BPF_NOTE(priority); \ - dlopen_bpf(log_level); \ - }) -#else -#define DLOPEN_BPF(log_level, priority) dlopen_bpf(log_level) #endif int dlopen_bpf(int log_level); + +#define DLOPEN_BPF(log_level, priority) \ + ({ \ + LIBBPF_NOTE(priority); \ + dlopen_bpf(log_level); \ + }) diff --git a/src/shared/crypto-util.c b/src/shared/crypto-util.c index d791996efc7..d285c16b8b3 100644 --- a/src/shared/crypto-util.c +++ b/src/shared/crypto-util.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "alloc-util.h" #include "ask-password-api.h" #include "crypto-util.h" @@ -348,7 +346,7 @@ int dlopen_libcrypto(int log_level) { static void *libcrypto_dl = NULL; int r; - LIBCRYPTO_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBCRYPTO_NOTE(suggested); FOREACH_STRING(soname, "libcrypto.so.4", "libcrypto.so.3") { r = dlopen_many_sym_or_warn( diff --git a/src/shared/crypto-util.h b/src/shared/crypto-util.h index 9927dfb5c7b..f4bf7ed49ed 100644 --- a/src/shared/crypto-util.h +++ b/src/shared/crypto-util.h @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - -#include "shared-forward.h" +#include "dlopen-note.h" #include "iovec-util.h" #include "sha256.h" +#include "shared-forward.h" typedef enum CertificateSourceType { OPENSSL_CERTIFICATE_SOURCE_FILE, @@ -28,8 +27,6 @@ int parse_openssl_certificate_source_argument(const char *argument, char **certi int parse_openssl_key_source_argument(const char *argument, char **private_key_source, KeySourceType *private_key_source_type); -int dlopen_libcrypto(int log_level); - #define X509_FINGERPRINT_SIZE SHA256_DIGEST_SIZE #if HAVE_OPENSSL @@ -37,18 +34,6 @@ int dlopen_libcrypto(int log_level); # error "missing libopenssl_cflags in meson dependency." #endif -#define LIBCRYPTO_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("libcrypto", \ - "Support for cryptographic operations", \ - priority, \ - "libcrypto.so.4", "libcrypto.so.3") - -#define DLOPEN_LIBCRYPTO(log_level, priority) \ - ({ \ - LIBCRYPTO_NOTE(priority); \ - dlopen_libcrypto(log_level); \ - }) - # include /* IWYU pragma: export */ # include /* IWYU pragma: export */ # include /* IWYU pragma: export */ @@ -459,7 +444,12 @@ int openssl_extract_public_key(EVP_PKEY *private_key, EVP_PKEY **ret); OpenSSLAskPasswordUI* openssl_ask_password_ui_free(OpenSSLAskPasswordUI *ui); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(OpenSSLAskPasswordUI*, openssl_ask_password_ui_free, NULL); - -#else -#define DLOPEN_LIBCRYPTO(log_level, priority) dlopen_libcrypto(log_level) #endif + +int dlopen_libcrypto(int log_level); + +#define DLOPEN_LIBCRYPTO(log_level, priority) \ + ({ \ + LIBCRYPTO_NOTE(priority); \ + dlopen_libcrypto(log_level); \ + }) diff --git a/src/shared/cryptsetup-util.c b/src/shared/cryptsetup-util.c index 531d2fcbc01..7c6d6468a9d 100644 --- a/src/shared/cryptsetup-util.c +++ b/src/shared/cryptsetup-util.c @@ -2,7 +2,6 @@ #include -#include "sd-dlopen.h" #include "sd-json.h" #include "alloc-util.h" @@ -282,7 +281,7 @@ int dlopen_cryptsetup(int log_level) { * still available though, and given we want to support 2.2.0 for a while longer, we'll use the old * symbol if the new one is not available. */ - CRYPTSETUP_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBCRYPTSETUP_NOTE(suggested); r = dlopen_many_sym_or_warn( &cryptsetup_dl, "libcryptsetup.so.12", log_level, diff --git a/src/shared/cryptsetup-util.h b/src/shared/cryptsetup-util.h index 1c1e122e753..b1eb3b724e3 100644 --- a/src/shared/cryptsetup-util.h +++ b/src/shared/cryptsetup-util.h @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - #include "dlfcn-util.h" +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBCRYPTSETUP @@ -98,24 +97,16 @@ int cryptsetup_add_token_json(struct crypt_device *cd, sd_json_variant *v); int cryptsetup_get_volume_key_prefix(struct crypt_device *cd, const char *volume_name, char **ret); int cryptsetup_get_volume_key_id(struct crypt_device *cd, const char *volume_name, const void *volume_key, size_t volume_key_size, char **ret); - -#define CRYPTSETUP_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("cryptsetup", \ - "Support for disk encryption, integrity, and authentication", \ - priority, \ - "libcryptsetup.so.12") - -#define DLOPEN_CRYPTSETUP(log_level, priority) \ - ({ \ - CRYPTSETUP_NOTE(priority); \ - dlopen_cryptsetup(log_level); \ - }) -#else -#define DLOPEN_CRYPTSETUP(log_level, priority) dlopen_cryptsetup(log_level) #endif int dlopen_cryptsetup(int log_level); +#define DLOPEN_CRYPTSETUP(log_level, priority) \ + ({ \ + LIBCRYPTSETUP_NOTE(priority); \ + dlopen_cryptsetup(log_level); \ + }) + int cryptsetup_get_keyslot_from_token(sd_json_variant *v); const char* mangle_none(const char *s); diff --git a/src/shared/curl-util.c b/src/shared/curl-util.c index 961a97ad2f7..186b77454bf 100644 --- a/src/shared/curl-util.c +++ b/src/shared/curl-util.c @@ -5,7 +5,6 @@ #if HAVE_LIBCURL -#include "sd-dlopen.h" #include "sd-event.h" #include "alloc-util.h" @@ -604,7 +603,7 @@ int dlopen_curl(int log_level) { #if HAVE_LIBCURL static void *curl_dl = NULL; - CURL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBCURL_NOTE(suggested); return dlopen_many_sym_or_warn( &curl_dl, diff --git a/src/shared/curl-util.h b/src/shared/curl-util.h index a010cefac10..20f54aae59d 100644 --- a/src/shared/curl-util.h +++ b/src/shared/curl-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBCURL @@ -76,20 +75,12 @@ int curl_append_to_header(struct curl_slist **list, char **headers); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(CURL*, sym_curl_easy_cleanup, curl_easy_cleanupp, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct curl_slist*, sym_curl_slist_free_all, curl_slist_free_allp, NULL); - -#define CURL_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("curl", \ - "Support for downloading and uploading files over HTTP", \ - priority, \ - "libcurl.so.4") - -#define DLOPEN_CURL(log_level, priority) \ - ({ \ - CURL_NOTE(priority); \ - dlopen_curl(log_level); \ - }) -#else -#define DLOPEN_CURL(log_level, priority) dlopen_curl(log_level) #endif int dlopen_curl(int log_level); + +#define DLOPEN_CURL(log_level, priority) \ + ({ \ + LIBCURL_NOTE(priority); \ + dlopen_curl(log_level); \ + }) diff --git a/src/shared/dlopen-note.h b/src/shared/dlopen-note.h new file mode 100644 index 00000000000..b1ed14e5b4d --- /dev/null +++ b/src/shared/dlopen-note.h @@ -0,0 +1,381 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +#pragma once + +#include "../basic/dlopen-note.h" /* IWYU pragma: export */ +#include "shared-forward.h" + +#if HAVE_ACL +# define LIBACL_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + acl, \ + "Support for file Access Control Lists (ACLs)", \ + priority, \ + "libacl.so.1") +#else +# define LIBACL_NOTE(priority) +#endif + +#if HAVE_APPARMOR +# define LIBAPPARMOR_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + apparmor, \ + "Support for AppArmor policies", \ + priority, \ + "libapparmor.so.1") +#else +# define LIBAPPARMOR_NOTE(priority) +#endif + +#if HAVE_LIBARCHIVE +# define LIBARCHIVE_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + archive, \ + "Support for decompressing archive files", \ + priority, \ + "libarchive.so.13") +#else +# define LIBARCHIVE_NOTE(priority) +#endif + +#if HAVE_AUDIT +# define LIBAUDIT_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + audit, \ + "Support for Audit logging", \ + priority, \ + "libaudit.so.1") +#else +# define LIBAUDIT_NOTE(priority) +#endif + +#if HAVE_BLKID +# define LIBBLKID_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + blkid, \ + "Support for block device identification", \ + priority, \ + "libblkid.so.1") +#else +# define LIBBLKID_NOTE(priority) +#endif + +#if HAVE_LIBBPF +# define LIBBPF_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + bpf, \ + "Support firewalling and sandboxing with BPF", \ + priority, \ + "libbpf.so.1", "libbpf.so.0") +#else +# define LIBBPF_NOTE(priority) +#endif + +#if HAVE_LIBCRYPT && defined(__GLIBC__) +# define LIBCRYPT_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + crypt, \ + "Support for hashing passwords", \ + priority, \ + "libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1") +#else +# define LIBCRYPT_NOTE(priority) +#endif + +#if HAVE_OPENSSL +# define LIBCRYPTO_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + libcrypto, \ + "Support for cryptographic operations", \ + priority, \ + "libcrypto.so.4", "libcrypto.so.3") +#else +# define LIBCRYPTO_NOTE(priority) +#endif + +#if HAVE_LIBCRYPTSETUP +# define LIBCRYPTSETUP_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + cryptsetup, \ + "Support for disk encryption, integrity, and authentication", \ + priority, \ + "libcryptsetup.so.12") +#else +# define LIBCRYPTSETUP_NOTE(priority) +#endif + +#if HAVE_LIBCURL +# define LIBCURL_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + curl, \ + "Support for downloading and uploading files over HTTP", \ + priority, \ + "libcurl.so.4") +#else +# define LIBCURL_NOTE(priority) +#endif + +#if HAVE_LIBFDISK +# define LIBFDISK_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + fdisk, \ + "Support for reading and writing partition tables", \ + priority, \ + "libfdisk.so.1") +#else +# define LIBFDISK_NOTE(priority) +#endif + +#if HAVE_ELFUTILS +# define LIBDW_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + dw, \ + "Support for backtrace and ELF package metadata decoding from core files", \ + priority, \ + "libdw.so.1") +#else +# define LIBDW_NOTE(priority) +#endif + +#if HAVE_ELFUTILS +# define LIBELF_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + elf, \ + "Support for backtraces and reading ELF package metadata from core files", \ + priority, \ + "libelf.so.1") +#else +# define LIBELF_NOTE(priority) +#endif + +#if HAVE_LIBFIDO2 +# define LIBFIDO2_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + fido2, \ + "Support fido2 for encryption and authentication", \ + priority, \ + "libfido2.so.1") +#else +# define LIBFIDO2_NOTE(priority) +#endif + +#if HAVE_GNUTLS +# define LIBGNUTLS_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + gnutls, \ + "Support for TLS via GnuTLS", \ + priority, \ + "libgnutls.so.30") +#else +# define LIBGNUTLS_NOTE(priority) +#endif + +#if HAVE_LIBIDN2 +# define LIBIDN2_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + idn, \ + "Support for internationalized domain names", \ + priority, \ + "libidn2.so.0") +#else +# define LIBIDN2_NOTE(priority) +#endif + +#if HAVE_KMOD +# define LIBKMOD_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + kmod, \ + "Support for loading kernel modules", \ + priority, \ + "libkmod.so.2") +#else +# define LIBKMOD_NOTE(priority) +#endif + +#if HAVE_MICROHTTPD +# define LIBMICROHTTPD_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + microhttpd, \ + "Support for embedded HTTP server via libmicrohttpd", \ + priority, \ + "libmicrohttpd.so.12") +#else +# define LIBMICROHTTPD_NOTE(priority) +#endif + +#if HAVE_LIBMOUNT +# define LIBMOUNT_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + mount, \ + "Support for mount enumeration", \ + priority, \ + "libmount.so.1") +#else +# define LIBMOUNT_NOTE(priority) +#endif + +#if HAVE_P11KIT +# define LIBP11KIT_NOTE(priority) \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + p11kit_##priority, \ + "p11-kit", \ + "Support for PKCS11 hardware tokens", \ + STRINGIFY(priority), \ + "libp11-kit.so.0") +#else +# define LIBP11KIT_NOTE(priority) +#endif + +#if HAVE_PAM +# define LIBPAM_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + pam, \ + "Support for LinuxPAM", \ + priority, \ + "libpam.so.0") +#else +# define LIBPAM_NOTE(priority) +#endif + +#if HAVE_PASSWDQC +# define LIBPASSWDQC_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + passwdqc, \ + "Support for password quality checks", \ + priority, \ + "libpasswdqc.so.1") +#else +# define LIBPASSWDQC_NOTE(priority) +#endif + +#if HAVE_PCRE2 +# define LIBPCRE2_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + pcre2, \ + "Support for regular expressions", \ + priority, \ + "libpcre2-8.so.0") +#else +# define LIBPCRE2_NOTE(priority) +#endif + +#if HAVE_PWQUALITY +# define LIBPWQUALITY_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + pwquality, \ + "Support for password quality checks", \ + priority, \ + "libpwquality.so.1") +#else +# define LIBPWQUALITY_NOTE(priority) +#endif + +#if HAVE_QRENCODE +# define LIBQRENCODE_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + qrencode, \ + "Support for generating QR codes", \ + priority, \ + "libqrencode.so.4", "libqrencode.so.3") +#else +# define LIBQRENCODE_NOTE(priority) +#endif + +#if HAVE_SECCOMP +# define LIBSECCOMP_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + seccomp, \ + "Support for Seccomp Sandboxes", \ + priority, \ + "libseccomp.so.2") +#else +# define LIBSECCOMP_NOTE(priority) +#endif + +#if HAVE_SELINUX +# define LIBSELINUX_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + selinux, \ + "Support for SELinux", \ + priority, \ + "libselinux.so.1") +#else +# define LIBSELINUX_NOTE(priority) +#endif + +#if HAVE_OPENSSL +# define LIBSSL_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + libssl, \ + "Support for TLS", \ + priority, \ + "libssl.so.4", "libssl.so.3") +#else +# define LIBSSL_NOTE(priority) +#endif + +#if HAVE_TPM2 +# define LIBTSS2_ESYS_NOTE(priority) \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + tpm2_esys_##priority, \ + "tpm", \ + "Support for TPM", \ + STRINGIFY(priority), \ + "libtss2-esys.so.0") +# define LIBTSS2_RC_NOTE(priority) \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + tpm2_rc_##priority, \ + "tpm", \ + "Support for TPM", \ + STRINGIFY(priority), \ + "libtss2-rc.so.0") +# define LIBTSS2_MU_NOTE(priority) \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + tpm2_mu_##priority, \ + "tpm", \ + "Support for TPM", \ + STRINGIFY(priority), \ + "libtss2-mu.so.0") +# define LIBTSS2_TCTI_DEVICE_NOTE(priority) \ + SD_ELF_NOTE_DLOPEN_ANCHORED( \ + tpm2_tcti_device_##priority, \ + "tpm", \ + "Support for TPM", \ + STRINGIFY(priority), \ + "libtss2-tcti-device.so.0") +#else +# define LIBTSS2_ESYS_NOTE(priority) +# define LIBTSS2_RC_NOTE(priority) +# define LIBTSS2_MU_NOTE(priority) +# define LIBTSS2_TCTI_DEVICE_NOTE(priority) +#endif + +#if HAVE_XKBCOMMON +# define LIBXKBCOMMON_NOTE(priority) \ + ELF_NOTE_DLOPEN_ANCHORED( \ + xkbcommon, \ + "Support for keyboard locale descriptions", \ + priority, \ + "libxkbcommon.so.0") +#else +# define LIBXKBCOMMON_NOTE(priority) +#endif + +#if HAVE_LIBARCHIVE +# define ARCHIVE_NOTE(priority) \ + COMPRESS_NOTE(priority); \ + LIBACL_NOTE(priority); \ + LIBARCHIVE_NOTE(priority) +#else +# define ARCHIVE_NOTE(priority) \ + COMPRESS_NOTE(priority) +#endif + +#define PASSWORD_NOTE(priority) \ + LIBPASSWDQC_NOTE(priority); \ + LIBPWQUALITY_NOTE(priority) + +#define TPM2_NOTE(priority) \ + LIBTSS2_ESYS_NOTE(priority); \ + LIBTSS2_RC_NOTE(priority); \ + LIBTSS2_MU_NOTE(priority); \ + LIBTSS2_TCTI_DEVICE_NOTE(priority) diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c index 5e40541ffcf..9a926e49ed3 100644 --- a/src/shared/elf-util.c +++ b/src/shared/elf-util.c @@ -12,12 +12,12 @@ #endif #include -#include "sd-dlopen.h" #include "sd-json.h" #include "alloc-util.h" #include "coredump-util.h" #include "dlfcn-util.h" +#include "dlopen-note.h" #include "elf-util.h" #include "errno-util.h" #include "escape.h" @@ -100,11 +100,7 @@ int dlopen_dw(int log_level) { static void *dw_dl = NULL; int r; - SD_ELF_NOTE_DLOPEN( - "dw", - "Support for backtrace and ELF package metadata decoding from core files", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libdw.so.1"); + LIBDW_NOTE(suggested); r = dlopen_many_sym_or_warn( &dw_dl, "libdw.so.1", log_level, @@ -166,11 +162,7 @@ int dlopen_elf(int log_level) { static void *elf_dl = NULL; int r; - SD_ELF_NOTE_DLOPEN( - "elf", - "Support for backtraces and reading ELF package metadata from core files", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libelf.so.1"); + LIBELF_NOTE(suggested); r = dlopen_many_sym_or_warn( &elf_dl, "libelf.so.1", log_level, diff --git a/src/shared/fdisk-util.c b/src/shared/fdisk-util.c index 8efafbc96e4..3c56f7033f6 100644 --- a/src/shared/fdisk-util.c +++ b/src/shared/fdisk-util.c @@ -5,8 +5,6 @@ #if HAVE_LIBFDISK -#include "sd-dlopen.h" - #include "alloc-util.h" #include "bitfield.h" #include "dissect-image.h" @@ -83,7 +81,7 @@ int dlopen_fdisk(int log_level) { #if HAVE_LIBFDISK static void *fdisk_dl = NULL; - FDISK_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBFDISK_NOTE(suggested); return dlopen_many_sym_or_warn( &fdisk_dl, diff --git a/src/shared/fdisk-util.h b/src/shared/fdisk-util.h index acdbd7c741c..c34cde1a41e 100644 --- a/src/shared/fdisk-util.h +++ b/src/shared/fdisk-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBFDISK @@ -88,20 +87,12 @@ int fdisk_partition_get_type_as_id128(struct fdisk_partition *p, sd_id128_t *ret int fdisk_partition_get_attrs_as_uint64(struct fdisk_partition *pa, uint64_t *ret); int fdisk_partition_set_attrs_as_uint64(struct fdisk_partition *pa, uint64_t flags); - -#define FDISK_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("fdisk", \ - "Support for reading and writing partition tables", \ - priority, \ - "libfdisk.so.1") - -#define DLOPEN_FDISK(log_level, priority) \ - ({ \ - FDISK_NOTE(priority); \ - dlopen_fdisk(log_level); \ - }) -#else -#define DLOPEN_FDISK(log_level, priority) dlopen_fdisk(log_level) #endif int dlopen_fdisk(int log_level); + +#define DLOPEN_FDISK(log_level, priority) \ + ({ \ + LIBFDISK_NOTE(priority); \ + dlopen_fdisk(log_level); \ + }) diff --git a/src/shared/gnutls-util.c b/src/shared/gnutls-util.c index 4a13dbe1ec9..96460f1e02d 100644 --- a/src/shared/gnutls-util.c +++ b/src/shared/gnutls-util.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "gnutls-util.h" #include "log.h" /* IWYU pragma: keep */ @@ -23,11 +22,7 @@ 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"); + LIBGNUTLS_NOTE(suggested); return dlopen_many_sym_or_warn( &gnutls_dl, diff --git a/src/shared/idn-util.c b/src/shared/idn-util.c index 01c808b57fe..fe36b71d3c8 100644 --- a/src/shared/idn-util.c +++ b/src/shared/idn-util.c @@ -5,8 +5,6 @@ #if HAVE_LIBIDN2 -#include "sd-dlopen.h" - static void* idn_dl = NULL; DLSYM_PROTOTYPE(idn2_lookup_u8) = NULL; @@ -17,7 +15,7 @@ DLSYM_PROTOTYPE(idn2_to_unicode_8z8z) = NULL; int dlopen_idn(int log_level) { #if HAVE_LIBIDN2 - IDN_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBIDN2_NOTE(suggested); return dlopen_many_sym_or_warn( &idn_dl, "libidn2.so.0", log_level, diff --git a/src/shared/idn-util.h b/src/shared/idn-util.h index 0f3db74c632..cf7e8a86178 100644 --- a/src/shared/idn-util.h +++ b/src/shared/idn-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBIDN2 @@ -17,20 +16,12 @@ extern DLSYM_PROTOTYPE(idn2_lookup_u8); extern const char *(*sym_idn2_strerror)(int rc) _const_; extern DLSYM_PROTOTYPE(idn2_to_unicode_8z8z); - -#define IDN_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("idn", \ - "Support for internationalized domain names", \ - priority, \ - "libidn2.so.0") - -#define DLOPEN_IDN(log_level, priority) \ - ({ \ - IDN_NOTE(priority); \ - dlopen_idn(log_level); \ - }) -#else -#define DLOPEN_IDN(log_level, priority) dlopen_idn(log_level) #endif int dlopen_idn(int log_level); + +#define DLOPEN_IDN(log_level, priority) \ + ({ \ + LIBIDN2_NOTE(priority); \ + dlopen_idn(log_level); \ + }) diff --git a/src/shared/libarchive-util.c b/src/shared/libarchive-util.c index cc28c2d3471..1e66fd68ca2 100644 --- a/src/shared/libarchive-util.c +++ b/src/shared/libarchive-util.c @@ -2,8 +2,6 @@ #include -#include "sd-dlopen.h" - #include "libarchive-util.h" #include "log.h" /* IWYU pragma: keep */ #include "user-util.h" /* IWYU pragma: keep */ @@ -80,7 +78,7 @@ int dlopen_libarchive(int log_level) { static void *libarchive_dl = NULL; int r; - LIBARCHIVE_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBARCHIVE_NOTE(suggested); r = dlopen_many_sym_or_warn( &libarchive_dl, diff --git a/src/shared/libarchive-util.h b/src/shared/libarchive-util.h index 71b4d66d42c..775ede55b97 100644 --- a/src/shared/libarchive-util.h +++ b/src/shared/libarchive-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBARCHIVE @@ -84,21 +83,12 @@ extern DLSYM_PROTOTYPE(archive_write_set_format_pax); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive_entry*, sym_archive_entry_free, archive_entry_freep, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive*, sym_archive_write_free, archive_write_freep, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive*, sym_archive_read_free, archive_read_freep, NULL); +#endif -#define LIBARCHIVE_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("archive", \ - "Support for decompressing archive files", \ - priority, \ - "libarchive.so.13") +int dlopen_libarchive(int log_level); #define DLOPEN_LIBARCHIVE(log_level, priority) \ ({ \ LIBARCHIVE_NOTE(priority); \ dlopen_libarchive(log_level); \ }) - -#else -#define DLOPEN_LIBARCHIVE(log_level, priority) dlopen_libarchive(log_level) -#endif - -int dlopen_libarchive(int log_level); diff --git a/src/shared/libaudit-util.c b/src/shared/libaudit-util.c index 41daa372b58..481eda7294e 100644 --- a/src/shared/libaudit-util.c +++ b/src/shared/libaudit-util.c @@ -4,8 +4,7 @@ #include #include -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "errno-util.h" #include "fd-util.h" #include "iovec-util.h" @@ -25,11 +24,7 @@ int dlopen_libaudit(int log_level) { #if HAVE_AUDIT static void *libaudit_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "audit", - "Support for Audit logging", - SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, - "libaudit.so.1"); + LIBAUDIT_NOTE(recommended); return dlopen_many_sym_or_warn( &libaudit_dl, diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index 106d7688fe9..0a72e4e25a2 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -7,10 +7,9 @@ # include #endif -#include "sd-dlopen.h" - #include "alloc-util.h" #include "dlfcn-util.h" +#include "dlopen-note.h" #include "errno-util.h" #include "libcrypt-util.h" #include "log.h" @@ -144,15 +143,11 @@ int dlopen_libcrypt(int log_level) { if (cached < 0) return cached; /* Already tried, and failed. */ + LIBCRYPT_NOTE(recommended); + /* Several distributions like Debian/Ubuntu and OpenSUSE provide libxcrypt as libcrypt.so.1 * (libcrypt.so.1.1 on some architectures), while others like Fedora/CentOS and Arch provide it as * libcrypt.so.2. */ - SD_ELF_NOTE_DLOPEN( - "crypt", - "Support for hashing passwords", - SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED, - "libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1"); - FOREACH_STRING(soname, "libcrypt.so.2", "libcrypt.so.1", "libcrypt.so.1.1") { r = dlopen_many_sym_or_warn( &libcrypt_dl, soname, LOG_DEBUG, diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index 07bea6658ec..0276e639533 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "libfido2-util.h" #include "log.h" @@ -86,11 +85,7 @@ int dlopen_libfido2(int log_level) { static void *libfido2_dl = NULL; int r; - SD_ELF_NOTE_DLOPEN( - "fido2", - "Support fido2 for encryption and authentication", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libfido2.so.1"); + LIBFIDO2_NOTE(suggested); r = dlopen_many_sym_or_warn( &libfido2_dl, "libfido2.so.1", log_level, diff --git a/src/shared/libmount-util.c b/src/shared/libmount-util.c index fd83da136ff..39fef6974d6 100644 --- a/src/shared/libmount-util.c +++ b/src/shared/libmount-util.c @@ -7,8 +7,6 @@ #include -#include "sd-dlopen.h" - #include "fstab-util.h" DLSYM_PROTOTYPE(mnt_free_iter) = NULL; @@ -120,7 +118,7 @@ int dlopen_libmount(int log_level) { #if HAVE_LIBMOUNT static void *libmount_dl = NULL; - LIBMOUNT_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBMOUNT_NOTE(recommended); return dlopen_many_sym_or_warn( &libmount_dl, diff --git a/src/shared/libmount-util.h b/src/shared/libmount-util.h index 3afdb973788..20195a13c8b 100644 --- a/src/shared/libmount-util.h +++ b/src/shared/libmount-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_LIBMOUNT @@ -78,28 +77,21 @@ int libmount_is_leaf( struct libmnt_table *table, struct libmnt_fs *fs); -#define LIBMOUNT_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("mount", \ - "Support for mount enumeration", \ - priority, \ - "libmount.so.1") - -#define DLOPEN_LIBMOUNT(log_level, priority) \ - ({ \ - LIBMOUNT_NOTE(priority); \ - dlopen_libmount(log_level); \ - }) #else struct libmnt_monitor; - static inline void* sym_mnt_unref_monitor(struct libmnt_monitor *p) { assert(p == NULL); return NULL; } -#define DLOPEN_LIBMOUNT(log_level, priority) dlopen_libmount(log_level) #endif int dlopen_libmount(int log_level); + +#define DLOPEN_LIBMOUNT(log_level, priority) \ + ({ \ + LIBMOUNT_NOTE(priority); \ + dlopen_libmount(log_level); \ + }) diff --git a/src/shared/microhttpd-util.c b/src/shared/microhttpd-util.c index 9820a1e4000..4a43bb65f51 100644 --- a/src/shared/microhttpd-util.c +++ b/src/shared/microhttpd-util.c @@ -2,8 +2,6 @@ #include -#include "sd-dlopen.h" - #include "alloc-util.h" #include "gnutls-util.h" #include "log.h" @@ -36,7 +34,7 @@ int dlopen_microhttpd(int log_level) { #if HAVE_MICROHTTPD static void *microhttpd_dl = NULL; - MICROHTTPD_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBMICROHTTPD_NOTE(suggested); return dlopen_many_sym_or_warn( µhttpd_dl, diff --git a/src/shared/microhttpd-util.h b/src/shared/microhttpd-util.h index c430f9e3d1a..524d73b8a25 100644 --- a/src/shared/microhttpd-util.h +++ b/src/shared/microhttpd-util.h @@ -1,29 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" -int dlopen_microhttpd(int log_level); - #if HAVE_MICROHTTPD #ifndef SYSTEMD_CFLAGS_MARKER_LIBMICROHTTPD # error "missing libmicrohttpd_cflags in meson dependency." #endif -#define MICROHTTPD_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("microhttpd", \ - "Support for embedded HTTP server via libmicrohttpd", \ - priority, \ - "libmicrohttpd.so.12") - -#define DLOPEN_MICROHTTPD(log_level, priority) \ - ({ \ - MICROHTTPD_NOTE(priority); \ - dlopen_microhttpd(log_level); \ - }) - #include #include "dlfcn-util.h" @@ -150,7 +135,12 @@ int setup_gnutls_logger(char **categories); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct MHD_Daemon*, sym_MHD_stop_daemon, MHD_stop_daemonp, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct MHD_Response*, sym_MHD_destroy_response, MHD_destroy_responsep, NULL); - -#else -#define DLOPEN_MICROHTTPD(log_level, priority) dlopen_microhttpd(log_level) #endif + +int dlopen_microhttpd(int log_level); + +#define DLOPEN_MICROHTTPD(log_level, priority) \ + ({ \ + LIBMICROHTTPD_NOTE(priority); \ + dlopen_microhttpd(log_level); \ + }) diff --git a/src/shared/module-util.c b/src/shared/module-util.c index e060c69d9d6..33704449d9a 100644 --- a/src/shared/module-util.c +++ b/src/shared/module-util.c @@ -2,8 +2,6 @@ #include -#include "sd-dlopen.h" - #include "log.h" #include "module-util.h" #include "proc-cmdline.h" @@ -173,7 +171,7 @@ int dlopen_libkmod(int log_level) { #if HAVE_KMOD static void *libkmod_dl = NULL; - LIBKMOD_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBKMOD_NOTE(recommended); return dlopen_many_sym_or_warn( &libkmod_dl, diff --git a/src/shared/module-util.h b/src/shared/module-util.h index 59d2f3b1f1e..59b13d01cfc 100644 --- a/src/shared/module-util.h +++ b/src/shared/module-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_KMOD @@ -40,22 +39,10 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_list*, sym_kmod_module_unref int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose); int module_setup_context(struct kmod_ctx **ret); -#define LIBKMOD_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("kmod", \ - "Support for loading kernel modules", \ - priority, \ - "libkmod.so.2") - -#define DLOPEN_LIBKMOD(log_level, priority) \ - ({ \ - LIBKMOD_NOTE(priority); \ - dlopen_libkmod(log_level); \ - }) #else struct kmod_ctx; - static inline int module_setup_context(struct kmod_ctx **ret) { return -EOPNOTSUPP; } @@ -64,7 +51,12 @@ static inline int module_load_and_warn(struct kmod_ctx *ctx, const char *module, return -EOPNOTSUPP; } -#define DLOPEN_LIBKMOD(log_level, priority) dlopen_libkmod(log_level) #endif int dlopen_libkmod(int log_level); + +#define DLOPEN_LIBKMOD(log_level, priority) \ + ({ \ + LIBKMOD_NOTE(priority); \ + dlopen_libkmod(log_level); \ + }) diff --git a/src/shared/pam-util.c b/src/shared/pam-util.c index 0fe4207a0b7..8d3a7b8d3ec 100644 --- a/src/shared/pam-util.c +++ b/src/shared/pam-util.c @@ -9,7 +9,6 @@ #include #include "sd-bus.h" -#include "sd-dlopen.h" #include "alloc-util.h" #include "bus-internal.h" @@ -383,7 +382,7 @@ int dlopen_libpam(int log_level) { #if HAVE_PAM static void *libpam_dl = NULL; - LIBPAM_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBPAM_NOTE(recommended); return dlopen_many_sym_or_warn( &libpam_dl, diff --git a/src/shared/pam-util.h b/src/shared/pam-util.h index 41591a4d36c..5f23667102d 100644 --- a/src/shared/pam-util.h +++ b/src/shared/pam-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_PAM @@ -109,20 +108,12 @@ int pam_prompt_graceful(pam_handle_t *pamh, int style, char **ret_response, cons /* Equivalent of pam_misc_setenv(pamh, name, value, 0), without the libpam_misc dep — builds "name=value" * and hands it to sym_pam_putenv(), then erases the buffer before freeing in case it carried a secret. */ int pam_putenv_assign(pam_handle_t *pamh, const char *name, const char *value); +#endif -#define LIBPAM_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("pam", \ - "Support for LinuxPAM", \ - priority, \ - "libpam.so.0") +int dlopen_libpam(int log_level); #define DLOPEN_LIBPAM(log_level, priority) \ ({ \ LIBPAM_NOTE(priority); \ dlopen_libpam(log_level); \ }) -#else -#define DLOPEN_LIBPAM(log_level, priority) dlopen_libpam(log_level) -#endif - -int dlopen_libpam(int log_level); diff --git a/src/shared/password-quality-util-passwdqc.c b/src/shared/password-quality-util-passwdqc.c index 8d762f7e5cc..15d95b76de0 100644 --- a/src/shared/password-quality-util-passwdqc.c +++ b/src/shared/password-quality-util-passwdqc.c @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "password-quality-util-passwdqc.h" - +#include "dlopen-note.h" #include "errno-util.h" /* IWYU pragma: keep */ #include "log.h" /* IWYU pragma: keep */ +#include "password-quality-util-passwdqc.h" #if HAVE_PASSWDQC #ifndef SYSTEMD_CFLAGS_MARKER_LIBPWQUALITY @@ -12,8 +12,6 @@ #include -#include "sd-dlopen.h" - #include "alloc-util.h" #include "dlfcn-util.h" #include "memory-util.h" @@ -143,11 +141,7 @@ int dlopen_passwdqc(int log_level) { #if HAVE_PASSWDQC static void *passwdqc_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "passwdqc", - "Support for password quality checks", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libpasswdqc.so.1"); + LIBPASSWDQC_NOTE(suggested); return dlopen_many_sym_or_warn( &passwdqc_dl, "libpasswdqc.so.1", log_level, diff --git a/src/shared/password-quality-util-pwquality.c b/src/shared/password-quality-util-pwquality.c index 9952c4d195b..e045a43a77c 100644 --- a/src/shared/password-quality-util-pwquality.c +++ b/src/shared/password-quality-util-pwquality.c @@ -1,9 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "password-quality-util-pwquality.h" - +#include "dlopen-note.h" #include "errno-util.h" #include "log.h" +#include "password-quality-util-pwquality.h" #if HAVE_PWQUALITY #ifndef SYSTEMD_CFLAGS_MARKER_LIBPWQUALITY @@ -14,8 +14,6 @@ #include #include -#include "sd-dlopen.h" - #include "alloc-util.h" #include "dlfcn-util.h" #include "password-quality-util.h" @@ -159,11 +157,7 @@ int dlopen_pwquality(int log_level) { #if HAVE_PWQUALITY static void *pwquality_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "pwquality", - "Support for password quality checks", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libpwquality.so.1"); + LIBPWQUALITY_NOTE(suggested); return dlopen_many_sym_or_warn( &pwquality_dl, "libpwquality.so.1", log_level, diff --git a/src/shared/pcre2-util.c b/src/shared/pcre2-util.c index 52b65a95a35..0523612bd9b 100644 --- a/src/shared/pcre2-util.c +++ b/src/shared/pcre2-util.c @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "dlfcn-util.h" +#include "dlopen-note.h" #include "hash-funcs.h" #include "log.h" #include "pcre2-util.h" @@ -30,11 +29,7 @@ int dlopen_pcre2(int log_level) { #if HAVE_PCRE2 static void *pcre2_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "pcre2", - "Support for regular expressions", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libpcre2-8.so.0"); + LIBPCRE2_NOTE(suggested); /* So here's something weird: PCRE2 actually renames the symbols exported by the library via C * macros, so that the exported symbols carry a suffix "_8" but when used from C the suffix is diff --git a/src/shared/pkcs11-util.c b/src/shared/pkcs11-util.c index 6002c2e0af7..a9bf1e5913f 100644 --- a/src/shared/pkcs11-util.c +++ b/src/shared/pkcs11-util.c @@ -1,11 +1,10 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "alloc-util.h" #include "ask-password-api.h" #include "crypto-util.h" #include "dlfcn-util.h" +#include "dlopen-note.h" #include "env-util.h" #include "escape.h" #include "format-table.h" @@ -1963,11 +1962,7 @@ int dlopen_p11kit(int log_level) { #if HAVE_P11KIT static void *p11kit_dl = NULL; - SD_ELF_NOTE_DLOPEN( - "p11-kit", - "Support for PKCS11 hardware tokens", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libp11-kit.so.0"); + LIBP11KIT_NOTE(suggested); return dlopen_many_sym_or_warn( &p11kit_dl, diff --git a/src/shared/qrcode-util.c b/src/shared/qrcode-util.c index a5bf75f8891..34755ca41fc 100644 --- a/src/shared/qrcode-util.c +++ b/src/shared/qrcode-util.c @@ -10,10 +10,9 @@ #endif #include -#include "sd-dlopen.h" - #include "ansi-color.h" #include "dlfcn-util.h" +#include "dlopen-note.h" #include "locale-util.h" #include "log.h" #include "strv.h" @@ -34,11 +33,7 @@ int dlopen_qrencode(int log_level) { static void *qrcode_dl = NULL; int r; - SD_ELF_NOTE_DLOPEN( - "qrencode", - "Support for generating QR codes", - SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, - "libqrencode.so.4", "libqrencode.so.3"); + LIBQRENCODE_NOTE(suggested); FOREACH_STRING(s, "libqrencode.so.4", "libqrencode.so.3") { r = dlopen_many_sym_or_warn( diff --git a/src/shared/seccomp-util.c b/src/shared/seccomp-util.c index 0ba0d6cd91c..2a8995666fe 100644 --- a/src/shared/seccomp-util.c +++ b/src/shared/seccomp-util.c @@ -16,8 +16,6 @@ #include #endif -#include "sd-dlopen.h" - #include "af-list.h" #include "alloc-util.h" #include "env-util.h" @@ -2604,7 +2602,7 @@ int dlopen_libseccomp(int log_level) { #if HAVE_SECCOMP static void *libseccomp_dl = NULL; - LIBSECCOMP_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBSECCOMP_NOTE(recommended); return dlopen_many_sym_or_warn( &libseccomp_dl, diff --git a/src/shared/seccomp-util.h b/src/shared/seccomp-util.h index 2bcb2d935ba..91e6bc886e5 100644 --- a/src/shared/seccomp-util.h +++ b/src/shared/seccomp-util.h @@ -1,8 +1,7 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "errno-util.h" #include "shared-forward.h" @@ -161,17 +160,6 @@ int parse_syscall_and_errno(const char *in, char **name, int *error); int seccomp_suppress_sync(void); -#define LIBSECCOMP_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("seccomp", \ - "Support for Seccomp Sandboxes", \ - priority, \ - "libseccomp.so.2") - -#define DLOPEN_LIBSECCOMP(log_level, priority) \ - ({ \ - LIBSECCOMP_NOTE(priority); \ - dlopen_libseccomp(log_level); \ - }) #else static inline bool is_seccomp_available(void) { @@ -179,11 +167,16 @@ static inline bool is_seccomp_available(void) { } -#define DLOPEN_LIBSECCOMP(log_level, priority) dlopen_libseccomp(log_level) #endif int dlopen_libseccomp(int log_level); +#define DLOPEN_LIBSECCOMP(log_level, priority) \ + ({ \ + LIBSECCOMP_NOTE(priority); \ + dlopen_libseccomp(log_level); \ + }) + /* This is a special value to be used where syscall filters otherwise expect errno numbers, will be replaced with real seccomp action. */ enum { diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index eb1f28a8144..ec10b5b846a 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -17,8 +17,6 @@ #include #include -#include "sd-dlopen.h" - #include "alloc-util.h" #include "fd-util.h" #include "path-util.h" @@ -94,7 +92,7 @@ int dlopen_libselinux(int log_level) { #if HAVE_SELINUX static void *libselinux_dl = NULL; - LIBSELINUX_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + LIBSELINUX_NOTE(recommended); return dlopen_many_sym_or_warn( &libselinux_dl, diff --git a/src/shared/selinux-util.h b/src/shared/selinux-util.h index 3cc48dd3acd..5c8181131e8 100644 --- a/src/shared/selinux-util.h +++ b/src/shared/selinux-util.h @@ -3,8 +3,7 @@ #include -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" #if HAVE_SELINUX @@ -56,28 +55,21 @@ extern DLSYM_PROTOTYPE(string_to_security_class); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(char*, sym_freecon, freeconp, NULL); -#define LIBSELINUX_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("selinux", \ - "Support for SELinux", \ - priority, \ - "libselinux.so.1") +#else + +static inline void freeconp(char **p) { + assert(*p == NULL); +} + +#endif + +int dlopen_libselinux(int log_level); #define DLOPEN_LIBSELINUX(log_level, priority) \ ({ \ LIBSELINUX_NOTE(priority); \ dlopen_libselinux(log_level); \ }) -#else - - -static inline void freeconp(char **p) { - assert(*p == NULL); -} - -#define DLOPEN_LIBSELINUX(log_level, priority) dlopen_libselinux(log_level) -#endif - -int dlopen_libselinux(int log_level); #define _cleanup_freecon_ _cleanup_(freeconp) diff --git a/src/shared/ssl-util.c b/src/shared/ssl-util.c index 80af61654e2..14ace396cd6 100644 --- a/src/shared/ssl-util.c +++ b/src/shared/ssl-util.c @@ -1,7 +1,5 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ -#include "sd-dlopen.h" - #include "log.h" /* IWYU pragma: keep */ #include "ssl-util.h" #include "strv.h" @@ -38,7 +36,7 @@ int dlopen_libssl(int log_level) { static void *libssl_dl = NULL; int r; - LIBSSL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBSSL_NOTE(suggested); FOREACH_STRING(soname, "libssl.so.4", "libssl.so.3") { r = dlopen_many_sym_or_warn( diff --git a/src/shared/ssl-util.h b/src/shared/ssl-util.h index 3a9a4084da3..8d60b16a1e7 100644 --- a/src/shared/ssl-util.h +++ b/src/shared/ssl-util.h @@ -1,29 +1,14 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - +#include "dlopen-note.h" #include "shared-forward.h" -int dlopen_libssl(int log_level); - #if HAVE_OPENSSL #ifndef SYSTEMD_CFLAGS_MARKER_LIBOPENSSL # error "missing libopenssl_cflags in meson dependency." #endif -#define LIBSSL_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("libssl", \ - "Support for TLS", \ - priority, \ - "libssl.so.4", "libssl.so.3") - -#define DLOPEN_LIBSSL(log_level, priority) \ - ({ \ - LIBSSL_NOTE(priority); \ - dlopen_libssl(log_level); \ - }) - # include /* IWYU pragma: export */ # include "dlfcn-util.h" @@ -60,7 +45,12 @@ extern DLSYM_PROTOTYPE(TLS_client_method); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL*, sym_SSL_free, SSL_freep, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL_CTX*, sym_SSL_CTX_free, SSL_CTX_freep, NULL); - -#else -#define DLOPEN_LIBSSL(log_level, priority) dlopen_libssl(log_level) #endif + +int dlopen_libssl(int log_level); + +#define DLOPEN_LIBSSL(log_level, priority) \ + ({ \ + LIBSSL_NOTE(priority); \ + dlopen_libssl(log_level); \ + }) diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index 11ae999093a..854d7fc4c55 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -4,7 +4,6 @@ #include #include "sd-device.h" -#include "sd-dlopen.h" #include "alloc-util.h" #include "ansi-color.h" @@ -171,7 +170,7 @@ static int dlopen_tpm2_esys(int log_level) { static void *libtss2_esys_dl = NULL; int r; - TPM2_ESYS_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBTSS2_ESYS_NOTE(suggested); r = dlopen_many_sym_or_warn( &libtss2_esys_dl, "libtss2-esys.so.0", log_level, @@ -233,7 +232,7 @@ static int dlopen_tpm2_esys(int log_level) { static int dlopen_tpm2_rc(int log_level) { static void *libtss2_rc_dl = NULL; - TPM2_RC_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBTSS2_RC_NOTE(suggested); return dlopen_many_sym_or_warn( &libtss2_rc_dl, "libtss2-rc.so.0", log_level, @@ -243,7 +242,7 @@ static int dlopen_tpm2_rc(int log_level) { static int dlopen_tpm2_mu(int log_level) { static void *libtss2_mu_dl = NULL; - TPM2_MU_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBTSS2_MU_NOTE(suggested); return dlopen_many_sym_or_warn( &libtss2_mu_dl, "libtss2-mu.so.0", log_level, @@ -275,7 +274,7 @@ static int dlopen_tpm2_tcti_device(int log_level) { /* The "device" TCTI is the most relevant one, let's also load it explicitly on dlopen_tpm2(), even * if we don't resolve any symbols here. */ - TPM2_TCTI_DEVICE_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED); + LIBTSS2_TCTI_DEVICE_NOTE(suggested); return dlopen_verbose( &libtss2_tcti_device_dl, diff --git a/src/shared/tpm2-util.h b/src/shared/tpm2-util.h index ea69940701e..63c449a31aa 100644 --- a/src/shared/tpm2-util.h +++ b/src/shared/tpm2-util.h @@ -1,9 +1,8 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once -#include "sd-dlopen.h" - #include "bitfield.h" +#include "dlopen-note.h" #include "iovec-util.h" #include "shared-forward.h" #include "sha256.h" @@ -58,34 +57,17 @@ int dlopen_tpm2(int log_level); * other tokens. */ #define ERRNO_IS_NEG_TPM2_TOKEN_MISMATCH(r) IN_SET(r, -EREMCHG, -ENOANO, -EPERM, -ENOSTR, -EREMOTE, -EADDRNOTAVAIL) -#if HAVE_TPM2 -#ifndef SYSTEMD_CFLAGS_MARKER_TPM2 -# error "missing tpm2_cflags in meson dependency." -#endif - -#define TPM2_ESYS_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("tpm", "Support for TPM", priority, "libtss2-esys.so.0") -#define TPM2_RC_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("tpm", "Support for TPM", priority, "libtss2-rc.so.0") -#define TPM2_MU_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("tpm", "Support for TPM", priority, "libtss2-mu.so.0") -#define TPM2_TCTI_DEVICE_NOTE(priority) \ - SD_ELF_NOTE_DLOPEN("tpm", "Support for TPM", priority, "libtss2-tcti-device.so.0") - -#define TPM2_NOTE(priority) \ - ({ \ - TPM2_ESYS_NOTE(priority); \ - TPM2_RC_NOTE(priority); \ - TPM2_MU_NOTE(priority); \ - TPM2_TCTI_DEVICE_NOTE(priority); \ - }) - #define DLOPEN_TPM2(log_level, priority) \ ({ \ TPM2_NOTE(priority); \ dlopen_tpm2(log_level); \ }) +#if HAVE_TPM2 +#ifndef SYSTEMD_CFLAGS_MARKER_TPM2 +# error "missing tpm2_cflags in meson dependency." +#endif + #include /* IWYU pragma: export */ #include /* IWYU pragma: export */ #include /* IWYU pragma: export */ @@ -483,8 +465,6 @@ typedef struct Tpm2PCRValue {} Tpm2PCRValue; static inline int tpm2_pcrlock_search_file(const char *path, FILE **ret_file, char **ret_path) { return -ENOENT; } - -#define DLOPEN_TPM2(log_level, priority) dlopen_tpm2(log_level) #endif /* HAVE_TPM2 */ int tpm2_list_devices(bool legend, bool quiet); diff --git a/src/shutdown/detach-swap.c b/src/shutdown/detach-swap.c index 585a2f85a68..9584284a560 100644 --- a/src/shutdown/detach-swap.c +++ b/src/shutdown/detach-swap.c @@ -36,7 +36,7 @@ int swap_list_get(const char *swaps, SwapDevice **head) { assert(head); - r = DLOPEN_LIBMOUNT(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBMOUNT(LOG_ERR, recommended); if (r < 0) return r; diff --git a/src/sysext/sysext.c b/src/sysext/sysext.c index e789af2e2f5..c8c50279f5b 100644 --- a/src/sysext/sysext.c +++ b/src/sysext/sysext.c @@ -1828,7 +1828,7 @@ static int unmerge( bool need_to_reload; int r; - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, required); r = get_extension_release_metadata(image_class, hierarchies, no_reload, &need_to_reload, &units_to_restart, &units_to_reload_or_restart); if (r < 0) @@ -2413,9 +2413,9 @@ static int merge(ImageClass image_class, int r; - (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBBLKID(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + (void) DLOPEN_CRYPTSETUP(LOG_DEBUG, recommended); + (void) DLOPEN_LIBBLKID(LOG_DEBUG, required); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, required); _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL; r = pidref_safe_fork("(sd-merge)", FORK_DEATHSIG_SIGTERM|FORK_LOG|FORK_NEW_MOUNTNS, &pidref); diff --git a/src/sysupdate/sysupdate-partition.c b/src/sysupdate/sysupdate-partition.c index 6361093231d..3fca5cc91ea 100644 --- a/src/sysupdate/sysupdate-partition.c +++ b/src/sysupdate/sysupdate-partition.c @@ -161,7 +161,7 @@ int find_suitable_partition( POINTER_MAY_BE_NULL(partition_type); assert(ret); - r = DLOPEN_FDISK(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_FDISK(LOG_DEBUG, recommended); if (r < 0) return r; @@ -230,7 +230,7 @@ int patch_partition( if (change == 0) /* Nothing to do */ return 0; - r = DLOPEN_FDISK(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_FDISK(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/sysupdate/sysupdate-resource.c b/src/sysupdate/sysupdate-resource.c index 275d8d7c15e..4f46e27869c 100644 --- a/src/sysupdate/sysupdate-resource.c +++ b/src/sysupdate/sysupdate-resource.c @@ -233,7 +233,7 @@ static int resource_load_from_blockdev(Resource *rr) { assert(rr); - r = DLOPEN_FDISK(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_FDISK(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 5d914bc4ba5..261a4f0b92a 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1270,7 +1270,7 @@ static int parse_acl_cond_exec( assert(cond_exec); assert(ret); - r = DLOPEN_LIBACL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBACL(LOG_DEBUG, recommended); if (r < 0) return r; @@ -1389,7 +1389,7 @@ static int path_set_acl( assert(c); - r = DLOPEN_LIBACL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + r = DLOPEN_LIBACL(LOG_DEBUG, recommended); if (r < 0) return r; diff --git a/src/tpm2-setup/tpm2-setup.c b/src/tpm2-setup/tpm2-setup.c index 86cfdb5d284..897c4daf14f 100644 --- a/src/tpm2-setup/tpm2-setup.c +++ b/src/tpm2-setup/tpm2-setup.c @@ -599,11 +599,11 @@ static int run(int argc, char *argv[]) { return EXIT_SUCCESS; } - r = DLOPEN_LIBCRYPTO(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBCRYPTO(LOG_ERR, required); if (r < 0) return r; - r = DLOPEN_TPM2(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_TPM2(LOG_ERR, required); if (r < 0) return r; diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index dcba83a5bd4..f9f68902841 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -520,7 +520,7 @@ static int builtin_blkid(UdevEvent *event, int argc, char *argv[]) { int64_t offset = 0; int r; - r = DLOPEN_LIBBLKID(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBBLKID(LOG_DEBUG, required); if (r < 0) return log_device_debug_errno(dev, r, "blkid not available: %m"); diff --git a/src/udev/udevd.c b/src/udev/udevd.c index 4cbc481c768..b452a1e848a 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -58,11 +58,11 @@ int run_udevd(int argc, char *argv[]) { return log_error_errno(r, "Failed to create /run/udev: %m"); /* Load some shared libraries before we fork any workers */ - (void) DLOPEN_LIBACL(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBBLKID(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBKMOD(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_LIBMOUNT(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); - (void) DLOPEN_TPM2(LOG_DEBUG, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED); + (void) DLOPEN_LIBACL(LOG_DEBUG, recommended); + (void) DLOPEN_LIBBLKID(LOG_DEBUG, recommended); + (void) DLOPEN_LIBKMOD(LOG_DEBUG, recommended); + (void) DLOPEN_LIBMOUNT(LOG_DEBUG, recommended); + (void) DLOPEN_TPM2(LOG_DEBUG, recommended); if (arg_daemonize) { pid_t pid; diff --git a/src/validatefs/validatefs.c b/src/validatefs/validatefs.c index 994fcbeb13d..0f4780ada58 100644 --- a/src/validatefs/validatefs.c +++ b/src/validatefs/validatefs.c @@ -290,7 +290,7 @@ static int validate_gpt_metadata_one(sd_device *d, const char *path, const Valid assert(d); assert(f); - r = DLOPEN_LIBBLKID(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_LIBBLKID(LOG_ERR, required); if (r < 0) return r; diff --git a/src/veritysetup/veritysetup.c b/src/veritysetup/veritysetup.c index 2b02694b9b1..dde1910866b 100644 --- a/src/veritysetup/veritysetup.c +++ b/src/veritysetup/veritysetup.c @@ -493,7 +493,7 @@ static int run(int argc, char *argv[]) { log_setup(); - r = DLOPEN_CRYPTSETUP(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_REQUIRED); + r = DLOPEN_CRYPTSETUP(LOG_ERR, required); if (r < 0) return r;