1
0
mirror of https://github.com/systemd/systemd synced 2025-11-18 16:24:44 +01:00

Compare commits

...

19 Commits

Author SHA1 Message Date
Daan De Meyer
f59f4ac2a7
Several cleanups for dlopen() (#39441) 2025-10-25 09:19:28 +02:00
Yu Watanabe
687bb9e2ce test: sort libraries in test-dlopen-so 2025-10-25 14:03:13 +09:00
Yu Watanabe
5e385fe16e locale: use include directory for libxkbcommon
To support the case the headers are installed at an unusual place.
2025-10-25 13:06:02 +09:00
Yu Watanabe
85fb6ad573 meson: add all 'cflags' dependencies to libshared
This should not change any behavior in most common setups.
But, may be useful when headers are installed at non-default places.
2025-10-25 12:52:23 +09:00
Yu Watanabe
910e3843fd pwquality: drop 'sym_' prefix from cleanup function
This also drops unnecessary symbols in header.
2025-10-25 11:54:21 +09:00
Yu Watanabe
7d7b1755e9 passwdqc: drop 'sym_' prefix from cleanup function
This also drops unnecessary symbols in header.
2025-10-25 11:53:41 +09:00
Yu Watanabe
56b52c00e3 qrcode-util: drop 'sym_' prefix from cleanup function 2025-10-25 11:45:20 +09:00
Yu Watanabe
63649394cc pcre2-util: drop trivial pattern_free() wrapper 2025-10-25 11:43:00 +09:00
Yu Watanabe
8aadb82966 pcre2-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:28:30 +09:00
Yu Watanabe
76afd4dc4a elf-util: drop 'sym_' prefix from cleanup function 2025-10-25 11:26:39 +09:00
Yu Watanabe
53dceb8a6d xkbcommon-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:25:41 +09:00
Yu Watanabe
fc945d22d5 libarchive-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:25:19 +09:00
Yu Watanabe
afb9b7c581 apparmor-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:21:12 +09:00
Yu Watanabe
78c86080ec compress: drop 'sym_' prefix from cleanup functions 2025-10-25 11:18:52 +09:00
Yu Watanabe
744d0e4422 pkcs11-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:15:05 +09:00
Yu Watanabe
d0520b1ee7 module-util: drop 'sym_' prefix from cleanup functions 2025-10-25 11:12:16 +09:00
Yu Watanabe
163a3990fa openssl-util: fix spurious indent 2025-10-25 10:40:43 +09:00
Yu Watanabe
73063abf24 openssl-util: drop unused functions
They were introduced by 5f163921e9ff6d735798db259c47543822f81b5c, but
never used.
2025-10-25 10:26:49 +09:00
Yu Watanabe
5f884da903 cleanup: introduce DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME() macro
This is similar to DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(), but for
macro.
2025-10-25 10:22:16 +09:00
33 changed files with 133 additions and 152 deletions

View File

@ -1034,6 +1034,7 @@ bpf_compiler = get_option('bpf-compiler')
libbpf = dependency('libbpf',
required : bpf_framework,
version : bpf_compiler == 'gcc' ? '>= 1.4.0' : '>= 0.1.0')
libbpf_cflags = libbpf.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_LIBBPF', libbpf.found())
if not libbpf.found()
@ -1139,6 +1140,7 @@ if not have
libpwquality = dependency('passwdqc',
required : get_option('passwdqc'))
endif
libpwquality_cflags = libpwquality.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_PWQUALITY', have)
conf.set10('HAVE_PASSWDQC', not have and libpwquality.found())
@ -1242,6 +1244,7 @@ endif
libcryptsetup = dependency('libcryptsetup',
version : libcryptsetup_plugins.enabled() ? '>= 2.4.0' : '>= 2.0.1',
required : libcryptsetup)
libcryptsetup_cflags = libcryptsetup.partial_dependency(includes: true, compile_args: true)
have = libcryptsetup.found()
foreach ident : ['crypt_set_metadata_size',
@ -1307,12 +1310,14 @@ if not have
libidn = dependency('libidn',
required : get_option('libidn'))
endif
libidn_cflags = libidn.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_LIBIDN', not have and libidn.found())
conf.set10('HAVE_LIBIDN2', have)
libqrencode = dependency('libqrencode',
version : '>= 3',
required : get_option('qrencode'))
libqrencode_cflags = libqrencode.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_QRENCODE', libqrencode.found())
feature = get_option('gcrypt')
@ -1353,16 +1358,23 @@ feature = get_option('libfido2').require(
error_message : 'openssl required')
libfido2 = dependency('libfido2',
required : feature)
libfido2_cflags = libfido2.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_LIBFIDO2', libfido2.found())
tpm2 = dependency('tss2-esys tss2-rc tss2-mu tss2-tcti-device',
required : get_option('tpm2'))
tpm2_cflags = tpm2.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_TPM2', tpm2.found())
conf.set10('HAVE_TSS2_ESYS3', tpm2.found() and tpm2.version().version_compare('>= 3.0.0'))
libdw = dependency('libdw',
required : get_option('elfutils'))
conf.set10('HAVE_ELFUTILS', libdw.found())
libdw_cflags = libdw.partial_dependency(includes: true, compile_args: true)
libelf = dependency('libelf',
required : get_option('elfutils'))
libelf_cflags = libelf.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_ELFUTILS', libdw.found() and libelf.found())
# New in elfutils 0.177
conf.set10('HAVE_DWELF_ELF_E_MACHINE_STRING',
libdw.found() and cc.has_function('dwelf_elf_e_machine_string', dependencies : libdw))
@ -1435,6 +1447,7 @@ conf.set('DEFAULT_COMPRESSION', 'COMPRESSION_@0@'.format(compression.to_upper())
libarchive = dependency('libarchive',
version : '>= 3.0',
required : get_option('libarchive'))
libarchive_cflags = libarchive.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_LIBARCHIVE', libarchive.found())
conf.set10('HAVE_LIBARCHIVE_UID_IS_SET',
libarchive.found() and cc.has_function('archive_entry_uid_is_set', dependencies : libarchive))
@ -1444,10 +1457,12 @@ conf.set10('HAVE_LIBARCHIVE_HARDLINK_IS_SET',
libxkbcommon = dependency('xkbcommon',
version : '>= 0.3.0',
required : get_option('xkbcommon'))
libxkbcommon_cflags = libxkbcommon.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_XKBCOMMON', libxkbcommon.found())
libpcre2 = dependency('libpcre2-8',
required : get_option('pcre2'))
libpcre2_cflags = libpcre2.partial_dependency(includes: true, compile_args: true)
conf.set10('HAVE_PCRE2', libpcre2.found())
libglib = dependency('glib-2.0',

View File

@ -51,8 +51,8 @@ DLSYM_PROTOTYPE(LZ4_decompress_safe) = NULL;
DLSYM_PROTOTYPE(LZ4_decompress_safe_partial) = NULL;
DLSYM_PROTOTYPE(LZ4_versionNumber) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_compressionContext_t, sym_LZ4F_freeCompressionContext, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_decompressionContext_t, sym_LZ4F_freeDecompressionContext, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(LZ4F_compressionContext_t, sym_LZ4F_freeCompressionContext, LZ4F_freeCompressionContextp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(LZ4F_decompressionContext_t, sym_LZ4F_freeDecompressionContext, LZ4F_freeDecompressionContextp, NULL);
#endif
#if HAVE_ZSTD
@ -75,8 +75,8 @@ static DLSYM_PROTOTYPE(ZSTD_getErrorName) = NULL;
static DLSYM_PROTOTYPE(ZSTD_getFrameContentSize) = NULL;
static DLSYM_PROTOTYPE(ZSTD_isError) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_CCtx*, sym_ZSTD_freeCCtx, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_DCtx*, sym_ZSTD_freeDCtx, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(ZSTD_CCtx*, sym_ZSTD_freeCCtx, ZSTD_freeCCtxp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(ZSTD_DCtx*, sym_ZSTD_freeDCtx, ZSTD_freeDCtxp, NULL);
static int zstd_ret_to_errno(size_t ret) {
switch (sym_ZSTD_getErrorCode(ret)) {
@ -481,7 +481,7 @@ int decompress_blob_zstd(
if (!(greedy_realloc(dst, MAX(sym_ZSTD_DStreamOutSize(), size), 1)))
return -ENOMEM;
_cleanup_(sym_ZSTD_freeDCtxp) ZSTD_DCtx *dctx = sym_ZSTD_createDCtx();
_cleanup_(ZSTD_freeDCtxp) ZSTD_DCtx *dctx = sym_ZSTD_createDCtx();
if (!dctx)
return -ENOMEM;
@ -701,7 +701,7 @@ int decompress_startswith_zstd(
if (size < prefix_len + 1)
return 0; /* Decompressed text too short to match the prefix and extra */
_cleanup_(sym_ZSTD_freeDCtxp) ZSTD_DCtx *dctx = sym_ZSTD_createDCtx();
_cleanup_(ZSTD_freeDCtxp) ZSTD_DCtx *dctx = sym_ZSTD_createDCtx();
if (!dctx)
return -ENOMEM;
@ -858,7 +858,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_unco
#if HAVE_LZ4
LZ4F_errorCode_t c;
_cleanup_(sym_LZ4F_freeCompressionContextp) LZ4F_compressionContext_t ctx = NULL;
_cleanup_(LZ4F_freeCompressionContextp) LZ4F_compressionContext_t ctx = NULL;
_cleanup_free_ void *in_buff = NULL;
_cleanup_free_ char *out_buff = NULL;
size_t out_allocsize, n, offset = 0, frame_size;
@ -1032,7 +1032,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
#if HAVE_LZ4
size_t c;
_cleanup_(sym_LZ4F_freeDecompressionContextp) LZ4F_decompressionContext_t ctx = NULL;
_cleanup_(LZ4F_freeDecompressionContextp) LZ4F_decompressionContext_t ctx = NULL;
_cleanup_free_ char *buf = NULL;
char *src;
struct stat st;
@ -1106,7 +1106,7 @@ int compress_stream_zstd(int fdf, int fdt, uint64_t max_bytes, uint64_t *ret_unc
assert(fdt >= 0);
#if HAVE_ZSTD
_cleanup_(sym_ZSTD_freeCCtxp) ZSTD_CCtx *cctx = NULL;
_cleanup_(ZSTD_freeCCtxp) ZSTD_CCtx *cctx = NULL;
_cleanup_free_ void *in_buff = NULL, *out_buff = NULL;
size_t in_allocsize, out_allocsize;
size_t z;
@ -1215,7 +1215,7 @@ int decompress_stream_zstd(int fdf, int fdt, uint64_t max_bytes) {
assert(fdt >= 0);
#if HAVE_ZSTD
_cleanup_(sym_ZSTD_freeDCtxp) ZSTD_DCtx *dctx = NULL;
_cleanup_(ZSTD_freeDCtxp) ZSTD_DCtx *dctx = NULL;
_cleanup_free_ void *in_buff = NULL, *out_buff = NULL;
size_t in_allocsize, out_allocsize;
size_t last_result = 0;

View File

@ -14,8 +14,8 @@
int mac_apparmor_setup(void) {
#if HAVE_APPARMOR
_cleanup_(sym_aa_policy_cache_unrefp) aa_policy_cache *policy_cache = NULL;
_cleanup_(sym_aa_features_unrefp) aa_features *features = NULL;
_cleanup_(aa_policy_cache_unrefp) aa_policy_cache *policy_cache = NULL;
_cleanup_(aa_features_unrefp) aa_features *features = NULL;
_cleanup_free_ char *current_profile = NULL, *cache_dir_path = NULL;
int r;

View File

@ -2039,7 +2039,7 @@ int bus_exec_context_set_transient_property(
return r;
while ((r = sd_bus_message_read(message, "(bs)", &is_allowlist, &pattern)) > 0) {
_cleanup_(pattern_freep) pcre2_code *compiled_pattern = NULL;
_cleanup_(pcre2_code_freep) pcre2_code *compiled_pattern = NULL;
if (isempty(pattern))
continue;

View File

@ -148,7 +148,7 @@ int kmod_setup(void) {
if (have_effective_cap(CAP_SYS_MODULE) <= 0)
return 0;
_cleanup_(sym_kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
FOREACH_ELEMENT(kmod, kmod_table) {
if (kmod->path && access(kmod->path, F_OK) >= 0)
continue;

View File

@ -10,7 +10,7 @@
#if HAVE_P11KIT && HAVE_OPENSSL
static int uri_set_private_class(const char *uri, char **ret_uri) {
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *p11kit_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *p11kit_uri = NULL;
_cleanup_free_ char *private_uri = NULL;
int r;

View File

@ -1455,7 +1455,7 @@ static int archive_item(
log_debug("Archiving %s\n", path);
_cleanup_(sym_archive_entry_freep) struct archive_entry *entry = NULL;
_cleanup_(archive_entry_freep) struct archive_entry *entry = NULL;
entry = sym_archive_entry_new();
if (!entry)
return log_oom();
@ -1744,7 +1744,7 @@ static int action_list_or_mtree_or_copy_or_make_archive(DissectedImage *m, LoopD
if (dfd < 0)
return log_error_errno(errno, "Failed to open mount directory: %m");
_cleanup_(sym_archive_write_freep) struct archive *a = sym_archive_write_new();
_cleanup_(archive_write_freep) struct archive *a = sym_archive_write_new();
if (!a)
return log_oom();

View File

@ -34,14 +34,17 @@
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(type, func, func##p, empty)
/* When func() doesn't return the appropriate type, and is also a macro, set variable to empty afterwards. */
#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO(type, func, empty) \
static inline void func##p(type *p) { \
#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME(type, macro, name, empty) \
static inline void name(type *p) { \
if (*p != (empty)) { \
func(*p); \
macro(*p); \
*p = (empty); \
} \
}
#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO(type, macro, empty) \
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME(type, macro, macro##p, empty)
typedef void (*free_array_func_t)(void *p, size_t n);
/* An automatic _cleanup_-like logic for destroy arrays (i.e. pointers + size) when leaving scope */

View File

@ -126,7 +126,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_machine, freep);
STATIC_DESTRUCTOR_REGISTER(arg_namespace, freep);
STATIC_DESTRUCTOR_REGISTER(arg_output_fields, set_freep);
STATIC_DESTRUCTOR_REGISTER(arg_pattern, freep);
STATIC_DESTRUCTOR_REGISTER(arg_compiled_pattern, pattern_freep);
STATIC_DESTRUCTOR_REGISTER(arg_compiled_pattern, pcre2_code_freep);
STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep);
static int parse_id_descriptor(const char *x, sd_id128_t *ret_id, int *ret_offset) {

View File

@ -33,7 +33,7 @@ static int client_parse_log_filter_nulstr(const char *nulstr, size_t len, Set **
return log_oom_debug();
STRV_FOREACH(pattern, patterns_strv) {
_cleanup_(pattern_freep) pcre2_code *compiled_pattern = NULL;
_cleanup_(pcre2_code_freep) pcre2_code *compiled_pattern = NULL;
r = pattern_compile_and_log(*pattern, 0, &compiled_pattern);
if (r < 0)

View File

@ -19,7 +19,7 @@ localectl_sources = files('localectl.c')
if conf.get('HAVE_XKBCOMMON') == 1
libxkbcommon_deps = [
libdl,
libxkbcommon.partial_dependency(compile_args: true),
libxkbcommon_cflags,
]
else
libxkbcommon_deps = []

View File

@ -38,12 +38,12 @@ static void log_xkb(struct xkb_context *ctx, enum xkb_log_level lvl, const char
REENABLE_WARNING;
}
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct xkb_context *, sym_xkb_context_unref, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct xkb_keymap *, sym_xkb_keymap_unref, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct xkb_context *, sym_xkb_context_unref, xkb_context_unrefp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct xkb_keymap *, sym_xkb_keymap_unref, xkb_keymap_unrefp, NULL);
int verify_xkb_rmlvo(const char *model, const char *layout, const char *variant, const char *options) {
_cleanup_(sym_xkb_context_unrefp) struct xkb_context *ctx = NULL;
_cleanup_(sym_xkb_keymap_unrefp) struct xkb_keymap *km = NULL;
_cleanup_(xkb_context_unrefp) struct xkb_context *ctx = NULL;
_cleanup_(xkb_keymap_unrefp) struct xkb_keymap *km = NULL;
const struct xkb_rule_names rmlvo = {
.model = model,
.layout = layout,

View File

@ -135,7 +135,7 @@ static int parse_argv(int argc, char *argv[]) {
}
static int run(int argc, char *argv[]) {
_cleanup_(sym_kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
int r, k;
r = parse_argv(argc, argv);

View File

@ -17,8 +17,8 @@ extern DLSYM_PROTOTYPE(aa_policy_cache_new);
extern DLSYM_PROTOTYPE(aa_policy_cache_replace_all);
extern DLSYM_PROTOTYPE(aa_policy_cache_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_features*, sym_aa_features_unref, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_policy_cache*, sym_aa_policy_cache_unref, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(aa_features*, sym_aa_features_unref, aa_features_unrefp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(aa_policy_cache*, sym_aa_policy_cache_unref, aa_policy_cache_unrefp, NULL);
int dlopen_libapparmor(void);
#else

View File

@ -205,7 +205,7 @@ static void stack_context_done(StackContext *c) {
}
}
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(Elf *, sym_elf_end, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(Elf *, sym_elf_end, elf_endp, NULL);
static int frame_callback(Dwfl_Frame *frame, void *userdata) {
StackContext *c = ASSERT_PTR(userdata);
@ -587,7 +587,7 @@ static int module_callback(Dwfl_Module *mod, void **userdata, const char *name,
if (!data)
continue;
_cleanup_(sym_elf_endp) Elf *memelf = sym_elf_memory(data->d_buf, data->d_size);
_cleanup_(elf_endp) Elf *memelf = sym_elf_memory(data->d_buf, data->d_size);
if (!memelf)
continue;
r = parse_package_metadata(name, id_json, memelf, NULL, c);

View File

@ -77,9 +77,9 @@ static inline int sym_archive_entry_hardlink_is_set(struct archive_entry *e) {
int dlopen_libarchive(void);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct archive_entry*, sym_archive_entry_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct archive*, sym_archive_write_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct archive*, sym_archive_read_free, NULL);
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);
#else

View File

@ -359,23 +359,34 @@ libshared_name = 'systemd-shared-@0@'.format(shared_lib_tag)
libshared_deps = [threads,
libacl_cflags,
libapparmor_cflags,
libarchive_cflags,
libaudit_cflags,
libblkid_cflags,
libbpf_cflags,
libcrypt,
libcryptsetup_cflags,
libdl,
libdw_cflags,
libelf_cflags,
libfido2_cflags,
libgcrypt_cflags,
libidn_cflags,
libkmod_cflags,
liblz4_cflags,
libmount_cflags,
libopenssl,
libp11kit_cflags,
libpam_cflags,
libpcre2_cflags,
libpwquality_cflags,
libqrencode_cflags,
librt,
libseccomp_cflags,
libselinux_cflags,
libxenctrl_cflags,
libxz_cflags,
libzstd_cflags]
libzstd_cflags,
tpm2_cflags]
libshared_sym_path = meson.current_source_dir() / 'libshared.sym'
libshared_build_dir = meson.current_build_dir()

View File

@ -68,7 +68,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
}
int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose) {
_cleanup_(sym_kmod_module_unref_listp) struct kmod_list *modlist = NULL;
_cleanup_(kmod_module_unref_listp) struct kmod_list *modlist = NULL;
_cleanup_strv_free_ char **denylist = NULL;
bool denylist_parsed = false;
struct kmod_list *itr;
@ -93,7 +93,7 @@ int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose)
"Failed to find module '%s'", module);
sym_kmod_list_foreach(itr, modlist) {
_cleanup_(sym_kmod_module_unrefp) struct kmod_module *mod = NULL;
_cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
int state, err;
mod = sym_kmod_module_get_module(itr);
@ -172,7 +172,7 @@ _printf_(6,0) static void systemd_kmod_log(
}
int module_setup_context(struct kmod_ctx **ret) {
_cleanup_(sym_kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
int r;
assert(ret);

View File

@ -25,9 +25,9 @@ extern DLSYM_PROTOTYPE(kmod_validate_resources);
int dlopen_libkmod(void);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_ctx*, sym_kmod_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_module*, sym_kmod_module_unref);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct kmod_list*, sym_kmod_module_unref_list, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_ctx*, sym_kmod_unref, kmod_unrefp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_module*, sym_kmod_module_unref, kmod_module_unrefp, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct kmod_list*, sym_kmod_module_unref_list, kmod_module_unref_listp, NULL);
#define sym_kmod_list_foreach(list_entry, first_entry) \
for (list_entry = first_entry; \

View File

@ -872,7 +872,6 @@ int ecc_pkey_from_curve_x_y(
#endif
*ret = TAKE_PTR(pkey);
return 0;
}

View File

@ -190,16 +190,6 @@ static inline void* EVP_PKEY_free(EVP_PKEY *p) {
return NULL;
}
static inline void* ASN1_TYPE_free(ASN1_TYPE *p) {
assert(p == NULL);
return NULL;
}
static inline void* ASN1_STRING_free(ASN1_STRING *p) {
assert(p == NULL);
return NULL;
}
static inline int string_hashsum(const char *s, size_t len, const char *md_algorithm, char **ret) {
return -EOPNOTSUPP;
}
@ -208,8 +198,6 @@ static inline int string_hashsum(const char *s, size_t len, const char *md_algor
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(X509*, X509_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY*, EVP_PKEY_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ASN1_TYPE*, ASN1_TYPE_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ASN1_STRING*, ASN1_STRING_free, NULL);
struct OpenSSLAskPasswordUI {
AskPasswordRequest request;

View File

@ -19,9 +19,11 @@ DLSYM_PROTOTYPE(passwdqc_params_free) = NULL;
DLSYM_PROTOTYPE(passwdqc_check) = NULL;
DLSYM_PROTOTYPE(passwdqc_random) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(passwdqc_params_t*, sym_passwdqc_params_free, passwdqc_params_freep, NULL);
static int pwqc_allocate_context(passwdqc_params_t **ret) {
_cleanup_(sym_passwdqc_params_freep) passwdqc_params_t *params = NULL;
_cleanup_(passwdqc_params_freep) passwdqc_params_t *params = NULL;
_cleanup_free_ char *load_reason = NULL;
int r;
@ -50,7 +52,7 @@ static int pwqc_allocate_context(passwdqc_params_t **ret) {
int suggest_passwords(void) {
_cleanup_(sym_passwdqc_params_freep) passwdqc_params_t *params = NULL;
_cleanup_(passwdqc_params_freep) passwdqc_params_t *params = NULL;
_cleanup_strv_free_erase_ char **suggestions = NULL;
_cleanup_(erase_and_freep) char *joined = NULL;
int r;
@ -86,7 +88,7 @@ int check_password_quality(
const char *username,
char **ret_error) {
_cleanup_(sym_passwdqc_params_freep) passwdqc_params_t *params = NULL;
_cleanup_(passwdqc_params_freep) passwdqc_params_t *params = NULL;
const char *check_reason;
int r;

View File

@ -6,20 +6,8 @@
#if HAVE_PASSWDQC
#include <passwdqc.h>
#include "dlfcn-util.h"
extern DLSYM_PROTOTYPE(passwdqc_params_reset);
extern DLSYM_PROTOTYPE(passwdqc_params_load);
extern DLSYM_PROTOTYPE(passwdqc_params_parse);
extern DLSYM_PROTOTYPE(passwdqc_params_free);
extern DLSYM_PROTOTYPE(passwdqc_check);
extern DLSYM_PROTOTYPE(passwdqc_random);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(passwdqc_params_t*, sym_passwdqc_params_free, NULL);
int suggest_passwords(void);
int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
#endif
int dlopen_passwdqc(void);

View File

@ -25,6 +25,8 @@ DLSYM_PROTOTYPE(pwquality_read_config) = NULL;
DLSYM_PROTOTYPE(pwquality_set_int_value) = NULL;
DLSYM_PROTOTYPE(pwquality_strerror) = NULL;
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pwquality_settings_t*, sym_pwquality_free_settings, pwquality_free_settingsp, NULL);
static void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq) {
char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
const char *path;
@ -59,7 +61,7 @@ static void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq) {
}
static int pwq_allocate_context(pwquality_settings_t **ret) {
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
_cleanup_(pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
void *auxerror;
int r;
@ -86,7 +88,7 @@ static int pwq_allocate_context(pwquality_settings_t **ret) {
}
int suggest_passwords(void) {
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
_cleanup_(pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
_cleanup_strv_free_erase_ char **suggestions = NULL;
_cleanup_(erase_and_freep) char *joined = NULL;
char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
@ -119,7 +121,7 @@ int suggest_passwords(void) {
}
int check_password_quality(const char *password, const char *old, const char *username, char **ret_error) {
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
_cleanup_(pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
void *auxerror;
int r;

View File

@ -6,22 +6,8 @@
#if HAVE_PWQUALITY
#include <pwquality.h>
#include "dlfcn-util.h"
extern DLSYM_PROTOTYPE(pwquality_check);
extern DLSYM_PROTOTYPE(pwquality_default_settings);
extern DLSYM_PROTOTYPE(pwquality_free_settings);
extern DLSYM_PROTOTYPE(pwquality_generate);
extern DLSYM_PROTOTYPE(pwquality_get_str_value);
extern DLSYM_PROTOTYPE(pwquality_read_config);
extern DLSYM_PROTOTYPE(pwquality_set_int_value);
extern DLSYM_PROTOTYPE(pwquality_strerror);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_settings, NULL);
int suggest_passwords(void);
int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
#endif
int dlopen_pwquality(void);

View File

@ -58,7 +58,7 @@ int dlopen_pcre2(void) {
int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2_code **ret) {
#if HAVE_PCRE2
PCRE2_SIZE erroroffset;
_cleanup_(sym_pcre2_code_freep) pcre2_code *p = NULL;
_cleanup_(pcre2_code_freep) pcre2_code *p = NULL;
unsigned flags = 0;
int errorcode, r;
@ -71,9 +71,9 @@ int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2
if (case_ == PATTERN_COMPILE_CASE_INSENSITIVE)
flags = PCRE2_CASELESS;
else if (case_ == PATTERN_COMPILE_CASE_AUTO) {
_cleanup_(sym_pcre2_match_data_freep) pcre2_match_data *md = NULL;
_cleanup_(pcre2_match_data_freep) pcre2_match_data *md = NULL;
bool has_case;
_cleanup_(sym_pcre2_code_freep) pcre2_code *cs = NULL;
_cleanup_(pcre2_code_freep) pcre2_code *cs = NULL;
md = sym_pcre2_match_data_create(1, NULL);
if (!md)
@ -116,7 +116,7 @@ int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2
int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, size_t size, size_t *ret_ovec) {
#if HAVE_PCRE2
_cleanup_(sym_pcre2_match_data_freep) pcre2_match_data *md = NULL;
_cleanup_(pcre2_match_data_freep) pcre2_match_data *md = NULL;
int r;
assert(compiled_pattern);
@ -156,17 +156,3 @@ int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, s
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PCRE2 support is not compiled in.");
#endif
}
void *pattern_free(pcre2_code *p) {
#if HAVE_PCRE2
if (!p)
return NULL;
assert(pcre2_dl);
sym_pcre2_code_free(p);
return NULL;
#else
assert(p == NULL);
return NULL;
#endif
}

View File

@ -18,14 +18,19 @@ extern DLSYM_PROTOTYPE(pcre2_get_error_message);
extern DLSYM_PROTOTYPE(pcre2_match);
extern DLSYM_PROTOTYPE(pcre2_get_ovector_pointer);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_match_data*, sym_pcre2_match_data_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_code*, sym_pcre2_code_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_match_data*, sym_pcre2_match_data_free, pcre2_match_data_freep, NULL);
#else
typedef struct {} pcre2_code;
typedef struct pcre2_code pcre2_code;
static inline void sym_pcre2_code_free(pcre2_code *p) {
assert(!p);
}
#endif
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_code*, sym_pcre2_code_free, pcre2_code_freep, NULL);
extern const struct hash_ops pcre2_code_hash_ops_free;
typedef enum PatternCompileCase {
@ -38,8 +43,5 @@ typedef enum PatternCompileCase {
int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2_code **ret);
int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, size_t size, size_t *ret_ovec);
void *pattern_free(pcre2_code *p);
DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_code*, pattern_free);
int dlopen_pcre2(void);

View File

@ -57,7 +57,7 @@ DLSYM_PROTOTYPE(p11_kit_uri_new) = NULL;
DLSYM_PROTOTYPE(p11_kit_uri_parse) = NULL;
int uri_from_string(const char *p, P11KitUri **ret) {
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *uri = NULL;
int r;
assert(p);
@ -273,7 +273,7 @@ int pkcs11_token_login(
char **ret_used_pin) {
_cleanup_free_ char *token_uri_string = NULL, *token_uri_escaped = NULL, *id = NULL, *token_label = NULL;
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *token_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *token_uri = NULL;
CK_TOKEN_INFO updated_token_info;
int uri_result, r;
CK_RV rv;
@ -1331,7 +1331,7 @@ static int slot_process(
pkcs11_find_token_callback_t callback,
void *userdata) {
_cleanup_(sym_p11_kit_uri_freep) P11KitUri* slot_uri = NULL, *token_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri* slot_uri = NULL, *token_uri = NULL;
_cleanup_free_ char *token_uri_string = NULL;
CK_TOKEN_INFO token_info;
CK_SLOT_INFO slot_info;
@ -1411,7 +1411,7 @@ static int module_process(
pkcs11_find_token_callback_t callback,
void *userdata) {
_cleanup_(sym_p11_kit_uri_freep) P11KitUri* module_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri* module_uri = NULL;
_cleanup_free_ char *name = NULL, *module_uri_string = NULL;
_cleanup_free_ CK_SLOT_ID *slotids = NULL;
CK_ULONG n_slotids = 0;
@ -1483,8 +1483,8 @@ int pkcs11_find_token(
pkcs11_find_token_callback_t callback,
void *userdata) {
_cleanup_(sym_p11_kit_modules_finalize_and_releasep) CK_FUNCTION_LIST **modules = NULL;
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *search_uri = NULL;
_cleanup_(p11_kit_modules_finalize_and_releasep) CK_FUNCTION_LIST **modules = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *search_uri = NULL;
int r;
r = dlopen_p11kit();
@ -1739,7 +1739,7 @@ static int list_callback(
void *userdata) {
_cleanup_free_ char *token_uri_string = NULL, *token_label = NULL, *token_manufacturer_id = NULL, *token_model = NULL;
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *token_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *token_uri = NULL;
Table *t = userdata;
int uri_result, r;
@ -1860,7 +1860,7 @@ static int auto_callback(
P11KitUri *uri,
void *userdata) {
_cleanup_(sym_p11_kit_uri_freep) P11KitUri *token_uri = NULL;
_cleanup_(p11_kit_uri_freep) P11KitUri *token_uri = NULL;
char **t = userdata;
int uri_result, r;

View File

@ -40,8 +40,8 @@ P11KitUri *uri_from_module_info(const CK_INFO *info);
P11KitUri *uri_from_slot_info(const CK_SLOT_INFO *slot_info);
P11KitUri *uri_from_token_info(const CK_TOKEN_INFO *token_info);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(P11KitUri*, sym_p11_kit_uri_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CK_FUNCTION_LIST**, sym_p11_kit_modules_finalize_and_release, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(P11KitUri*, sym_p11_kit_uri_free, p11_kit_uri_freep, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(CK_FUNCTION_LIST**, sym_p11_kit_modules_finalize_and_release, p11_kit_modules_finalize_and_releasep, NULL);
CK_RV pkcs11_get_slot_list_malloc(CK_FUNCTION_LIST *m, CK_SLOT_ID **ret_slotids, CK_ULONG *ret_n_slotids);

View File

@ -183,7 +183,7 @@ static void write_qrcode(FILE *output, QRcode *qr, unsigned row, unsigned column
fflush(output);
}
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(QRcode*, sym_QRcode_free, NULL);
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(QRcode*, sym_QRcode_free, QRcode_freep, NULL);
#endif
@ -211,8 +211,7 @@ int print_qrcode_full(
if (r < 0)
return r;
_cleanup_(sym_QRcode_freep) QRcode *qr =
sym_QRcode_encodeString(string, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
_cleanup_(QRcode_freep) QRcode *qr = sym_QRcode_encodeString(string, 0, QR_ECLEVEL_L, QR_MODE_8, 1);
if (!qr)
return log_oom_debug();

View File

@ -392,7 +392,7 @@ int tar_x(int input_fd, int tree_fd, TarFlags flags) {
assert(input_fd >= 0);
assert(tree_fd >= 0);
_cleanup_(sym_archive_read_freep) struct archive *a = NULL;
_cleanup_(archive_read_freep) struct archive *a = NULL;
a = sym_archive_read_new();
if (!a)
return log_oom();

View File

@ -36,32 +36,32 @@ static int run(int argc, char **argv) {
* where .so versions change and distributions update, but systemd doesn't have the new so names
* around yet. */
ASSERT_DLOPEN(dlopen_idn, HAVE_LIBIDN2 || HAVE_LIBIDN);
ASSERT_DLOPEN(dlopen_bpf, HAVE_LIBBPF);
ASSERT_DLOPEN(dlopen_cryptsetup, HAVE_LIBCRYPTSETUP);
ASSERT_DLOPEN(dlopen_dw, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_elf, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_gcrypt, HAVE_GCRYPT);
ASSERT_DLOPEN(dlopen_idn, HAVE_LIBIDN2 || HAVE_LIBIDN);
ASSERT_DLOPEN(dlopen_libacl, HAVE_ACL);
ASSERT_DLOPEN(dlopen_libapparmor, HAVE_APPARMOR);
ASSERT_DLOPEN(dlopen_libarchive, HAVE_LIBARCHIVE);
ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
ASSERT_DLOPEN(dlopen_libblkid, HAVE_BLKID);
ASSERT_DLOPEN(dlopen_libfido2, HAVE_LIBFIDO2);
ASSERT_DLOPEN(dlopen_libkmod, HAVE_KMOD);
ASSERT_DLOPEN(dlopen_libmount, true);
ASSERT_DLOPEN(dlopen_libpam, HAVE_PAM);
ASSERT_DLOPEN(dlopen_libseccomp, HAVE_SECCOMP);
ASSERT_DLOPEN(dlopen_libselinux, HAVE_SELINUX);
ASSERT_DLOPEN(dlopen_lz4, HAVE_LZ4);
ASSERT_DLOPEN(dlopen_lzma, HAVE_XZ);
ASSERT_DLOPEN(dlopen_p11kit, HAVE_P11KIT);
ASSERT_DLOPEN(dlopen_passwdqc, HAVE_PASSWDQC);
ASSERT_DLOPEN(dlopen_pcre2, HAVE_PCRE2);
ASSERT_DLOPEN(dlopen_pwquality, HAVE_PWQUALITY);
ASSERT_DLOPEN(dlopen_qrencode, HAVE_QRENCODE);
ASSERT_DLOPEN(dlopen_tpm2, HAVE_TPM2);
ASSERT_DLOPEN(dlopen_libfido2, HAVE_LIBFIDO2);
ASSERT_DLOPEN(dlopen_bpf, HAVE_LIBBPF);
ASSERT_DLOPEN(dlopen_dw, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_elf, HAVE_ELFUTILS);
ASSERT_DLOPEN(dlopen_pcre2, HAVE_PCRE2);
ASSERT_DLOPEN(dlopen_p11kit, HAVE_P11KIT);
ASSERT_DLOPEN(dlopen_libarchive, HAVE_LIBARCHIVE);
ASSERT_DLOPEN(dlopen_lz4, HAVE_LZ4);
ASSERT_DLOPEN(dlopen_zstd, HAVE_ZSTD);
ASSERT_DLOPEN(dlopen_lzma, HAVE_XZ);
ASSERT_DLOPEN(dlopen_gcrypt, HAVE_GCRYPT);
ASSERT_DLOPEN(dlopen_libkmod, HAVE_KMOD);
ASSERT_DLOPEN(dlopen_libapparmor, HAVE_APPARMOR);
ASSERT_DLOPEN(dlopen_libaudit, HAVE_AUDIT);
ASSERT_DLOPEN(dlopen_libpam, HAVE_PAM);
ASSERT_DLOPEN(dlopen_libacl, HAVE_ACL);
ASSERT_DLOPEN(dlopen_libblkid, HAVE_BLKID);
ASSERT_DLOPEN(dlopen_libseccomp, HAVE_SECCOMP);
ASSERT_DLOPEN(dlopen_libmount, true);
ASSERT_DLOPEN(dlopen_libselinux, HAVE_SELINUX);
return 0;
}

View File

@ -10,8 +10,8 @@
#include "tests.h"
static int load_module(const char *mod_name) {
_cleanup_(sym_kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(sym_kmod_module_unref_listp) struct kmod_list *list = NULL;
_cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
_cleanup_(kmod_module_unref_listp) struct kmod_list *list = NULL;
struct kmod_list *l;
int r;
@ -28,7 +28,7 @@ static int load_module(const char *mod_name) {
return r;
sym_kmod_list_foreach(l, list) {
_cleanup_(sym_kmod_module_unrefp) struct kmod_module *mod = NULL;
_cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
mod = sym_kmod_module_get_module(l);