From: Zbigniew Jędrzejewski-Szmek Date: Fri, 7 Nov 2025 16:04:03 +0000 (+0100) Subject: journald: do not allow persistent journal storage in the initrd X-Git-Tag: v259-rc1~72^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F39624%2Fhead;p=thirdparty%2Fsystemd.git journald: do not allow persistent journal storage in the initrd 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. --- diff --git a/src/journal/journald-config.c b/src/journal/journald-config.c index de78a40008f..b524379b5c4 100644 --- a/src/journal/journald-config.c +++ b/src/journal/journald-config.c @@ -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. */