#else
static void *libintl_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "intl",
- "Support for message translation via gettext",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libintl.so.8");
+ LIBINTL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&libintl_dl,
#include <libintl.h> /* IWYU pragma: export */
#include <locale.h> /* IWYU pragma: export */
+#include "sd-dlopen.h" /* IWYU pragma: export */
+
#include "basic-forward.h"
#include "dlfcn-util.h"
int dlopen_libintl(int log_level);
+#ifdef __GLIBC__
+#define DLOPEN_LIBINTL(log_level, priority) dlopen_libintl(log_level)
+#else
+#define LIBINTL_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("intl", \
+ "Support for message translation via gettext", \
+ priority, \
+ "libintl.so.8")
+
+#define DLOPEN_LIBINTL(log_level, priority) \
+ ({ \
+ LIBINTL_NOTE(priority); \
+ dlopen_libintl(log_level); \
+ })
+#endif
+
typedef enum LocaleVariable {
/* We don't list LC_ALL here on purpose. People should be
* using LANG instead. */
#if HAVE_ACL
static void *libacl_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "acl",
- "Support for file Access Control Lists (ACLs)",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libacl.so.1");
+ LIBACL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libacl_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_ACL
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;
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);
#if HAVE_BLKID
static void *libblkid_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "blkid",
- "Support for block device identification",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libblkid.so.1");
+ LIBBLKID_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libblkid_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_BLKID
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);
+
+#define LIBBLKID_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("blkid", \
+ "Support for block device identification", \
+ priority, \
+ "libblkid.so.1")
+
+#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);
if (cached < 0)
return cached; /* Already tried, and failed. */
- SD_ELF_NOTE_DLOPEN(
- "bpf",
- "Support firewalling and sandboxing with BPF",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libbpf.so.1", "libbpf.so.0");
+ BPF_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
DISABLE_WARNING_DEPRECATED_DECLARATIONS;
#include <syslog.h>
+#include "sd-dlopen.h"
+
#if HAVE_LIBBPF
#include <bpf/bpf.h> /* IWYU pragma: export */
* 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);
#if HAVE_OPENSSL
static void *libcrypto_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "libcrypto",
- "Support for cryptographic operations",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libcrypto.so.3");
+ LIBCRYPTO_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&libcrypto_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#include "iovec-util.h"
#include "sha256.h"
#define X509_FINGERPRINT_SIZE SHA256_DIGEST_SIZE
#if HAVE_OPENSSL
+#define LIBCRYPTO_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("libcrypto", \
+ "Support for cryptographic operations", \
+ priority, \
+ "libcrypto.so.3")
+
+#define DLOPEN_LIBCRYPTO(log_level, priority) \
+ ({ \
+ LIBCRYPTO_NOTE(priority); \
+ dlopen_libcrypto(log_level); \
+ })
+
# include <openssl/bio.h> /* IWYU pragma: export */
# include <openssl/bn.h> /* IWYU pragma: export */
# include <openssl/crypto.h> /* IWYU pragma: export */
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
* 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. */
- SD_ELF_NOTE_DLOPEN(
- "cryptsetup",
- "Support for disk encryption, integrity, and authentication",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libcryptsetup.so.12");
+ CRYPTSETUP_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
r = dlopen_many_sym_or_warn(
&cryptsetup_dl, "libcryptsetup.so.12", log_level,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "dlfcn-util.h"
#include "shared-forward.h"
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);
#if HAVE_LIBCURL
static void *curl_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "curl",
- "Support for downloading and uploading files over HTTP",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libcurl.so.4");
+ CURL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&curl_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_LIBCURL
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);
#if HAVE_LIBFDISK
static void *fdisk_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "fdisk",
- "Support for reading and writing partition tables",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libfdisk.so.1");
+ FDISK_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&fdisk_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_LIBFDISK
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);
int dlopen_idn(int log_level) {
#if HAVE_LIBIDN2
- SD_ELF_NOTE_DLOPEN(
- "idn",
- "Support for internationalized domain names",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libidn2.so.0");
+ IDN_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&idn_dl, "libidn2.so.0", log_level,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_LIBIDN2
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);
static void *libarchive_dl = NULL;
int r;
- SD_ELF_NOTE_DLOPEN(
- "archive",
- "Support for decompressing archive files",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libarchive.so.13");
+ LIBARCHIVE_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
r = dlopen_many_sym_or_warn(
&libarchive_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_LIBARCHIVE
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);
-#else
+#define LIBARCHIVE_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("archive", \
+ "Support for decompressing archive files", \
+ priority, \
+ "libarchive.so.13")
+#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);
#if HAVE_LIBMOUNT
static void *libmount_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "mount",
- "Support for mount enumeration",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libmount.so.1");
+ LIBMOUNT_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libmount_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_LIBMOUNT
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;
return NULL;
}
+#define DLOPEN_LIBMOUNT(log_level, priority) dlopen_libmount(log_level)
#endif
int dlopen_libmount(int log_level);
#if HAVE_MICROHTTPD
static void *microhttpd_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "microhttpd",
- "Support for embedded HTTP server via libmicrohttpd",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libmicrohttpd.so.12");
+ MICROHTTPD_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
µhttpd_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
int dlopen_microhttpd(int log_level);
#if HAVE_MICROHTTPD
+#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 <microhttpd.h>
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
#if HAVE_KMOD
static void *libkmod_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "kmod",
- "Support for loading kernel modules",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libkmod.so.2");
+ LIBKMOD_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libkmod_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_KMOD
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;
return -EOPNOTSUPP;
}
+#define DLOPEN_LIBKMOD(log_level, priority) dlopen_libkmod(log_level)
#endif
int dlopen_libkmod(int log_level);
#if HAVE_PAM
static void *libpam_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "pam",
- "Support for LinuxPAM",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libpam.so.0");
+ LIBPAM_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libpam_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_PAM
* 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);
+#define LIBPAM_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("pam", \
+ "Support for LinuxPAM", \
+ priority, \
+ "libpam.so.0")
+
+#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);
#if HAVE_SECCOMP
static void *libseccomp_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "seccomp",
- "Support for Seccomp Sandboxes",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libseccomp.so.2");
+ LIBSECCOMP_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libseccomp_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "errno-util.h"
#include "shared-forward.h"
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) {
}
+#define DLOPEN_LIBSECCOMP(log_level, priority) dlopen_libseccomp(log_level)
#endif
int dlopen_libseccomp(int log_level);
#if HAVE_SELINUX
static void *libselinux_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "selinux",
- "Support for SELinux",
- SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
- "libselinux.so.1");
+ LIBSELINUX_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
return dlopen_many_sym_or_warn(
&libselinux_dl,
#include <sys/socket.h>
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
#if HAVE_SELINUX
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")
+
+#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);
#if HAVE_OPENSSL
static void *libssl_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "libssl",
- "Support for TLS",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libssl.so.3");
+ LIBSSL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&libssl_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "shared-forward.h"
int dlopen_libssl(int log_level);
#if HAVE_OPENSSL
+#define LIBSSL_NOTE(priority) \
+ SD_ELF_NOTE_DLOPEN("libssl", \
+ "Support for TLS", \
+ priority, \
+ "libssl.so.3")
+
+#define DLOPEN_LIBSSL(log_level, priority) \
+ ({ \
+ LIBSSL_NOTE(priority); \
+ dlopen_libssl(log_level); \
+ })
# include <openssl/ssl.h> /* IWYU pragma: export */
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL*, sym_SSL_free, SSL_freep, NULL);
+#else
+#define DLOPEN_LIBSSL(log_level, priority) dlopen_libssl(log_level)
#endif
static void *libtss2_esys_dl = NULL;
int r;
- SD_ELF_NOTE_DLOPEN(
- "tpm",
- "Support for TPM",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libtss2-esys.so.0");
+ TPM2_ESYS_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
r = dlopen_many_sym_or_warn(
&libtss2_esys_dl, "libtss2-esys.so.0", log_level,
static int dlopen_tpm2_rc(int log_level) {
static void *libtss2_rc_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "tpm",
- "Support for TPM",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libtss2-rc.so.0");
+ TPM2_RC_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&libtss2_rc_dl, "libtss2-rc.so.0", log_level,
static int dlopen_tpm2_mu(int log_level) {
static void *libtss2_mu_dl = NULL;
- SD_ELF_NOTE_DLOPEN(
- "tpm",
- "Support for TPM",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libtss2-mu.so.0");
+ TPM2_MU_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_many_sym_or_warn(
&libtss2_mu_dl, "libtss2-mu.so.0", 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. */
- SD_ELF_NOTE_DLOPEN(
- "tpm",
- "Support for TPM",
- SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
- "libtss2-tcti-device.so.0");
+ TPM2_TCTI_DEVICE_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
return dlopen_verbose(
&libtss2_tcti_device_dl,
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "sd-dlopen.h"
+
#include "bitfield.h"
#include "iovec-util.h"
#include "shared-forward.h"
int dlopen_tpm2(int log_level);
#if HAVE_TPM2
+#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); \
+ })
#include <tss2/tss2_esys.h> /* IWYU pragma: export */
#include <tss2/tss2_mu.h> /* IWYU pragma: export */
return -ENOENT;
}
+#define DLOPEN_TPM2(log_level, priority) dlopen_tpm2(log_level)
#endif /* HAVE_TPM2 */
int tpm2_list_devices(bool legend, bool quiet);