]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
libfido2: pick up debug logging from libfido2, and funnel it through our log subsystem
authorLennart Poettering <lennart@poettering.net>
Tue, 8 Aug 2023 10:26:09 +0000 (12:26 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Aug 2023 13:41:43 +0000 (15:41 +0200)
Fixes: #27984
src/shared/libfido2-util.c
src/shared/libfido2-util.h

index 57c40584879abfa87085a6ab39a9f09791eadaaa..1cc3afe6b9733f5065174ddb8530d72772894386 100644 (file)
@@ -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(
index a04a3768a5b054a94ee98c8bf0068d6dd594cc09..4cfc95f712a0b468843dfb21f3ee5deacff3d800 100644 (file)
@@ -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);