]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journald: do not allow persistent journal storage in the initrd 39624/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Nov 2025 16:04:03 +0000 (17:04 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 12 Nov 2025 23:08:31 +0000 (00:08 +0100)
If the user managed to configure persistent storage in the journal
in the initrd, e.g. by creating /var/log/journal with default of 'auto',
we could end up writing entries there. Let's make sure this doesn't
happen.

src/journal/journald-config.c

index de78a40008fd2066986255adac29782cf2f2a216..b524379b5c46f5842a3f489f52c5c4409d4bf861 100644 (file)
@@ -5,6 +5,7 @@
 #include "conf-parser.h"
 #include "creds-util.h"
 #include "daemon-util.h"
+#include "initrd-util.h"
 #include "journald-audit.h"
 #include "journald-config.h"
 #include "journald-context.h"
@@ -117,6 +118,11 @@ void manager_merge_configs(Manager *m) {
         journal_config_done(&m->config);
 
         MERGE_NON_NEGATIVE(storage, JOURNAL_STORAGE_DEFAULT_VAL);
+
+        /* In the initrd, only 'none' and 'volatile' make sense. */
+        if (in_initrd() && IN_SET(m->config.storage, STORAGE_PERSISTENT, STORAGE_AUTO))
+                m->config.storage = STORAGE_VOLATILE;
+
         manager_merge_journal_compress_options(m);
         MERGE_NON_NEGATIVE(seal, true);
         /* By default, /dev/kmsg is read only by the main namespace instance. */