From: Lennart Poettering Date: Tue, 8 Aug 2023 10:26:09 +0000 (+0200) Subject: libfido2: pick up debug logging from libfido2, and funnel it through our log subsystem X-Git-Tag: v255-rc1~793 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a96b32dead5132ba37a8b968c59101c2aac8d23;p=thirdparty%2Fsystemd.git libfido2: pick up debug logging from libfido2, and funnel it through our log subsystem Fixes: #27984 --- diff --git a/src/shared/libfido2-util.c b/src/shared/libfido2-util.c index 57c40584879..1cc3afe6b97 100644 --- a/src/shared/libfido2-util.c +++ b/src/shared/libfido2-util.c @@ -60,10 +60,18 @@ 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; +static void fido_log_propagate_handler(const char *s) { + log_debug("libfido2: %s", strempty(s)); +} + int dlopen_libfido2(void) { - return dlopen_many_sym_or_warn( + int r; + + r = dlopen_many_sym_or_warn( &libfido2_dl, "libfido2.so.1", LOG_DEBUG, DLSYM_ARG(fido_assert_allow_cred), DLSYM_ARG(fido_assert_free), @@ -109,7 +117,16 @@ int dlopen_libfido2(void) { DLSYM_ARG(fido_dev_new), DLSYM_ARG(fido_dev_open), DLSYM_ARG(fido_dev_close), + DLSYM_ARG(fido_init), + DLSYM_ARG(fido_set_log_handler), DLSYM_ARG(fido_strerr)); + if (r < 0) + return r; + + sym_fido_init(FIDO_DEBUG); + sym_fido_set_log_handler(fido_log_propagate_handler); + + return 0; } static int verify_features( diff --git a/src/shared/libfido2-util.h b/src/shared/libfido2-util.h index a04a3768a5b..4cfc95f712a 100644 --- a/src/shared/libfido2-util.h +++ b/src/shared/libfido2-util.h @@ -61,6 +61,8 @@ 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); int dlopen_libfido2(void);