]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: dlopen gcrypt in the --setup-keys path
authorLuca Boccassi <luca.boccassi@gmail.com>
Thu, 18 Jun 2026 15:46:32 +0000 (16:46 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Jun 2026 06:22:02 +0000 (15:22 +0900)
journalctl needs gcrypt to set up the journal sealing
keys and other such operations, but gets no dlopen note
with the dependency. Add the dlopen macro with a recommends
level so it can be skipped, but gets pulled in by default
on user/desktop systems.

Follow-up for 590e22643722cf1268bd24f9056c7115ab0c1cf2

src/basic/gcrypt-util.c
src/basic/gcrypt-util.h
src/journal/journalctl-authenticate.c

index 80e9d4ddb45d2f52b3654966ba3c01b788f80568..824fc6c4150c9f65bfbed33475ac4fb18c5ede40 100644 (file)
@@ -47,11 +47,7 @@ int dlopen_gcrypt(int log_level) {
 #if HAVE_GCRYPT
         static void *gcrypt_dl = NULL;
 
-        SD_ELF_NOTE_DLOPEN(
-                        "gcrypt",
-                        "Support for journald forward-sealing",
-                        SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
-                        "libgcrypt.so.20");
+        GCRYPT_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
 
         return dlopen_many_sym_or_warn(
                         &gcrypt_dl,
index 0f45fad205b2868fca650ea3dd094ac32191c9ab..2a85fa7e1daa650786577d2c286cded30e84ee50 100644 (file)
@@ -2,6 +2,8 @@
 
 #pragma once
 
+#include "sd-dlopen.h"
+
 #include "basic-forward.h"
 
 int dlopen_gcrypt(int log_level);
@@ -9,6 +11,18 @@ int dlopen_gcrypt(int log_level);
 int initialize_libgcrypt(bool secmem);
 
 #if HAVE_GCRYPT
+#define GCRYPT_NOTE(priority)                                           \
+        SD_ELF_NOTE_DLOPEN("gcrypt",                                    \
+                           "Support for journald forward-sealing",      \
+                           priority,                                    \
+                           "libgcrypt.so.20")
+
+#define DLOPEN_GCRYPT(log_level, priority)                              \
+        ({                                                              \
+                GCRYPT_NOTE(priority);                                  \
+                dlopen_gcrypt(log_level);                               \
+        })
+
 #include <gcrypt.h> /* IWYU pragma: export */
 
 #include "dlfcn-util.h"
@@ -53,6 +67,8 @@ extern DLSYM_PROTOTYPE(gcry_strerror);
                 (h__)->buf[(h__)->bufpos++] = (c) & 0xff;  \
         } while(false)
 #else
+#define DLOPEN_GCRYPT(log_level, priority) dlopen_gcrypt(log_level)
+
 typedef struct gcry_md_handle *gcry_md_hd_t;
 
 static inline void sym_gcry_md_close(gcry_md_hd_t h) {
index c31c31ef6125c2f67001edd673693c6464832caf..b1b1ba6cd04d63f20f8afd3a294b4df627b27a72 100644 (file)
@@ -11,6 +11,7 @@
 #include "fd-util.h"
 #include "fs-util.h"
 #include "fsprg.h"
+#include "gcrypt-util.h"
 #include "hostname-setup.h"
 #include "hostname-util.h"
 #include "io-util.h"
@@ -72,6 +73,10 @@ int action_setup_keys(void) {
 
         assert(arg_action == ACTION_SETUP_KEYS);
 
+        r = DLOPEN_GCRYPT(LOG_ERR, SD_ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED);
+        if (r < 0)
+                return r;
+
         r = is_dir("/var/log/journal/", /* follow= */ false);
         if (r == 0)
                 return log_error_errno(SYNTHETIC_ERRNO(ENOTDIR),