From 9dbabd0a8b4dda28fd2c6dae0f75e763f26e8e05 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 1 Mar 2024 10:12:48 +0100 Subject: [PATCH] tree-wide: switch dlopen hooks over to DLSYM_PROTOTYPE()/DLSYM_FUNCTION() We have these pretty macros, let's use them everywhere (so far we mostly used them for newer additions only). This PR is mostly an excercise in "perl -p -i -e", but there are some special cases: * idn-util.c exposes a function whose prototype in the official library headers is marked with the "const" attribute, and this apparently does not propagate along typeof() correctly and then __builtin_types_compatible_p() fails later because it detects that prototype and original function don't match in prototype. * libbpf removed some symbols in newer versions, hence we need to define some prototypes manually to still be able to build. * libcryptsetup marked a symbol as deprecated we want to use (knowing it is deprecated). By using the macros this is detected by the compiler. We work around it via the usual warning off macros. Note by using these macros we assume that all symbols are known during build time. Which might not be the case. We might need to revert this commit for some symbols if this trips up builds on older distros. --- src/locale/xkbcommon-util.c | 19 +-- src/locale/xkbcommon-util.h | 21 ++-- src/shared/bpf-dlopen.c | 38 +++--- src/shared/bpf-dlopen.h | 37 +++--- src/shared/cryptsetup-util.c | 82 +++++++------ src/shared/cryptsetup-util.h | 83 +++++++------ src/shared/elf-util.c | 82 ++++++------- src/shared/idn-util.c | 12 +- src/shared/idn-util.h | 14 ++- src/shared/libfido2-util.c | 94 +++++++------- src/shared/libfido2-util.h | 96 ++++++++------- src/shared/password-quality-util-passwdqc.c | 12 +- src/shared/password-quality-util-passwdqc.h | 12 +- src/shared/password-quality-util-pwquality.c | 16 +-- src/shared/password-quality-util-pwquality.h | 18 +-- src/shared/pcre2-util.c | 14 +-- src/shared/pcre2-util.h | 16 +-- src/shared/pkcs11-util.c | 32 ++--- src/shared/pkcs11-util.h | 34 +++--- src/shared/qrcode-util.c | 4 +- src/shared/tpm2-util.c | 122 +++++++++---------- 21 files changed, 429 insertions(+), 429 deletions(-) diff --git a/src/locale/xkbcommon-util.c b/src/locale/xkbcommon-util.c index 295ac8af8db..468452f8afd 100644 --- a/src/locale/xkbcommon-util.c +++ b/src/locale/xkbcommon-util.c @@ -9,20 +9,11 @@ #if HAVE_XKBCOMMON static void *xkbcommon_dl = NULL; -struct xkb_context* (*sym_xkb_context_new)(enum xkb_context_flags flags); -void (*sym_xkb_context_unref)(struct xkb_context *context); -void (*sym_xkb_context_set_log_fn)( - struct xkb_context *context, - void (*log_fn)( - struct xkb_context *context, - enum xkb_log_level level, - const char *format, - va_list args)); -struct xkb_keymap* (*sym_xkb_keymap_new_from_names)( - struct xkb_context *context, - const struct xkb_rule_names *names, - enum xkb_keymap_compile_flags flags); -void (*sym_xkb_keymap_unref)(struct xkb_keymap *keymap); +DLSYM_FUNCTION(xkb_context_new); +DLSYM_FUNCTION(xkb_context_unref); +DLSYM_FUNCTION(xkb_context_set_log_fn); +DLSYM_FUNCTION(xkb_keymap_new_from_names); +DLSYM_FUNCTION(xkb_keymap_unref); static int dlopen_xkbcommon(void) { return dlopen_many_sym_or_warn( diff --git a/src/locale/xkbcommon-util.h b/src/locale/xkbcommon-util.h index e99c2d7783d..92f45c2bcb0 100644 --- a/src/locale/xkbcommon-util.h +++ b/src/locale/xkbcommon-util.h @@ -1,23 +1,16 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #pragma once +#include "dlfcn-util.h" + #if HAVE_XKBCOMMON #include -extern struct xkb_context* (*sym_xkb_context_new)(enum xkb_context_flags flags); -extern void (*sym_xkb_context_unref)(struct xkb_context *context); -extern void (*sym_xkb_context_set_log_fn)( - struct xkb_context *context, - void (*log_fn)( - struct xkb_context *context, - enum xkb_log_level level, - const char *format, - va_list args)); -extern struct xkb_keymap* (*sym_xkb_keymap_new_from_names)( - struct xkb_context *context, - const struct xkb_rule_names *names, - enum xkb_keymap_compile_flags flags); -extern void (*sym_xkb_keymap_unref)(struct xkb_keymap *keymap); +DLSYM_PROTOTYPE(xkb_context_new); +DLSYM_PROTOTYPE(xkb_context_unref); +DLSYM_PROTOTYPE(xkb_context_set_log_fn); +DLSYM_PROTOTYPE(xkb_keymap_new_from_names); +DLSYM_PROTOTYPE(xkb_keymap_unref); int verify_xkb_rmlvo(const char *model, const char *layout, const char *variant, const char *options); diff --git a/src/shared/bpf-dlopen.c b/src/shared/bpf-dlopen.c index 15301aee600..70b1ffbf99d 100644 --- a/src/shared/bpf-dlopen.c +++ b/src/shared/bpf-dlopen.c @@ -18,26 +18,28 @@ #define MODERN_LIBBPF 0 #endif -struct bpf_link* (*sym_bpf_program__attach_cgroup)(const struct bpf_program *, int); -struct bpf_link* (*sym_bpf_program__attach_lsm)(const struct bpf_program *); -int (*sym_bpf_link__fd)(const struct bpf_link *); -int (*sym_bpf_link__destroy)(struct bpf_link *); -int (*sym_bpf_map__fd)(const struct bpf_map *); -const char* (*sym_bpf_map__name)(const struct bpf_map *); +DLSYM_FUNCTION(bpf_program__attach_cgroup); +DLSYM_FUNCTION(bpf_program__attach_lsm); +DLSYM_FUNCTION(bpf_link__fd); +DLSYM_FUNCTION(bpf_link__destroy); +DLSYM_FUNCTION(bpf_map__fd); +DLSYM_FUNCTION(bpf_map__name); +DLSYM_FUNCTION(bpf_map__set_max_entries); +DLSYM_FUNCTION(bpf_map_update_elem); +DLSYM_FUNCTION(bpf_map_delete_elem); +DLSYM_FUNCTION(bpf_map__set_inner_map_fd); +DLSYM_FUNCTION(bpf_object__open_skeleton); +DLSYM_FUNCTION(bpf_object__load_skeleton); +DLSYM_FUNCTION(bpf_object__attach_skeleton); +DLSYM_FUNCTION(bpf_object__detach_skeleton); +DLSYM_FUNCTION(bpf_object__destroy_skeleton); +DLSYM_FUNCTION(bpf_program__name); +DLSYM_FUNCTION(libbpf_set_print); +DLSYM_FUNCTION(libbpf_get_error); + +/* new symbols available from libbpf 0.7.0 */ int (*sym_bpf_map_create)(enum bpf_map_type, const char *, __u32, __u32, __u32, const struct bpf_map_create_opts *); -int (*sym_bpf_map__set_max_entries)(struct bpf_map *, __u32); -int (*sym_bpf_map_update_elem)(int, const void *, const void *, __u64); -int (*sym_bpf_map_delete_elem)(int, const void *); -int (*sym_bpf_map__set_inner_map_fd)(struct bpf_map *, int); -int (*sym_bpf_object__open_skeleton)(struct bpf_object_skeleton *, const struct bpf_object_open_opts *); -int (*sym_bpf_object__load_skeleton)(struct bpf_object_skeleton *); -int (*sym_bpf_object__attach_skeleton)(struct bpf_object_skeleton *); -void (*sym_bpf_object__detach_skeleton)(struct bpf_object_skeleton *); -void (*sym_bpf_object__destroy_skeleton)(struct bpf_object_skeleton *); int (*sym_libbpf_probe_bpf_prog_type)(enum bpf_prog_type, const void *); -const char* (*sym_bpf_program__name)(const struct bpf_program *); -libbpf_print_fn_t (*sym_libbpf_set_print)(libbpf_print_fn_t); -long (*sym_libbpf_get_error)(const void *); /* compat symbols removed in libbpf 1.0 */ int (*sym_bpf_create_map)(enum bpf_map_type, int key_size, int value_size, int max_entries, __u32 map_flags); diff --git a/src/shared/bpf-dlopen.h b/src/shared/bpf-dlopen.h index 0750abc56b9..859405e3c69 100644 --- a/src/shared/bpf-dlopen.h +++ b/src/shared/bpf-dlopen.h @@ -7,27 +7,28 @@ #include #include "bpf-compat.h" +#include "dlfcn-util.h" -extern struct bpf_link* (*sym_bpf_program__attach_cgroup)(const struct bpf_program *, int); -extern struct bpf_link* (*sym_bpf_program__attach_lsm)(const struct bpf_program *); -extern int (*sym_bpf_link__fd)(const struct bpf_link *); -extern int (*sym_bpf_link__destroy)(struct bpf_link *); -extern int (*sym_bpf_map__fd)(const struct bpf_map *); -extern const char* (*sym_bpf_map__name)(const struct bpf_map *); -extern int (*sym_bpf_map__set_max_entries)(struct bpf_map *, __u32); -extern int (*sym_bpf_map_update_elem)(int, const void *, const void *, __u64); -extern int (*sym_bpf_map_delete_elem)(int, const void *); -extern int (*sym_bpf_map__set_inner_map_fd)(struct bpf_map *, int); +DLSYM_PROTOTYPE(bpf_program__attach_cgroup); +DLSYM_PROTOTYPE(bpf_program__attach_lsm); +DLSYM_PROTOTYPE(bpf_link__fd); +DLSYM_PROTOTYPE(bpf_link__destroy); +DLSYM_PROTOTYPE(bpf_map__fd); +DLSYM_PROTOTYPE(bpf_map__name); +DLSYM_PROTOTYPE(bpf_map__set_max_entries); +DLSYM_PROTOTYPE(bpf_map_update_elem); +DLSYM_PROTOTYPE(bpf_map_delete_elem); +DLSYM_PROTOTYPE(bpf_map__set_inner_map_fd); /* The *_skeleton APIs are autogenerated by bpftool, the targets can be found * in ./build/src/core/bpf/socket_bind/socket-bind.skel.h */ -extern int (*sym_bpf_object__open_skeleton)(struct bpf_object_skeleton *, const struct bpf_object_open_opts *); -extern int (*sym_bpf_object__load_skeleton)(struct bpf_object_skeleton *); -extern int (*sym_bpf_object__attach_skeleton)(struct bpf_object_skeleton *); -extern void (*sym_bpf_object__detach_skeleton)(struct bpf_object_skeleton *); -extern void (*sym_bpf_object__destroy_skeleton)(struct bpf_object_skeleton *); -extern const char* (*sym_bpf_program__name)(const struct bpf_program *); -extern libbpf_print_fn_t (*sym_libbpf_set_print)(libbpf_print_fn_t); -extern long (*sym_libbpf_get_error)(const void *); +DLSYM_PROTOTYPE(bpf_object__open_skeleton); +DLSYM_PROTOTYPE(bpf_object__load_skeleton); +DLSYM_PROTOTYPE(bpf_object__attach_skeleton); +DLSYM_PROTOTYPE(bpf_object__detach_skeleton); +DLSYM_PROTOTYPE(bpf_object__destroy_skeleton); +DLSYM_PROTOTYPE(bpf_program__name); +DLSYM_PROTOTYPE(libbpf_set_print); +DLSYM_PROTOTYPE(libbpf_get_error); #endif diff --git a/src/shared/cryptsetup-util.c b/src/shared/cryptsetup-util.c index ab5764dc105..77ac85965f8 100644 --- a/src/shared/cryptsetup-util.c +++ b/src/shared/cryptsetup-util.c @@ -9,58 +9,60 @@ #if HAVE_LIBCRYPTSETUP static void *cryptsetup_dl = NULL; -int (*sym_crypt_activate_by_passphrase)(struct crypt_device *cd, const char *name, int keyslot, const char *passphrase, size_t passphrase_size, uint32_t flags); +DLSYM_FUNCTION(crypt_activate_by_passphrase); #if HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY -int (*sym_crypt_activate_by_signed_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, const char *signature, size_t signature_size, uint32_t flags); +DLSYM_FUNCTION(crypt_activate_by_signed_key); #endif -int (*sym_crypt_activate_by_volume_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, uint32_t flags); -int (*sym_crypt_deactivate_by_name)(struct crypt_device *cd, const char *name, uint32_t flags); -int (*sym_crypt_format)(struct crypt_device *cd, const char *type, const char *cipher, const char *cipher_mode, const char *uuid, const char *volume_key, size_t volume_key_size, void *params); -void (*sym_crypt_free)(struct crypt_device *cd); -const char *(*sym_crypt_get_cipher)(struct crypt_device *cd); -const char *(*sym_crypt_get_cipher_mode)(struct crypt_device *cd); -uint64_t (*sym_crypt_get_data_offset)(struct crypt_device *cd); -const char *(*sym_crypt_get_device_name)(struct crypt_device *cd); -const char *(*sym_crypt_get_dir)(void); -const char *(*sym_crypt_get_type)(struct crypt_device *cd); -const char *(*sym_crypt_get_uuid)(struct crypt_device *cd); -int (*sym_crypt_get_verity_info)(struct crypt_device *cd, struct crypt_params_verity *vp); -int (*sym_crypt_get_volume_key_size)(struct crypt_device *cd); -int (*sym_crypt_init)(struct crypt_device **cd, const char *device); -int (*sym_crypt_init_by_name)(struct crypt_device **cd, const char *name); -int (*sym_crypt_keyslot_add_by_volume_key)(struct crypt_device *cd, int keyslot, const char *volume_key, size_t volume_key_size, const char *passphrase, size_t passphrase_size); -int (*sym_crypt_keyslot_destroy)(struct crypt_device *cd, int keyslot); -int (*sym_crypt_keyslot_max)(const char *type); -int (*sym_crypt_load)(struct crypt_device *cd, const char *requested_type, void *params); -int (*sym_crypt_resize)(struct crypt_device *cd, const char *name, uint64_t new_size); -int (*sym_crypt_resume_by_passphrase)(struct crypt_device *cd, const char *name, int keyslot, const char *passphrase, size_t passphrase_size); -int (*sym_crypt_set_data_device)(struct crypt_device *cd, const char *device); -void (*sym_crypt_set_debug_level)(int level); -void (*sym_crypt_set_log_callback)(struct crypt_device *cd, void (*log)(int level, const char *msg, void *usrptr), void *usrptr); +DLSYM_FUNCTION(crypt_activate_by_volume_key); +DLSYM_FUNCTION(crypt_deactivate_by_name); +DLSYM_FUNCTION(crypt_format); +DLSYM_FUNCTION(crypt_free); +DLSYM_FUNCTION(crypt_get_cipher); +DLSYM_FUNCTION(crypt_get_cipher_mode); +DLSYM_FUNCTION(crypt_get_data_offset); +DLSYM_FUNCTION(crypt_get_device_name); +DLSYM_FUNCTION(crypt_get_dir); +DLSYM_FUNCTION(crypt_get_type); +DLSYM_FUNCTION(crypt_get_uuid); +DLSYM_FUNCTION(crypt_get_verity_info); +DLSYM_FUNCTION(crypt_get_volume_key_size); +DLSYM_FUNCTION(crypt_init); +DLSYM_FUNCTION(crypt_init_by_name); +DLSYM_FUNCTION(crypt_keyslot_add_by_volume_key); +DLSYM_FUNCTION(crypt_keyslot_destroy); +DLSYM_FUNCTION(crypt_keyslot_max); +DLSYM_FUNCTION(crypt_load); +DLSYM_FUNCTION(crypt_resize); +DLSYM_FUNCTION(crypt_resume_by_passphrase); +DLSYM_FUNCTION(crypt_set_data_device); +DLSYM_FUNCTION(crypt_set_debug_level); +DLSYM_FUNCTION(crypt_set_log_callback); #if HAVE_CRYPT_SET_METADATA_SIZE -int (*sym_crypt_set_metadata_size)(struct crypt_device *cd, uint64_t metadata_size, uint64_t keyslots_size); +DLSYM_FUNCTION(crypt_set_metadata_size); #endif -int (*sym_crypt_set_pbkdf_type)(struct crypt_device *cd, const struct crypt_pbkdf_type *pbkdf); -int (*sym_crypt_suspend)(struct crypt_device *cd, const char *name); -int (*sym_crypt_token_json_get)(struct crypt_device *cd, int token, const char **json); -int (*sym_crypt_token_json_set)(struct crypt_device *cd, int token, const char *json); +DLSYM_FUNCTION(crypt_set_pbkdf_type); +DLSYM_FUNCTION(crypt_suspend); +DLSYM_FUNCTION(crypt_token_json_get); +DLSYM_FUNCTION(crypt_token_json_set); #if HAVE_CRYPT_TOKEN_MAX -int (*sym_crypt_token_max)(const char *type); +DLSYM_FUNCTION(crypt_token_max); #endif -crypt_token_info (*sym_crypt_token_status)(struct crypt_device *cd, int token, const char **type); -int (*sym_crypt_volume_key_get)(struct crypt_device *cd, int keyslot, char *volume_key, size_t *volume_key_size, const char *passphrase, size_t passphrase_size); +DLSYM_FUNCTION(crypt_token_status); +DLSYM_FUNCTION(crypt_volume_key_get); #if HAVE_CRYPT_REENCRYPT_INIT_BY_PASSPHRASE -int (*sym_crypt_reencrypt_init_by_passphrase)(struct crypt_device *cd, const char *name, const char *passphrase, size_t passphrase_size, int keyslot_old, int keyslot_new, const char *cipher, const char *cipher_mode, const struct crypt_params_reencrypt *params); +DLSYM_FUNCTION(crypt_reencrypt_init_by_passphrase); #endif #if HAVE_CRYPT_REENCRYPT -int (*sym_crypt_reencrypt)(struct crypt_device *cd, int (*progress)(uint64_t size, uint64_t offset, void *usrptr)); +DISABLE_WARNING_DEPRECATED_DECLARATIONS; +DLSYM_FUNCTION(crypt_reencrypt); +REENABLE_WARNING; #endif -int (*sym_crypt_metadata_locking)(struct crypt_device *cd, int enable); +DLSYM_FUNCTION(crypt_metadata_locking); #if HAVE_CRYPT_SET_DATA_OFFSET -int (*sym_crypt_set_data_offset)(struct crypt_device *cd, uint64_t data_offset); +DLSYM_FUNCTION(crypt_set_data_offset); #endif -int (*sym_crypt_header_restore)(struct crypt_device *cd, const char *requested_type, const char *backup_file); -int (*sym_crypt_volume_key_keyring)(struct crypt_device *cd, int enable); +DLSYM_FUNCTION(crypt_header_restore); +DLSYM_FUNCTION(crypt_volume_key_keyring); /* Unfortunately libcryptsetup provides neither an environment variable to redirect where to look for token * modules, nor does it have an API to change the token lookup path at runtime. The maintainers suggest using diff --git a/src/shared/cryptsetup-util.h b/src/shared/cryptsetup-util.h index 5ff439d9c29..8a4416b4fcb 100644 --- a/src/shared/cryptsetup-util.h +++ b/src/shared/cryptsetup-util.h @@ -2,6 +2,7 @@ #pragma once #include "alloc-util.h" +#include "dlfcn-util.h" #include "json.h" #include "macro.h" @@ -16,43 +17,43 @@ #define CRYPT_ACTIVATE_NO_WRITE_WORKQUEUE (1 << 25) #endif -extern int (*sym_crypt_activate_by_passphrase)(struct crypt_device *cd, const char *name, int keyslot, const char *passphrase, size_t passphrase_size, uint32_t flags); +DLSYM_PROTOTYPE(crypt_activate_by_passphrase); #if HAVE_CRYPT_ACTIVATE_BY_SIGNED_KEY -extern int (*sym_crypt_activate_by_signed_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, const char *signature, size_t signature_size, uint32_t flags); +DLSYM_PROTOTYPE(crypt_activate_by_signed_key); #endif -extern int (*sym_crypt_activate_by_volume_key)(struct crypt_device *cd, const char *name, const char *volume_key, size_t volume_key_size, uint32_t flags); -extern int (*sym_crypt_deactivate_by_name)(struct crypt_device *cd, const char *name, uint32_t flags); -extern int (*sym_crypt_format)(struct crypt_device *cd, const char *type, const char *cipher, const char *cipher_mode, const char *uuid, const char *volume_key, size_t volume_key_size, void *params); -extern void (*sym_crypt_free)(struct crypt_device *cd); -extern const char *(*sym_crypt_get_cipher)(struct crypt_device *cd); -extern const char *(*sym_crypt_get_cipher_mode)(struct crypt_device *cd); -extern uint64_t (*sym_crypt_get_data_offset)(struct crypt_device *cd); -extern const char *(*sym_crypt_get_device_name)(struct crypt_device *cd); -extern const char *(*sym_crypt_get_dir)(void); -extern const char *(*sym_crypt_get_type)(struct crypt_device *cd); -extern const char *(*sym_crypt_get_uuid)(struct crypt_device *cd); -extern int (*sym_crypt_get_verity_info)(struct crypt_device *cd, struct crypt_params_verity *vp); -extern int (*sym_crypt_get_volume_key_size)(struct crypt_device *cd); -extern int (*sym_crypt_init)(struct crypt_device **cd, const char *device); -extern int (*sym_crypt_init_by_name)(struct crypt_device **cd, const char *name); -extern int (*sym_crypt_keyslot_add_by_volume_key)(struct crypt_device *cd, int keyslot, const char *volume_key, size_t volume_key_size, const char *passphrase, size_t passphrase_size); -extern int (*sym_crypt_keyslot_destroy)(struct crypt_device *cd, int keyslot); -extern int (*sym_crypt_keyslot_max)(const char *type); -extern int (*sym_crypt_load)(struct crypt_device *cd, const char *requested_type, void *params); -extern int (*sym_crypt_resize)(struct crypt_device *cd, const char *name, uint64_t new_size); -extern int (*sym_crypt_resume_by_passphrase)(struct crypt_device *cd, const char *name, int keyslot, const char *passphrase, size_t passphrase_size); -extern int (*sym_crypt_set_data_device)(struct crypt_device *cd, const char *device); -extern void (*sym_crypt_set_debug_level)(int level); -extern void (*sym_crypt_set_log_callback)(struct crypt_device *cd, void (*log)(int level, const char *msg, void *usrptr), void *usrptr); +DLSYM_PROTOTYPE(crypt_activate_by_volume_key); +DLSYM_PROTOTYPE(crypt_deactivate_by_name); +DLSYM_PROTOTYPE(crypt_format); +DLSYM_PROTOTYPE(crypt_free); +DLSYM_PROTOTYPE(crypt_get_cipher); +DLSYM_PROTOTYPE(crypt_get_cipher_mode); +DLSYM_PROTOTYPE(crypt_get_data_offset); +DLSYM_PROTOTYPE(crypt_get_device_name); +DLSYM_PROTOTYPE(crypt_get_dir); +DLSYM_PROTOTYPE(crypt_get_type); +DLSYM_PROTOTYPE(crypt_get_uuid); +DLSYM_PROTOTYPE(crypt_get_verity_info); +DLSYM_PROTOTYPE(crypt_get_volume_key_size); +DLSYM_PROTOTYPE(crypt_init); +DLSYM_PROTOTYPE(crypt_init_by_name); +DLSYM_PROTOTYPE(crypt_keyslot_add_by_volume_key); +DLSYM_PROTOTYPE(crypt_keyslot_destroy); +DLSYM_PROTOTYPE(crypt_keyslot_max); +DLSYM_PROTOTYPE(crypt_load); +DLSYM_PROTOTYPE(crypt_resize); +DLSYM_PROTOTYPE(crypt_resume_by_passphrase); +DLSYM_PROTOTYPE(crypt_set_data_device); +DLSYM_PROTOTYPE(crypt_set_debug_level); +DLSYM_PROTOTYPE(crypt_set_log_callback); #if HAVE_CRYPT_SET_METADATA_SIZE -extern int (*sym_crypt_set_metadata_size)(struct crypt_device *cd, uint64_t metadata_size, uint64_t keyslots_size); +DLSYM_PROTOTYPE(crypt_set_metadata_size); #endif -extern int (*sym_crypt_set_pbkdf_type)(struct crypt_device *cd, const struct crypt_pbkdf_type *pbkdf); -extern int (*sym_crypt_suspend)(struct crypt_device *cd, const char *name); -extern int (*sym_crypt_token_json_get)(struct crypt_device *cd, int token, const char **json); -extern int (*sym_crypt_token_json_set)(struct crypt_device *cd, int token, const char *json); +DLSYM_PROTOTYPE(crypt_set_pbkdf_type); +DLSYM_PROTOTYPE(crypt_suspend); +DLSYM_PROTOTYPE(crypt_token_json_get); +DLSYM_PROTOTYPE(crypt_token_json_set); #if HAVE_CRYPT_TOKEN_MAX -extern int (*sym_crypt_token_max)(const char *type); +DLSYM_PROTOTYPE(crypt_token_max); #else /* As a fallback, use the same hard-coded value libcryptsetup uses internally. */ static inline int crypt_token_max(_unused_ const char *type) { @@ -62,20 +63,22 @@ static inline int crypt_token_max(_unused_ const char *type) { } #define sym_crypt_token_max(type) crypt_token_max(type) #endif -extern crypt_token_info (*sym_crypt_token_status)(struct crypt_device *cd, int token, const char **type); -extern int (*sym_crypt_volume_key_get)(struct crypt_device *cd, int keyslot, char *volume_key, size_t *volume_key_size, const char *passphrase, size_t passphrase_size); +DLSYM_PROTOTYPE(crypt_token_status); +DLSYM_PROTOTYPE(crypt_volume_key_get); #if HAVE_CRYPT_REENCRYPT_INIT_BY_PASSPHRASE -extern int (*sym_crypt_reencrypt_init_by_passphrase)(struct crypt_device *cd, const char *name, const char *passphrase, size_t passphrase_size, int keyslot_old, int keyslot_new, const char *cipher, const char *cipher_mode, const struct crypt_params_reencrypt *params); +DLSYM_PROTOTYPE(crypt_reencrypt_init_by_passphrase); #endif #if HAVE_CRYPT_REENCRYPT -extern int (*sym_crypt_reencrypt)(struct crypt_device *cd, int (*progress)(uint64_t size, uint64_t offset, void *usrptr)); +DISABLE_WARNING_DEPRECATED_DECLARATIONS; +DLSYM_PROTOTYPE(crypt_reencrypt); +REENABLE_WARNING; #endif -extern int (*sym_crypt_metadata_locking)(struct crypt_device *cd, int enable); +DLSYM_PROTOTYPE(crypt_metadata_locking); #if HAVE_CRYPT_SET_DATA_OFFSET -extern int (*sym_crypt_set_data_offset)(struct crypt_device *cd, uint64_t data_offset); +DLSYM_PROTOTYPE(crypt_set_data_offset); #endif -extern int (*sym_crypt_header_restore)(struct crypt_device *cd, const char *requested_type, const char *backup_file); -extern int (*sym_crypt_volume_key_keyring)(struct crypt_device *cd, int enable); +DLSYM_PROTOTYPE(crypt_header_restore); +DLSYM_PROTOTYPE(crypt_volume_key_keyring); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, crypt_free, NULL); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, sym_crypt_free, NULL); diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c index 9f8a0f962af..85f3c173db1 100644 --- a/src/shared/elf-util.c +++ b/src/shared/elf-util.c @@ -38,51 +38,51 @@ static void *dw_dl = NULL; static void *elf_dl = NULL; /* libdw symbols */ -Dwarf_Attribute *(*sym_dwarf_attr_integrate)(Dwarf_Die *, unsigned int, Dwarf_Attribute *); -const char *(*sym_dwarf_diename)(Dwarf_Die *); -const char *(*sym_dwarf_formstring)(Dwarf_Attribute *); -int (*sym_dwarf_getscopes)(Dwarf_Die *, Dwarf_Addr, Dwarf_Die **); -int (*sym_dwarf_getscopes_die)(Dwarf_Die *, Dwarf_Die **); -Elf *(*sym_dwelf_elf_begin)(int); +static DLSYM_FUNCTION(dwarf_attr_integrate); +static DLSYM_FUNCTION(dwarf_diename); +static DLSYM_FUNCTION(dwarf_formstring); +static DLSYM_FUNCTION(dwarf_getscopes); +static DLSYM_FUNCTION(dwarf_getscopes_die); +static DLSYM_FUNCTION(dwelf_elf_begin); #if HAVE_DWELF_ELF_E_MACHINE_STRING -const char *(*sym_dwelf_elf_e_machine_string)(int); +static DLSYM_FUNCTION(dwelf_elf_e_machine_string); #endif -ssize_t (*sym_dwelf_elf_gnu_build_id)(Elf *, const void **); -int (*sym_dwarf_tag)(Dwarf_Die *); -Dwfl_Module *(*sym_dwfl_addrmodule)(Dwfl *, Dwarf_Addr); -Dwfl *(*sym_dwfl_begin)(const Dwfl_Callbacks *); -int (*sym_dwfl_build_id_find_elf)(Dwfl_Module *, void **, const char *, Dwarf_Addr, char **, Elf **); -int (*sym_dwfl_core_file_attach)(Dwfl *, Elf *); -int (*sym_dwfl_core_file_report)(Dwfl *, Elf *, const char *); -void (*sym_dwfl_end)(Dwfl *); -const char *(*sym_dwfl_errmsg)(int); -int (*sym_dwfl_errno)(void); -bool (*sym_dwfl_frame_pc)(Dwfl_Frame *, Dwarf_Addr *, bool *); -ptrdiff_t (*sym_dwfl_getmodules)(Dwfl *, int (*)(Dwfl_Module *, void **, const char *, Dwarf_Addr, void *), void *, ptrdiff_t); -int (*sym_dwfl_getthreads)(Dwfl *, int (*)(Dwfl_Thread *, void *), void *); -Dwarf_Die *(*sym_dwfl_module_addrdie)(Dwfl_Module *, Dwarf_Addr, Dwarf_Addr *); -const char *(*sym_dwfl_module_addrname)(Dwfl_Module *, GElf_Addr); -int (*sym_dwfl_module_build_id)(Dwfl_Module *, const unsigned char **, GElf_Addr *); -Elf *(*sym_dwfl_module_getelf)(Dwfl_Module *, GElf_Addr *); -const char *(*sym_dwfl_module_info)(Dwfl_Module *, void ***, Dwarf_Addr *, Dwarf_Addr *, Dwarf_Addr *, Dwarf_Addr *, const char **, const char **); -int (*sym_dwfl_offline_section_address)(Dwfl_Module *, void **, const char *, Dwarf_Addr, const char *, GElf_Word, const GElf_Shdr *, Dwarf_Addr *); -int (*sym_dwfl_report_end)(Dwfl *, int (*)(Dwfl_Module *, void *, const char *, Dwarf_Addr, void *), void *); -int (*sym_dwfl_standard_find_debuginfo)(Dwfl_Module *, void **, const char *, Dwarf_Addr, const char *, const char *, GElf_Word, char **); -int (*sym_dwfl_thread_getframes)(Dwfl_Thread *, int (*)(Dwfl_Frame *, void *), void *); -pid_t (*sym_dwfl_thread_tid)(Dwfl_Thread *); +static DLSYM_FUNCTION(dwelf_elf_gnu_build_id); +static DLSYM_FUNCTION(dwarf_tag); +static DLSYM_FUNCTION(dwfl_addrmodule); +static DLSYM_FUNCTION(dwfl_begin); +static DLSYM_FUNCTION(dwfl_build_id_find_elf); +static DLSYM_FUNCTION(dwfl_core_file_attach); +static DLSYM_FUNCTION(dwfl_core_file_report); +static DLSYM_FUNCTION(dwfl_end); +static DLSYM_FUNCTION(dwfl_errmsg); +static DLSYM_FUNCTION(dwfl_errno); +static DLSYM_FUNCTION(dwfl_frame_pc); +static DLSYM_FUNCTION(dwfl_getmodules); +static DLSYM_FUNCTION(dwfl_getthreads); +static DLSYM_FUNCTION(dwfl_module_addrdie); +static DLSYM_FUNCTION(dwfl_module_addrname); +static DLSYM_FUNCTION(dwfl_module_build_id); +static DLSYM_FUNCTION(dwfl_module_getelf); +static DLSYM_FUNCTION(dwfl_module_info); +static DLSYM_FUNCTION(dwfl_offline_section_address); +static DLSYM_FUNCTION(dwfl_report_end); +static DLSYM_FUNCTION(dwfl_standard_find_debuginfo); +static DLSYM_FUNCTION(dwfl_thread_getframes); +static DLSYM_FUNCTION(dwfl_thread_tid); /* libelf symbols */ -Elf *(*sym_elf_begin)(int, Elf_Cmd, Elf *); -int (*sym_elf_end)(Elf *); -Elf_Data *(*sym_elf_getdata_rawchunk)(Elf *, int64_t, size_t, Elf_Type); -GElf_Ehdr *(*sym_gelf_getehdr)(Elf *, GElf_Ehdr *); -int (*sym_elf_getphdrnum)(Elf *, size_t *); -const char *(*sym_elf_errmsg)(int); -int (*sym_elf_errno)(void); -Elf *(*sym_elf_memory)(char *, size_t); -unsigned int (*sym_elf_version)(unsigned int); -GElf_Phdr *(*sym_gelf_getphdr)(Elf *, int, GElf_Phdr *); -size_t (*sym_gelf_getnote)(Elf_Data *, size_t, GElf_Nhdr *, size_t *, size_t *); +static DLSYM_FUNCTION(elf_begin); +static DLSYM_FUNCTION(elf_end); +static DLSYM_FUNCTION(elf_getdata_rawchunk); +static DLSYM_FUNCTION(gelf_getehdr); +static DLSYM_FUNCTION(elf_getphdrnum); +static DLSYM_FUNCTION(elf_errmsg); +static DLSYM_FUNCTION(elf_errno); +static DLSYM_FUNCTION(elf_memory); +static DLSYM_FUNCTION(elf_version); +static DLSYM_FUNCTION(gelf_getphdr); +static DLSYM_FUNCTION(gelf_getnote); int dlopen_dw(void) { int r; diff --git a/src/shared/idn-util.c b/src/shared/idn-util.c index 6f36688dc01..70f039f8252 100644 --- a/src/shared/idn-util.c +++ b/src/shared/idn-util.c @@ -16,9 +16,9 @@ static void* idn_dl = NULL; #endif #if HAVE_LIBIDN2 -int (*sym_idn2_lookup_u8)(const uint8_t* src, uint8_t** lookupname, int flags) = NULL; +DLSYM_FUNCTION(idn2_lookup_u8); const char *(*sym_idn2_strerror)(int rc) _const_ = NULL; -int (*sym_idn2_to_unicode_8z8z)(const char * input, char ** output, int flags) = NULL; +DLSYM_FUNCTION(idn2_to_unicode_8z8z); int dlopen_idn(void) { return dlopen_many_sym_or_warn( @@ -30,10 +30,10 @@ int dlopen_idn(void) { #endif #if HAVE_LIBIDN -int (*sym_idna_to_ascii_4i)(const uint32_t * in, size_t inlen, char *out, int flags); -int (*sym_idna_to_unicode_44i)(const uint32_t * in, size_t inlen, uint32_t * out, size_t * outlen, int flags); -char* (*sym_stringprep_ucs4_to_utf8)(const uint32_t * str, ssize_t len, size_t * items_read, size_t * items_written); -uint32_t* (*sym_stringprep_utf8_to_ucs4)(const char *str, ssize_t len, size_t *items_written); +DLSYM_FUNCTION(idna_to_ascii_4i); +DLSYM_FUNCTION(idna_to_unicode_44i); +DLSYM_FUNCTION(stringprep_ucs4_to_utf8); +DLSYM_FUNCTION(stringprep_utf8_to_ucs4); int dlopen_idn(void) { _cleanup_(dlclosep) void *dl = NULL; diff --git a/src/shared/idn-util.h b/src/shared/idn-util.h index e64bd99747e..3ae2f132318 100644 --- a/src/shared/idn-util.h +++ b/src/shared/idn-util.h @@ -11,6 +11,8 @@ #include #if HAVE_LIBIDN2 || HAVE_LIBIDN +#include "dlfcn-util.h" + int dlopen_idn(void); #else static inline int dlopen_idn(void) { @@ -19,14 +21,14 @@ static inline int dlopen_idn(void) { #endif #if HAVE_LIBIDN2 -extern int (*sym_idn2_lookup_u8)(const uint8_t* src, uint8_t** lookupname, int flags); +DLSYM_PROTOTYPE(idn2_lookup_u8); extern const char *(*sym_idn2_strerror)(int rc) _const_; -extern int (*sym_idn2_to_unicode_8z8z)(const char * input, char ** output, int flags); +DLSYM_PROTOTYPE(idn2_to_unicode_8z8z); #endif #if HAVE_LIBIDN -extern int (*sym_idna_to_ascii_4i)(const uint32_t * in, size_t inlen, char *out, int flags); -extern int (*sym_idna_to_unicode_44i)(const uint32_t * in, size_t inlen,uint32_t * out, size_t * outlen, int flags); -extern char* (*sym_stringprep_ucs4_to_utf8)(const uint32_t * str, ssize_t len, size_t * items_read, size_t * items_written); -extern uint32_t* (*sym_stringprep_utf8_to_ucs4)(const char *str, ssize_t len, size_t *items_written); +DLSYM_PROTOTYPE(idna_to_ascii_4i); +DLSYM_PROTOTYPE(idna_to_unicode_44i); +DLSYM_PROTOTYPE(stringprep_ucs4_to_utf8); +DLSYM_PROTOTYPE(stringprep_utf8_to_ucs4); #endif diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index f5df5793697..15b7e42c848 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -16,53 +16,53 @@ static void *libfido2_dl = NULL; -int (*sym_fido_assert_allow_cred)(fido_assert_t *, const unsigned char *, size_t) = NULL; -void (*sym_fido_assert_free)(fido_assert_t **) = NULL; -size_t (*sym_fido_assert_hmac_secret_len)(const fido_assert_t *, size_t) = NULL; -const unsigned char* (*sym_fido_assert_hmac_secret_ptr)(const fido_assert_t *, size_t) = NULL; -fido_assert_t* (*sym_fido_assert_new)(void) = NULL; -int (*sym_fido_assert_set_clientdata_hash)(fido_assert_t *, const unsigned char *, size_t) = NULL; -int (*sym_fido_assert_set_extensions)(fido_assert_t *, int) = NULL; -int (*sym_fido_assert_set_hmac_salt)(fido_assert_t *, const unsigned char *, size_t) = NULL; -int (*sym_fido_assert_set_rp)(fido_assert_t *, const char *) = NULL; -int (*sym_fido_assert_set_up)(fido_assert_t *, fido_opt_t) = NULL; -int (*sym_fido_assert_set_uv)(fido_assert_t *, fido_opt_t) = NULL; -size_t (*sym_fido_cbor_info_extensions_len)(const fido_cbor_info_t *) = NULL; -char **(*sym_fido_cbor_info_extensions_ptr)(const fido_cbor_info_t *) = NULL; -void (*sym_fido_cbor_info_free)(fido_cbor_info_t **) = NULL; -fido_cbor_info_t* (*sym_fido_cbor_info_new)(void) = NULL; -size_t (*sym_fido_cbor_info_options_len)(const fido_cbor_info_t *) = NULL; -char** (*sym_fido_cbor_info_options_name_ptr)(const fido_cbor_info_t *) = NULL; -const bool* (*sym_fido_cbor_info_options_value_ptr)(const fido_cbor_info_t *) = NULL; -void (*sym_fido_cred_free)(fido_cred_t **) = NULL; -size_t (*sym_fido_cred_id_len)(const fido_cred_t *) = NULL; -const unsigned char* (*sym_fido_cred_id_ptr)(const fido_cred_t *) = NULL; -fido_cred_t* (*sym_fido_cred_new)(void) = NULL; -int (*sym_fido_cred_set_clientdata_hash)(fido_cred_t *, const unsigned char *, size_t) = NULL; -int (*sym_fido_cred_set_extensions)(fido_cred_t *, int) = NULL; -int (*sym_fido_cred_set_rk)(fido_cred_t *, fido_opt_t) = NULL; -int (*sym_fido_cred_set_rp)(fido_cred_t *, const char *, const char *) = NULL; -int (*sym_fido_cred_set_type)(fido_cred_t *, int) = NULL; -int (*sym_fido_cred_set_user)(fido_cred_t *, const unsigned char *, size_t, const char *, const char *, const char *) = NULL; -int (*sym_fido_cred_set_uv)(fido_cred_t *, fido_opt_t) = NULL; -void (*sym_fido_dev_free)(fido_dev_t **) = NULL; -int (*sym_fido_dev_get_assert)(fido_dev_t *, fido_assert_t *, const char *) = NULL; -int (*sym_fido_dev_get_cbor_info)(fido_dev_t *, fido_cbor_info_t *) = NULL; -void (*sym_fido_dev_info_free)(fido_dev_info_t **, size_t) = NULL; -int (*sym_fido_dev_info_manifest)(fido_dev_info_t *, size_t, size_t *) = NULL; -const char* (*sym_fido_dev_info_manufacturer_string)(const fido_dev_info_t *) = NULL; -const char* (*sym_fido_dev_info_product_string)(const fido_dev_info_t *) = NULL; -fido_dev_info_t* (*sym_fido_dev_info_new)(size_t) = NULL; -const char* (*sym_fido_dev_info_path)(const fido_dev_info_t *) = NULL; -const fido_dev_info_t* (*sym_fido_dev_info_ptr)(const fido_dev_info_t *, size_t) = NULL; -bool (*sym_fido_dev_is_fido2)(const fido_dev_t *) = NULL; -int (*sym_fido_dev_make_cred)(fido_dev_t *, fido_cred_t *, const char *) = NULL; -fido_dev_t* (*sym_fido_dev_new)(void) = NULL; -int (*sym_fido_dev_open)(fido_dev_t *, const char *) = NULL; -int (*sym_fido_dev_close)(fido_dev_t *) = NULL; -void (*sym_fido_init)(int) = NULL; -void (*sym_fido_set_log_handler)(fido_log_handler_t *) = NULL; -const char* (*sym_fido_strerr)(int) = NULL; +DLSYM_FUNCTION(fido_assert_allow_cred); +DLSYM_FUNCTION(fido_assert_free); +DLSYM_FUNCTION(fido_assert_hmac_secret_len); +DLSYM_FUNCTION(fido_assert_hmac_secret_ptr); +DLSYM_FUNCTION(fido_assert_new); +DLSYM_FUNCTION(fido_assert_set_clientdata_hash); +DLSYM_FUNCTION(fido_assert_set_extensions); +DLSYM_FUNCTION(fido_assert_set_hmac_salt); +DLSYM_FUNCTION(fido_assert_set_rp); +DLSYM_FUNCTION(fido_assert_set_up); +DLSYM_FUNCTION(fido_assert_set_uv); +DLSYM_FUNCTION(fido_cbor_info_extensions_len); +DLSYM_FUNCTION(fido_cbor_info_extensions_ptr); +DLSYM_FUNCTION(fido_cbor_info_free); +DLSYM_FUNCTION(fido_cbor_info_new); +DLSYM_FUNCTION(fido_cbor_info_options_len); +DLSYM_FUNCTION(fido_cbor_info_options_name_ptr); +DLSYM_FUNCTION(fido_cbor_info_options_value_ptr); +DLSYM_FUNCTION(fido_cred_free); +DLSYM_FUNCTION(fido_cred_id_len); +DLSYM_FUNCTION(fido_cred_id_ptr); +DLSYM_FUNCTION(fido_cred_new); +DLSYM_FUNCTION(fido_cred_set_clientdata_hash); +DLSYM_FUNCTION(fido_cred_set_extensions); +DLSYM_FUNCTION(fido_cred_set_rk); +DLSYM_FUNCTION(fido_cred_set_rp); +DLSYM_FUNCTION(fido_cred_set_type); +DLSYM_FUNCTION(fido_cred_set_user); +DLSYM_FUNCTION(fido_cred_set_uv); +DLSYM_FUNCTION(fido_dev_free); +DLSYM_FUNCTION(fido_dev_get_assert); +DLSYM_FUNCTION(fido_dev_get_cbor_info); +DLSYM_FUNCTION(fido_dev_info_free); +DLSYM_FUNCTION(fido_dev_info_manifest); +DLSYM_FUNCTION(fido_dev_info_manufacturer_string); +DLSYM_FUNCTION(fido_dev_info_product_string); +DLSYM_FUNCTION(fido_dev_info_new); +DLSYM_FUNCTION(fido_dev_info_path); +DLSYM_FUNCTION(fido_dev_info_ptr); +DLSYM_FUNCTION(fido_dev_is_fido2); +DLSYM_FUNCTION(fido_dev_make_cred); +DLSYM_FUNCTION(fido_dev_new); +DLSYM_FUNCTION(fido_dev_open); +DLSYM_FUNCTION(fido_dev_close); +DLSYM_FUNCTION(fido_init); +DLSYM_FUNCTION(fido_set_log_handler); +DLSYM_FUNCTION(fido_strerr); static void fido_log_propagate_handler(const char *s) { log_debug("libfido2: %s", strempty(s)); diff --git a/src/shared/libfido2-util.h b/src/shared/libfido2-util.h index 3520ab4ec3f..198408fdaf3 100644 --- a/src/shared/libfido2-util.h +++ b/src/shared/libfido2-util.h @@ -17,53 +17,55 @@ typedef enum Fido2EnrollFlags { #if HAVE_LIBFIDO2 #include -extern int (*sym_fido_assert_allow_cred)(fido_assert_t *, const unsigned char *, size_t); -extern void (*sym_fido_assert_free)(fido_assert_t **); -extern size_t (*sym_fido_assert_hmac_secret_len)(const fido_assert_t *, size_t); -extern const unsigned char* (*sym_fido_assert_hmac_secret_ptr)(const fido_assert_t *, size_t); -extern fido_assert_t* (*sym_fido_assert_new)(void); -extern int (*sym_fido_assert_set_clientdata_hash)(fido_assert_t *, const unsigned char *, size_t); -extern int (*sym_fido_assert_set_extensions)(fido_assert_t *, int); -extern int (*sym_fido_assert_set_hmac_salt)(fido_assert_t *, const unsigned char *, size_t); -extern int (*sym_fido_assert_set_rp)(fido_assert_t *, const char *); -extern int (*sym_fido_assert_set_up)(fido_assert_t *, fido_opt_t); -extern int (*sym_fido_assert_set_uv)(fido_assert_t *, fido_opt_t); -extern size_t (*sym_fido_cbor_info_extensions_len)(const fido_cbor_info_t *); -extern char **(*sym_fido_cbor_info_extensions_ptr)(const fido_cbor_info_t *); -extern void (*sym_fido_cbor_info_free)(fido_cbor_info_t **); -extern fido_cbor_info_t* (*sym_fido_cbor_info_new)(void); -extern size_t (*sym_fido_cbor_info_options_len)(const fido_cbor_info_t *); -extern char** (*sym_fido_cbor_info_options_name_ptr)(const fido_cbor_info_t *); -extern const bool* (*sym_fido_cbor_info_options_value_ptr)(const fido_cbor_info_t *); -extern void (*sym_fido_cred_free)(fido_cred_t **); -extern size_t (*sym_fido_cred_id_len)(const fido_cred_t *); -extern const unsigned char* (*sym_fido_cred_id_ptr)(const fido_cred_t *); -extern fido_cred_t* (*sym_fido_cred_new)(void); -extern int (*sym_fido_cred_set_clientdata_hash)(fido_cred_t *, const unsigned char *, size_t); -extern int (*sym_fido_cred_set_extensions)(fido_cred_t *, int); -extern int (*sym_fido_cred_set_rk)(fido_cred_t *, fido_opt_t); -extern int (*sym_fido_cred_set_rp)(fido_cred_t *, const char *, const char *); -extern int (*sym_fido_cred_set_type)(fido_cred_t *, int); -extern int (*sym_fido_cred_set_user)(fido_cred_t *, const unsigned char *, size_t, const char *, const char *, const char *); -extern int (*sym_fido_cred_set_uv)(fido_cred_t *, fido_opt_t); -extern void (*sym_fido_dev_free)(fido_dev_t **); -extern int (*sym_fido_dev_get_assert)(fido_dev_t *, fido_assert_t *, const char *); -extern int (*sym_fido_dev_get_cbor_info)(fido_dev_t *, fido_cbor_info_t *); -extern void (*sym_fido_dev_info_free)(fido_dev_info_t **, size_t); -extern int (*sym_fido_dev_info_manifest)(fido_dev_info_t *, size_t, size_t *); -extern const char* (*sym_fido_dev_info_manufacturer_string)(const fido_dev_info_t *); -extern const char* (*sym_fido_dev_info_product_string)(const fido_dev_info_t *); -extern fido_dev_info_t* (*sym_fido_dev_info_new)(size_t); -extern const char* (*sym_fido_dev_info_path)(const fido_dev_info_t *); -extern const fido_dev_info_t* (*sym_fido_dev_info_ptr)(const fido_dev_info_t *, size_t); -extern bool (*sym_fido_dev_is_fido2)(const fido_dev_t *); -extern int (*sym_fido_dev_make_cred)(fido_dev_t *, fido_cred_t *, const char *); -extern fido_dev_t* (*sym_fido_dev_new)(void); -extern int (*sym_fido_dev_open)(fido_dev_t *, const char *); -extern int (*sym_fido_dev_close)(fido_dev_t *); -extern void (*sym_fido_init)(int); -extern void (*sym_fido_set_log_handler)(fido_log_handler_t *); -extern const char* (*sym_fido_strerr)(int); +#include "dlfcn-util.h" + +DLSYM_PROTOTYPE(fido_assert_allow_cred); +DLSYM_PROTOTYPE(fido_assert_free); +DLSYM_PROTOTYPE(fido_assert_hmac_secret_len); +DLSYM_PROTOTYPE(fido_assert_hmac_secret_ptr); +DLSYM_PROTOTYPE(fido_assert_new); +DLSYM_PROTOTYPE(fido_assert_set_clientdata_hash); +DLSYM_PROTOTYPE(fido_assert_set_extensions); +DLSYM_PROTOTYPE(fido_assert_set_hmac_salt); +DLSYM_PROTOTYPE(fido_assert_set_rp); +DLSYM_PROTOTYPE(fido_assert_set_up); +DLSYM_PROTOTYPE(fido_assert_set_uv); +DLSYM_PROTOTYPE(fido_cbor_info_extensions_len); +DLSYM_PROTOTYPE(fido_cbor_info_extensions_ptr); +DLSYM_PROTOTYPE(fido_cbor_info_free); +DLSYM_PROTOTYPE(fido_cbor_info_new); +DLSYM_PROTOTYPE(fido_cbor_info_options_len); +DLSYM_PROTOTYPE(fido_cbor_info_options_name_ptr); +DLSYM_PROTOTYPE(fido_cbor_info_options_value_ptr); +DLSYM_PROTOTYPE(fido_cred_free); +DLSYM_PROTOTYPE(fido_cred_id_len); +DLSYM_PROTOTYPE(fido_cred_id_ptr); +DLSYM_PROTOTYPE(fido_cred_new); +DLSYM_PROTOTYPE(fido_cred_set_clientdata_hash); +DLSYM_PROTOTYPE(fido_cred_set_extensions); +DLSYM_PROTOTYPE(fido_cred_set_rk); +DLSYM_PROTOTYPE(fido_cred_set_rp); +DLSYM_PROTOTYPE(fido_cred_set_type); +DLSYM_PROTOTYPE(fido_cred_set_user); +DLSYM_PROTOTYPE(fido_cred_set_uv); +DLSYM_PROTOTYPE(fido_dev_free); +DLSYM_PROTOTYPE(fido_dev_get_assert); +DLSYM_PROTOTYPE(fido_dev_get_cbor_info); +DLSYM_PROTOTYPE(fido_dev_info_free); +DLSYM_PROTOTYPE(fido_dev_info_manifest); +DLSYM_PROTOTYPE(fido_dev_info_manufacturer_string); +DLSYM_PROTOTYPE(fido_dev_info_product_string); +DLSYM_PROTOTYPE(fido_dev_info_new); +DLSYM_PROTOTYPE(fido_dev_info_path); +DLSYM_PROTOTYPE(fido_dev_info_ptr); +DLSYM_PROTOTYPE(fido_dev_is_fido2); +DLSYM_PROTOTYPE(fido_dev_make_cred); +DLSYM_PROTOTYPE(fido_dev_new); +DLSYM_PROTOTYPE(fido_dev_open); +DLSYM_PROTOTYPE(fido_dev_close); +DLSYM_PROTOTYPE(fido_init); +DLSYM_PROTOTYPE(fido_set_log_handler); +DLSYM_PROTOTYPE(fido_strerr); int dlopen_libfido2(void); diff --git a/src/shared/password-quality-util-passwdqc.c b/src/shared/password-quality-util-passwdqc.c index adfc14d7404..c32b4935345 100644 --- a/src/shared/password-quality-util-passwdqc.c +++ b/src/shared/password-quality-util-passwdqc.c @@ -12,12 +12,12 @@ static void *passwdqc_dl = NULL; -void (*sym_passwdqc_params_reset)(passwdqc_params_t *params); -int (*sym_passwdqc_params_load)(passwdqc_params_t *params, char **reason, const char *pathname); -int (*sym_passwdqc_params_parse)(passwdqc_params_t *params, char **reason, int argc, const char *const *argv); -void (*sym_passwdqc_params_free)(passwdqc_params_t *params); -const char *(*sym_passwdqc_check)(const passwdqc_params_qc_t *params, const char *newpass, const char *oldpass, const struct passwd *pw); -char *(*sym_passwdqc_random)(const passwdqc_params_qc_t *params); +DLSYM_FUNCTION(passwdqc_params_reset); +DLSYM_FUNCTION(passwdqc_params_load); +DLSYM_FUNCTION(passwdqc_params_parse); +DLSYM_FUNCTION(passwdqc_params_free); +DLSYM_FUNCTION(passwdqc_check); +DLSYM_FUNCTION(passwdqc_random); int dlopen_passwdqc(void) { return dlopen_many_sym_or_warn( diff --git a/src/shared/password-quality-util-passwdqc.h b/src/shared/password-quality-util-passwdqc.h index 0d528d2089f..11d756d2554 100644 --- a/src/shared/password-quality-util-passwdqc.h +++ b/src/shared/password-quality-util-passwdqc.h @@ -6,12 +6,12 @@ #if HAVE_PASSWDQC #include -extern void (*sym_passwdqc_params_reset)(passwdqc_params_t *params); -extern int (*sym_passwdqc_params_load)(passwdqc_params_t *params, char **reason, const char *pathname); -extern int (*sym_passwdqc_params_parse)(passwdqc_params_t *params, char **reason, int argc, const char *const *argv); -extern void (*sym_passwdqc_params_free)(passwdqc_params_t *params); -extern const char *(*sym_passwdqc_check)(const passwdqc_params_qc_t *params, const char *newpass, const char *oldpass, const struct passwd *pw); -extern char *(*sym_passwdqc_random)(const passwdqc_params_qc_t *params); +DLSYM_PROTOTYPE(passwdqc_params_reset); +DLSYM_PROTOTYPE(passwdqc_params_load); +DLSYM_PROTOTYPE(passwdqc_params_parse); +DLSYM_PROTOTYPE(passwdqc_params_free); +DLSYM_PROTOTYPE(passwdqc_check); +DLSYM_PROTOTYPE(passwdqc_random); int dlopen_passwdqc(void); diff --git a/src/shared/password-quality-util-pwquality.c b/src/shared/password-quality-util-pwquality.c index 80f7d58e5d3..87e7d285c53 100644 --- a/src/shared/password-quality-util-pwquality.c +++ b/src/shared/password-quality-util-pwquality.c @@ -14,14 +14,14 @@ static void *pwquality_dl = NULL; -int (*sym_pwquality_check)(pwquality_settings_t *pwq, const char *password, const char *oldpassword, const char *user, void **auxerror); -pwquality_settings_t *(*sym_pwquality_default_settings)(void); -void (*sym_pwquality_free_settings)(pwquality_settings_t *pwq); -int (*sym_pwquality_generate)(pwquality_settings_t *pwq, int entropy_bits, char **password); -int (*sym_pwquality_get_str_value)(pwquality_settings_t *pwq, int setting, const char **value); -int (*sym_pwquality_read_config)(pwquality_settings_t *pwq, const char *cfgfile, void **auxerror); -int (*sym_pwquality_set_int_value)(pwquality_settings_t *pwq, int setting, int value); -const char* (*sym_pwquality_strerror)(char *buf, size_t len, int errcode, void *auxerror); +DLSYM_FUNCTION(pwquality_check); +DLSYM_FUNCTION(pwquality_default_settings); +DLSYM_FUNCTION(pwquality_free_settings); +DLSYM_FUNCTION(pwquality_generate); +DLSYM_FUNCTION(pwquality_get_str_value); +DLSYM_FUNCTION(pwquality_read_config); +DLSYM_FUNCTION(pwquality_set_int_value); +DLSYM_FUNCTION(pwquality_strerror); int dlopen_pwquality(void) { return dlopen_many_sym_or_warn( diff --git a/src/shared/password-quality-util-pwquality.h b/src/shared/password-quality-util-pwquality.h index a420b0df2c6..4c2517b446a 100644 --- a/src/shared/password-quality-util-pwquality.h +++ b/src/shared/password-quality-util-pwquality.h @@ -8,14 +8,16 @@ #include #include -extern int (*sym_pwquality_check)(pwquality_settings_t *pwq, const char *password, const char *oldpassword, const char *user, void **auxerror); -extern pwquality_settings_t *(*sym_pwquality_default_settings)(void); -extern void (*sym_pwquality_free_settings)(pwquality_settings_t *pwq); -extern int (*sym_pwquality_generate)(pwquality_settings_t *pwq, int entropy_bits, char **password); -extern int (*sym_pwquality_get_str_value)(pwquality_settings_t *pwq, int setting, const char **value); -extern int (*sym_pwquality_read_config)(pwquality_settings_t *pwq, const char *cfgfile, void **auxerror); -extern int (*sym_pwquality_set_int_value)(pwquality_settings_t *pwq, int setting, int value); -extern const char* (*sym_pwquality_strerror)(char *buf, size_t len, int errcode, void *auxerror); +#include "dlfcn-util.h" + +DLSYM_PROTOTYPE(pwquality_check); +DLSYM_PROTOTYPE(pwquality_default_settings); +DLSYM_PROTOTYPE(pwquality_free_settings); +DLSYM_PROTOTYPE(pwquality_generate); +DLSYM_PROTOTYPE(pwquality_get_str_value); +DLSYM_PROTOTYPE(pwquality_read_config); +DLSYM_PROTOTYPE(pwquality_set_int_value); +DLSYM_PROTOTYPE(pwquality_strerror); int dlopen_pwquality(void); diff --git a/src/shared/pcre2-util.c b/src/shared/pcre2-util.c index 578b02ddc0d..4f33efc5fc9 100644 --- a/src/shared/pcre2-util.c +++ b/src/shared/pcre2-util.c @@ -7,13 +7,13 @@ #if HAVE_PCRE2 static void *pcre2_dl = NULL; -pcre2_match_data* (*sym_pcre2_match_data_create)(uint32_t, pcre2_general_context *); -void (*sym_pcre2_match_data_free)(pcre2_match_data *); -void (*sym_pcre2_code_free)(pcre2_code *); -pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, pcre2_compile_context *); -int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE); -int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *); -PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *); +DLSYM_FUNCTION(pcre2_match_data_create); +DLSYM_FUNCTION(pcre2_match_data_free); +DLSYM_FUNCTION(pcre2_code_free); +DLSYM_FUNCTION(pcre2_compile); +DLSYM_FUNCTION(pcre2_get_error_message); +DLSYM_FUNCTION(pcre2_match); +DLSYM_FUNCTION(pcre2_get_ovector_pointer); DEFINE_HASH_OPS_WITH_KEY_DESTRUCTOR( pcre2_code_hash_ops_free, diff --git a/src/shared/pcre2-util.h b/src/shared/pcre2-util.h index f1e744d5774..27e2b02f7dd 100644 --- a/src/shared/pcre2-util.h +++ b/src/shared/pcre2-util.h @@ -6,16 +6,18 @@ #if HAVE_PCRE2 +#include "dlfcn-util.h" + #define PCRE2_CODE_UNIT_WIDTH 8 #include -extern pcre2_match_data* (*sym_pcre2_match_data_create)(uint32_t, pcre2_general_context *); -extern void (*sym_pcre2_match_data_free)(pcre2_match_data *); -extern void (*sym_pcre2_code_free)(pcre2_code *); -extern pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, pcre2_compile_context *); -extern int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE); -extern int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *); -extern PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *); +DLSYM_PROTOTYPE(pcre2_match_data_create); +DLSYM_PROTOTYPE(pcre2_match_data_free); +DLSYM_PROTOTYPE(pcre2_code_free); +DLSYM_PROTOTYPE(pcre2_compile); +DLSYM_PROTOTYPE(pcre2_get_error_message); +DLSYM_PROTOTYPE(pcre2_match); +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); diff --git a/src/shared/pkcs11-util.c b/src/shared/pkcs11-util.c index c330d9b6e0f..e6feba44bdf 100644 --- a/src/shared/pkcs11-util.c +++ b/src/shared/pkcs11-util.c @@ -43,22 +43,22 @@ bool pkcs11_uri_valid(const char *uri) { static void *p11kit_dl = NULL; -char *(*sym_p11_kit_module_get_name)(CK_FUNCTION_LIST *module); -void (*sym_p11_kit_modules_finalize_and_release)(CK_FUNCTION_LIST **modules); -CK_FUNCTION_LIST **(*sym_p11_kit_modules_load_and_initialize)(int flags); -const char *(*sym_p11_kit_strerror)(CK_RV rv); -int (*sym_p11_kit_uri_format)(P11KitUri *uri, P11KitUriType uri_type, char **string); -void (*sym_p11_kit_uri_free)(P11KitUri *uri); -CK_ATTRIBUTE_PTR (*sym_p11_kit_uri_get_attributes)(P11KitUri *uri, CK_ULONG *n_attrs); -CK_ATTRIBUTE_PTR (*sym_p11_kit_uri_get_attribute)(P11KitUri *uri, CK_ATTRIBUTE_TYPE attr_type); -int (*sym_p11_kit_uri_set_attribute)(P11KitUri *uri, CK_ATTRIBUTE_PTR attr); -CK_INFO_PTR (*sym_p11_kit_uri_get_module_info)(P11KitUri *uri); -CK_SLOT_INFO_PTR (*sym_p11_kit_uri_get_slot_info)(P11KitUri *uri); -CK_TOKEN_INFO_PTR (*sym_p11_kit_uri_get_token_info)(P11KitUri *uri); -int (*sym_p11_kit_uri_match_token_info)(const P11KitUri *uri, const CK_TOKEN_INFO *token_info); -const char *(*sym_p11_kit_uri_message)(int code); -P11KitUri *(*sym_p11_kit_uri_new)(void); -int (*sym_p11_kit_uri_parse)(const char *string, P11KitUriType uri_type, P11KitUri *uri); +DLSYM_FUNCTION(p11_kit_module_get_name); +DLSYM_FUNCTION(p11_kit_modules_finalize_and_release); +DLSYM_FUNCTION(p11_kit_modules_load_and_initialize); +DLSYM_FUNCTION(p11_kit_strerror); +DLSYM_FUNCTION(p11_kit_uri_format); +DLSYM_FUNCTION(p11_kit_uri_free); +DLSYM_FUNCTION(p11_kit_uri_get_attributes); +DLSYM_FUNCTION(p11_kit_uri_get_attribute); +DLSYM_FUNCTION(p11_kit_uri_set_attribute); +DLSYM_FUNCTION(p11_kit_uri_get_module_info); +DLSYM_FUNCTION(p11_kit_uri_get_slot_info); +DLSYM_FUNCTION(p11_kit_uri_get_token_info); +DLSYM_FUNCTION(p11_kit_uri_match_token_info); +DLSYM_FUNCTION(p11_kit_uri_message); +DLSYM_FUNCTION(p11_kit_uri_new); +DLSYM_FUNCTION(p11_kit_uri_parse); int dlopen_p11kit(void) { return dlopen_many_sym_or_warn( diff --git a/src/shared/pkcs11-util.h b/src/shared/pkcs11-util.h index 6927a37113f..23ab823c40a 100644 --- a/src/shared/pkcs11-util.h +++ b/src/shared/pkcs11-util.h @@ -13,29 +13,29 @@ #endif #include "ask-password-api.h" +#include "dlfcn-util.h" #include "macro.h" #include "time-util.h" bool pkcs11_uri_valid(const char *uri); #if HAVE_P11KIT - -extern char *(*sym_p11_kit_module_get_name)(CK_FUNCTION_LIST *module); -extern void (*sym_p11_kit_modules_finalize_and_release)(CK_FUNCTION_LIST **modules); -extern CK_FUNCTION_LIST **(*sym_p11_kit_modules_load_and_initialize)(int flags); -extern const char *(*sym_p11_kit_strerror)(CK_RV rv); -extern int (*sym_p11_kit_uri_format)(P11KitUri *uri, P11KitUriType uri_type, char **string); -extern void (*sym_p11_kit_uri_free)(P11KitUri *uri); -extern CK_ATTRIBUTE_PTR (*sym_p11_kit_uri_get_attributes)(P11KitUri *uri, CK_ULONG *n_attrs); -extern CK_ATTRIBUTE_PTR (*sym_p11_kit_uri_get_attribute)(P11KitUri *uri, CK_ATTRIBUTE_TYPE attr_type); -extern int (*sym_p11_kit_uri_set_attribute)(P11KitUri *uri, CK_ATTRIBUTE_PTR attr); -extern CK_INFO_PTR (*sym_p11_kit_uri_get_module_info)(P11KitUri *uri); -extern CK_SLOT_INFO_PTR (*sym_p11_kit_uri_get_slot_info)(P11KitUri *uri); -extern CK_TOKEN_INFO_PTR (*sym_p11_kit_uri_get_token_info)(P11KitUri *uri); -extern int (*sym_p11_kit_uri_match_token_info)(const P11KitUri *uri, const CK_TOKEN_INFO *token_info); -extern const char *(*sym_p11_kit_uri_message)(int code); -extern P11KitUri *(*sym_p11_kit_uri_new)(void); -extern int (*sym_p11_kit_uri_parse)(const char *string, P11KitUriType uri_type, P11KitUri *uri); +DLSYM_PROTOTYPE(p11_kit_module_get_name); +DLSYM_PROTOTYPE(p11_kit_modules_finalize_and_release); +DLSYM_PROTOTYPE(p11_kit_modules_load_and_initialize); +DLSYM_PROTOTYPE(p11_kit_strerror); +DLSYM_PROTOTYPE(p11_kit_uri_format); +DLSYM_PROTOTYPE(p11_kit_uri_free); +DLSYM_PROTOTYPE(p11_kit_uri_get_attributes); +DLSYM_PROTOTYPE(p11_kit_uri_get_attribute); +DLSYM_PROTOTYPE(p11_kit_uri_set_attribute); +DLSYM_PROTOTYPE(p11_kit_uri_get_module_info); +DLSYM_PROTOTYPE(p11_kit_uri_get_slot_info); +DLSYM_PROTOTYPE(p11_kit_uri_get_token_info); +DLSYM_PROTOTYPE(p11_kit_uri_match_token_info); +DLSYM_PROTOTYPE(p11_kit_uri_message); +DLSYM_PROTOTYPE(p11_kit_uri_new); +DLSYM_PROTOTYPE(p11_kit_uri_parse); int uri_from_string(const char *p, P11KitUri **ret); diff --git a/src/shared/qrcode-util.c b/src/shared/qrcode-util.c index b0dd90acd1a..c087136bd2b 100644 --- a/src/shared/qrcode-util.c +++ b/src/shared/qrcode-util.c @@ -18,8 +18,8 @@ static void *qrcode_dl = NULL; -static QRcode* (*sym_QRcode_encodeString)(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive) = NULL; -static void (*sym_QRcode_free)(QRcode *qrcode) = NULL; +static DLSYM_FUNCTION(QRcode_encodeString); +static DLSYM_FUNCTION(QRcode_free); int dlopen_qrencode(void) { int r; diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index f2b3bfb5759..20bb8c3ba5f 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -41,67 +41,67 @@ static void *libtss2_esys_dl = NULL; static void *libtss2_rc_dl = NULL; static void *libtss2_mu_dl = NULL; -static TSS2_RC (*sym_Esys_Create)(ESYS_CONTEXT *esysContext, ESYS_TR parentHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_SENSITIVE_CREATE *inSensitive, const TPM2B_PUBLIC *inPublic, const TPM2B_DATA *outsideInfo, const TPML_PCR_SELECTION *creationPCR, TPM2B_PRIVATE **outPrivate, TPM2B_PUBLIC **outPublic, TPM2B_CREATION_DATA **creationData, TPM2B_DIGEST **creationHash, TPMT_TK_CREATION **creationTicket) = NULL; -static TSS2_RC (*sym_Esys_CreateLoaded)(ESYS_CONTEXT *esysContext, ESYS_TR parentHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_SENSITIVE_CREATE *inSensitive, const TPM2B_TEMPLATE *inPublic, ESYS_TR *objectHandle, TPM2B_PRIVATE **outPrivate, TPM2B_PUBLIC **outPublic) = NULL; -static TSS2_RC (*sym_Esys_CreatePrimary)(ESYS_CONTEXT *esysContext, ESYS_TR primaryHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_SENSITIVE_CREATE *inSensitive, const TPM2B_PUBLIC *inPublic, const TPM2B_DATA *outsideInfo, const TPML_PCR_SELECTION *creationPCR, ESYS_TR *objectHandle, TPM2B_PUBLIC **outPublic, TPM2B_CREATION_DATA **creationData, TPM2B_DIGEST **creationHash, TPMT_TK_CREATION **creationTicket) = NULL; -static TSS2_RC (*sym_Esys_EvictControl)(ESYS_CONTEXT *esysContext, ESYS_TR auth, ESYS_TR objectHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, TPMI_DH_PERSISTENT persistentHandle, ESYS_TR *newObjectHandle) = NULL; -static void (*sym_Esys_Finalize)(ESYS_CONTEXT **context) = NULL; -static TSS2_RC (*sym_Esys_FlushContext)(ESYS_CONTEXT *esysContext, ESYS_TR flushHandle) = NULL; -static void (*sym_Esys_Free)(void *ptr) = NULL; -static TSS2_RC (*sym_Esys_GetCapability)(ESYS_CONTEXT *esysContext, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, TPM2_CAP capability, UINT32 property, UINT32 propertyCount, TPMI_YES_NO *moreData, TPMS_CAPABILITY_DATA **capabilityData) = NULL; -static TSS2_RC (*sym_Esys_GetRandom)(ESYS_CONTEXT *esysContext, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, UINT16 bytesRequested, TPM2B_DIGEST **randomBytes) = NULL; -static TSS2_RC (*sym_Esys_Import)(ESYS_CONTEXT *esysContext, ESYS_TR parentHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_DATA *encryptionKey, const TPM2B_PUBLIC *objectPublic, const TPM2B_PRIVATE *duplicate, const TPM2B_ENCRYPTED_SECRET *inSymSeed, const TPMT_SYM_DEF_OBJECT *symmetricAlg, TPM2B_PRIVATE **outPrivate) = NULL; -static TSS2_RC (*sym_Esys_Initialize)(ESYS_CONTEXT **esys_context, TSS2_TCTI_CONTEXT *tcti, TSS2_ABI_VERSION *abiVersion) = NULL; -static TSS2_RC (*sym_Esys_Load)(ESYS_CONTEXT *esysContext, ESYS_TR parentHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_PRIVATE *inPrivate, const TPM2B_PUBLIC *inPublic, ESYS_TR *objectHandle) = NULL; -static TSS2_RC (*sym_Esys_LoadExternal)(ESYS_CONTEXT *esysContext, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_SENSITIVE *inPrivate, const TPM2B_PUBLIC *inPublic, ESYS_TR hierarchy, ESYS_TR *objectHandle) = NULL; -static TSS2_RC (*sym_Esys_NV_DefineSpace)(ESYS_CONTEXT *esysContext, ESYS_TR authHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_AUTH *auth, const TPM2B_NV_PUBLIC *publicInfo, ESYS_TR *nvHandle); -static TSS2_RC (*sym_Esys_NV_UndefineSpace)(ESYS_CONTEXT *esysContext, ESYS_TR authHandle, ESYS_TR nvIndex, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3); -static TSS2_RC (*sym_Esys_NV_Write)(ESYS_CONTEXT *esysContext, ESYS_TR authHandle, ESYS_TR nvIndex, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_MAX_NV_BUFFER *data, UINT16 offset); -static TSS2_RC (*sym_Esys_PCR_Extend)(ESYS_CONTEXT *esysContext, ESYS_TR pcrHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPML_DIGEST_VALUES *digests) = NULL; -static TSS2_RC (*sym_Esys_PCR_Read)(ESYS_CONTEXT *esysContext, ESYS_TR shandle1,ESYS_TR shandle2, ESYS_TR shandle3, const TPML_PCR_SELECTION *pcrSelectionIn, UINT32 *pcrUpdateCounter, TPML_PCR_SELECTION **pcrSelectionOut, TPML_DIGEST **pcrValues) = NULL; -static TSS2_RC (*sym_Esys_PolicyAuthValue)(ESYS_CONTEXT *esysContext, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3) = NULL; -static TSS2_RC (*sym_Esys_PolicyAuthorize)(ESYS_CONTEXT *esysContext, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_DIGEST *approvedPolicy, const TPM2B_NONCE *policyRef, const TPM2B_NAME *keySign, const TPMT_TK_VERIFIED *checkTicket) = NULL; -static TSS2_RC (*sym_Esys_PolicyAuthorizeNV)(ESYS_CONTEXT *esysContext, ESYS_TR authHandle, ESYS_TR nvIndex, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3); -static TSS2_RC (*sym_Esys_PolicyGetDigest)(ESYS_CONTEXT *esysContext, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, TPM2B_DIGEST **policyDigest) = NULL; -static TSS2_RC (*sym_Esys_PolicyOR)(ESYS_CONTEXT *esysContext, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPML_DIGEST *pHashList) = NULL; -static TSS2_RC (*sym_Esys_PolicyPCR)(ESYS_CONTEXT *esysContext, ESYS_TR policySession, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_DIGEST *pcrDigest, const TPML_PCR_SELECTION *pcrs) = NULL; -static TSS2_RC (*sym_Esys_ReadPublic)(ESYS_CONTEXT *esysContext, ESYS_TR objectHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, TPM2B_PUBLIC **outPublic, TPM2B_NAME **name, TPM2B_NAME **qualifiedName) = NULL; -static TSS2_RC (*sym_Esys_StartAuthSession)(ESYS_CONTEXT *esysContext, ESYS_TR tpmKey, ESYS_TR bind, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_NONCE *nonceCaller, TPM2_SE sessionType, const TPMT_SYM_DEF *symmetric, TPMI_ALG_HASH authHash, ESYS_TR *sessionHandle) = NULL; -static TSS2_RC (*sym_Esys_Startup)(ESYS_CONTEXT *esysContext, TPM2_SU startupType) = NULL; -static TSS2_RC (*sym_Esys_TestParms)(ESYS_CONTEXT *esysContext, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPMT_PUBLIC_PARMS *parameters) = NULL; -static TSS2_RC (*sym_Esys_TR_Close)(ESYS_CONTEXT *esys_context, ESYS_TR *rsrc_handle) = NULL; -static TSS2_RC (*sym_Esys_TR_Deserialize)(ESYS_CONTEXT *esys_context, uint8_t const *buffer, size_t buffer_size, ESYS_TR *esys_handle) = NULL; -static TSS2_RC (*sym_Esys_TR_FromTPMPublic)(ESYS_CONTEXT *esysContext, TPM2_HANDLE tpm_handle, ESYS_TR optionalSession1, ESYS_TR optionalSession2, ESYS_TR optionalSession3, ESYS_TR *object) = NULL; -static TSS2_RC (*sym_Esys_TR_GetName)(ESYS_CONTEXT *esysContext, ESYS_TR handle, TPM2B_NAME **name) = NULL; -static TSS2_RC (*sym_Esys_TR_GetTpmHandle)(ESYS_CONTEXT *esys_context, ESYS_TR esys_handle, TPM2_HANDLE *tpm_handle) = NULL; -static TSS2_RC (*sym_Esys_TR_Serialize)(ESYS_CONTEXT *esys_context, ESYS_TR object, uint8_t **buffer, size_t *buffer_size) = NULL; -static TSS2_RC (*sym_Esys_TR_SetAuth)(ESYS_CONTEXT *esysContext, ESYS_TR handle, TPM2B_AUTH const *authValue) = NULL; -static TSS2_RC (*sym_Esys_TRSess_GetAttributes)(ESYS_CONTEXT *esysContext, ESYS_TR session, TPMA_SESSION *flags) = NULL; -static TSS2_RC (*sym_Esys_TRSess_SetAttributes)(ESYS_CONTEXT *esysContext, ESYS_TR session, TPMA_SESSION flags, TPMA_SESSION mask) = NULL; -static TSS2_RC (*sym_Esys_Unseal)(ESYS_CONTEXT *esysContext, ESYS_TR itemHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, TPM2B_SENSITIVE_DATA **outData) = NULL; -static TSS2_RC (*sym_Esys_VerifySignature)(ESYS_CONTEXT *esysContext, ESYS_TR keyHandle, ESYS_TR shandle1, ESYS_TR shandle2, ESYS_TR shandle3, const TPM2B_DIGEST *digest, const TPMT_SIGNATURE *signature, TPMT_TK_VERIFIED **validation) = NULL; - -static TSS2_RC (*sym_Tss2_MU_TPM2_CC_Marshal)(TPM2_CC src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2_HANDLE_Marshal)(TPM2_HANDLE src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_DIGEST_Marshal)(TPM2B_DIGEST const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_ENCRYPTED_SECRET_Marshal)(TPM2B_ENCRYPTED_SECRET const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_ENCRYPTED_SECRET_Unmarshal)(uint8_t const buffer[], size_t buffer_size, size_t *offset, TPM2B_ENCRYPTED_SECRET *dest) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_NAME_Marshal)(TPM2B_NAME const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_PRIVATE_Marshal)(TPM2B_PRIVATE const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_PRIVATE_Unmarshal)(uint8_t const buffer[], size_t buffer_size, size_t *offset, TPM2B_PRIVATE *dest) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_PUBLIC_Marshal)(TPM2B_PUBLIC const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_PUBLIC_Unmarshal)(uint8_t const buffer[], size_t buffer_size, size_t *offset, TPM2B_PUBLIC *dest) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_SENSITIVE_Marshal)(TPM2B_SENSITIVE const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPML_PCR_SELECTION_Marshal)(TPML_PCR_SELECTION const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPMS_NV_PUBLIC_Marshal)(TPMS_NV_PUBLIC const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_NV_PUBLIC_Marshal)(TPM2B_NV_PUBLIC const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPM2B_NV_PUBLIC_Unmarshal)(uint8_t const buffer[], size_t buffer_size, size_t *offset, TPM2B_NV_PUBLIC *dest) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPMS_ECC_POINT_Marshal)(TPMS_ECC_POINT const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPMT_HA_Marshal)(TPMT_HA const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_TPMT_PUBLIC_Marshal)(TPMT_PUBLIC const *src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; -static TSS2_RC (*sym_Tss2_MU_UINT32_Marshal)(UINT32 src, uint8_t buffer[], size_t buffer_size, size_t *offset) = NULL; - -static const char* (*sym_Tss2_RC_Decode)(TSS2_RC rc) = NULL; +static DLSYM_FUNCTION(Esys_Create); +static DLSYM_FUNCTION(Esys_CreateLoaded); +static DLSYM_FUNCTION(Esys_CreatePrimary); +static DLSYM_FUNCTION(Esys_EvictControl); +static DLSYM_FUNCTION(Esys_Finalize); +static DLSYM_FUNCTION(Esys_FlushContext); +static DLSYM_FUNCTION(Esys_Free); +static DLSYM_FUNCTION(Esys_GetCapability); +static DLSYM_FUNCTION(Esys_GetRandom); +static DLSYM_FUNCTION(Esys_Import); +static DLSYM_FUNCTION(Esys_Initialize); +static DLSYM_FUNCTION(Esys_Load); +static DLSYM_FUNCTION(Esys_LoadExternal); +static DLSYM_FUNCTION(Esys_NV_DefineSpace); +static DLSYM_FUNCTION(Esys_NV_UndefineSpace); +static DLSYM_FUNCTION(Esys_NV_Write); +static DLSYM_FUNCTION(Esys_PCR_Extend); +static DLSYM_FUNCTION(Esys_PCR_Read); +static DLSYM_FUNCTION(Esys_PolicyAuthValue); +static DLSYM_FUNCTION(Esys_PolicyAuthorize); +static DLSYM_FUNCTION(Esys_PolicyAuthorizeNV); +static DLSYM_FUNCTION(Esys_PolicyGetDigest); +static DLSYM_FUNCTION(Esys_PolicyOR); +static DLSYM_FUNCTION(Esys_PolicyPCR); +static DLSYM_FUNCTION(Esys_ReadPublic); +static DLSYM_FUNCTION(Esys_StartAuthSession); +static DLSYM_FUNCTION(Esys_Startup); +static DLSYM_FUNCTION(Esys_TestParms); +static DLSYM_FUNCTION(Esys_TR_Close); +static DLSYM_FUNCTION(Esys_TR_Deserialize); +static DLSYM_FUNCTION(Esys_TR_FromTPMPublic); +static DLSYM_FUNCTION(Esys_TR_GetName); +static DLSYM_FUNCTION(Esys_TR_GetTpmHandle); +static DLSYM_FUNCTION(Esys_TR_Serialize); +static DLSYM_FUNCTION(Esys_TR_SetAuth); +static DLSYM_FUNCTION(Esys_TRSess_GetAttributes); +static DLSYM_FUNCTION(Esys_TRSess_SetAttributes); +static DLSYM_FUNCTION(Esys_Unseal); +static DLSYM_FUNCTION(Esys_VerifySignature); + +static DLSYM_FUNCTION(Tss2_MU_TPM2_CC_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2_HANDLE_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_DIGEST_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_ENCRYPTED_SECRET_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_ENCRYPTED_SECRET_Unmarshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_NAME_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_PRIVATE_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_PRIVATE_Unmarshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_PUBLIC_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_PUBLIC_Unmarshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_SENSITIVE_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPML_PCR_SELECTION_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPMS_NV_PUBLIC_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_NV_PUBLIC_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPM2B_NV_PUBLIC_Unmarshal); +static DLSYM_FUNCTION(Tss2_MU_TPMS_ECC_POINT_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPMT_HA_Marshal); +static DLSYM_FUNCTION(Tss2_MU_TPMT_PUBLIC_Marshal); +static DLSYM_FUNCTION(Tss2_MU_UINT32_Marshal); + +static DLSYM_FUNCTION(Tss2_RC_Decode); int dlopen_tpm2(void) { int r; -- 2.47.3