shared: add DLOPEN_* wrapper macros that stamp .note.dlopen on callers
This macro emits an SD_ELF_NOTE_DLOPEN note so that calling sites, and not just libsystemd-shared, get the ELF stamped with the notes documenting the dependency. Currently most of the dlopen notes end up in libsystemd-shared, and executables have no way to document the optional dependencies they need. With this new macro, this issue can be fixed. Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -39,11 +39,7 @@ int dlopen_libintl(int log_level) {
|
||||
#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,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#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"
|
||||
|
||||
@@ -14,6 +16,22 @@ extern DLSYM_PROTOTYPE(dgettext) __attribute__((format_arg(2)));
|
||||
|
||||
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. */
|
||||
|
||||
@@ -49,11 +49,7 @@ int dlopen_libacl(int log_level) {
|
||||
#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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_ACL
|
||||
@@ -60,6 +62,17 @@ 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;
|
||||
@@ -90,6 +103,8 @@ 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);
|
||||
|
||||
@@ -99,11 +99,7 @@ int dlopen_libblkid(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_BLKID
|
||||
@@ -63,6 +65,20 @@ 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);
|
||||
|
||||
#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);
|
||||
|
||||
@@ -87,11 +87,7 @@ int dlopen_bpf(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;
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#if HAVE_LIBBPF
|
||||
|
||||
#include <bpf/bpf.h> /* IWYU pragma: export */
|
||||
@@ -88,6 +90,19 @@ static inline int compat_bpf_map_create(
|
||||
* 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);
|
||||
|
||||
@@ -336,11 +336,7 @@ int dlopen_libcrypto(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* 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"
|
||||
@@ -31,6 +33,18 @@ int dlopen_libcrypto(int log_level);
|
||||
#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 */
|
||||
@@ -402,4 +416,6 @@ 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
|
||||
|
||||
@@ -281,11 +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. */
|
||||
|
||||
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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "dlfcn-util.h"
|
||||
#include "shared-forward.h"
|
||||
|
||||
@@ -89,6 +91,20 @@ 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);
|
||||
|
||||
@@ -604,11 +604,7 @@ int dlopen_curl(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_LIBCURL
|
||||
@@ -71,6 +73,19 @@ 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);
|
||||
|
||||
@@ -83,11 +83,7 @@ int dlopen_fdisk(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_LIBFDISK
|
||||
@@ -84,6 +86,19 @@ 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);
|
||||
|
||||
@@ -17,11 +17,7 @@ DLSYM_PROTOTYPE(idn2_to_unicode_8z8z) = NULL;
|
||||
|
||||
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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_LIBIDN2
|
||||
@@ -11,6 +13,20 @@
|
||||
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);
|
||||
|
||||
@@ -80,11 +80,7 @@ int dlopen_libarchive(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_LIBARCHIVE
|
||||
@@ -79,9 +81,20 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive_entry*, sym_archive_entry
|
||||
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);
|
||||
|
||||
#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);
|
||||
|
||||
@@ -120,11 +120,7 @@ int dlopen_libmount(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_LIBMOUNT
|
||||
@@ -73,6 +75,17 @@ 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;
|
||||
@@ -83,6 +96,7 @@ static inline void* sym_mnt_unref_monitor(struct libmnt_monitor *p) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define DLOPEN_LIBMOUNT(log_level, priority) dlopen_libmount(log_level)
|
||||
#endif
|
||||
|
||||
int dlopen_libmount(int log_level);
|
||||
|
||||
@@ -36,11 +36,7 @@ int dlopen_microhttpd(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,
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
/* 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>
|
||||
|
||||
@@ -134,4 +147,6 @@ 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
|
||||
|
||||
@@ -173,11 +173,7 @@ int dlopen_libkmod(int log_level) {
|
||||
#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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_KMOD
|
||||
@@ -35,6 +37,17 @@ 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;
|
||||
@@ -48,6 +61,7 @@ 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);
|
||||
|
||||
@@ -383,11 +383,7 @@ int dlopen_libpam(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_PAM
|
||||
@@ -104,6 +106,19 @@ int pam_prompt_graceful(pam_handle_t *pamh, int style, char **ret_response, cons
|
||||
* 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);
|
||||
|
||||
@@ -2604,11 +2604,7 @@ int dlopen_libseccomp(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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "errno-util.h"
|
||||
#include "shared-forward.h"
|
||||
|
||||
@@ -155,6 +157,17 @@ 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) {
|
||||
@@ -162,6 +175,7 @@ static inline bool is_seccomp_available(void) {
|
||||
}
|
||||
|
||||
|
||||
#define DLOPEN_LIBSECCOMP(log_level, priority) dlopen_libseccomp(log_level)
|
||||
#endif
|
||||
|
||||
int dlopen_libseccomp(int log_level);
|
||||
|
||||
@@ -94,11 +94,7 @@ int dlopen_libselinux(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,
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "sd-dlopen.h"
|
||||
|
||||
#include "shared-forward.h"
|
||||
|
||||
#if HAVE_SELINUX
|
||||
@@ -50,12 +52,25 @@ 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")
|
||||
|
||||
#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);
|
||||
|
||||
@@ -36,11 +36,7 @@ int dlopen_libssl(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,
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
/* 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 */
|
||||
|
||||
@@ -43,4 +56,6 @@ extern DLSYM_PROTOTYPE(TLS_client_method);
|
||||
|
||||
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
|
||||
|
||||
+4
-20
@@ -124,11 +124,7 @@ static int dlopen_tpm2_esys(int log_level) {
|
||||
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,
|
||||
@@ -190,11 +186,7 @@ static int dlopen_tpm2_esys(int 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,
|
||||
@@ -204,11 +196,7 @@ static int dlopen_tpm2_rc(int 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,
|
||||
@@ -239,11 +227,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. */
|
||||
|
||||
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,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/* 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"
|
||||
@@ -43,6 +45,28 @@ static inline bool TPM2_PCR_MASK_VALID(uint32_t pcr_mask) {
|
||||
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 */
|
||||
@@ -413,6 +437,7 @@ static inline int tpm2_pcrlock_search_file(const char *path, FILE **ret_file, ch
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
#define DLOPEN_TPM2(log_level, priority) dlopen_tpm2(log_level)
|
||||
#endif /* HAVE_TPM2 */
|
||||
|
||||
int tpm2_list_devices(bool legend, bool quiet);
|
||||
|
||||
Reference in New Issue
Block a user