From e601bed9455daae7b4d1bcecfbcf2bf08d61a54f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Nov 2025 15:18:14 +0100 Subject: [PATCH 1/5] meson: make journald.conf templated A noop, in preparation for subsequent changes. --- src/journal/{journald.conf => journald.conf.in} | 0 src/journal/meson.build | 10 ++++++---- 2 files changed, 6 insertions(+), 4 deletions(-) rename src/journal/{journald.conf => journald.conf.in} (100%) diff --git a/src/journal/journald.conf b/src/journal/journald.conf.in similarity index 100% rename from src/journal/journald.conf rename to src/journal/journald.conf.in diff --git a/src/journal/meson.build b/src/journal/meson.build index 364c4ce7bf..7f35421e15 100644 --- a/src/journal/meson.build +++ b/src/journal/meson.build @@ -153,10 +153,12 @@ executables += [ }, ] -if install_sysconfdir_samples - install_data('journald.conf', - install_dir : pkgconfigfiledir) -endif +custom_target( + input : 'journald.conf.in', + output: 'journald.conf', + command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'], + install : install_sysconfdir_samples, + install_dir : pkgconfigfiledir) if get_option('create-log-dirs') install_emptydir('/var/log/journal', From 7e9a787a8677c8a7e014622a06152ead2d8c0638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Nov 2025 16:41:05 +0100 Subject: [PATCH 2/5] man: stop inventing custom entity names for docbook For some reason, the entity names configured in custom-entities.ent used abbreviated names. This just creates unnecessary confusion, so update to use the same name as the config dict. Reword some surrounding sentences while at it. --- man/custom-entities.ent.in | 6 +++--- man/systemd-system.conf.xml | 10 +++++----- man/vconsole.conf.xml | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/man/custom-entities.ent.in b/man/custom-entities.ent.in index 9ec6ef92cc..6338ad13f9 100644 --- a/man/custom-entities.ent.in +++ b/man/custom-entities.ent.in @@ -15,8 +15,8 @@ - - - + + + diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index d3c345dbb4..b7fe53dc9c 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -581,9 +581,9 @@ DefaultTimeoutStartSec= and DefaultTimeoutStopSec= - default to &DEFAULT_TIMEOUT; in the system manager and &DEFAULT_USER_TIMEOUT; in the user manager. - DefaultTimeoutAbortSec= is not set by default so that all units fall back to - TimeoutStopSec=. DefaultRestartSec= defaults to 100 ms. + default to &DEFAULT_TIMEOUT_SEC; in the system manager and &DEFAULT_USER_TIMEOUT_SEC; in the user + manager. DefaultTimeoutAbortSec= is not set by default so that all units fall back + to TimeoutStopSec=. DefaultRestartSec= defaults to 100 ms. @@ -597,8 +597,8 @@ and /etc/crypttab (see systemd.mount5, crypttab5). - Defaults to &DEFAULT_TIMEOUT; in the system manager and &DEFAULT_USER_TIMEOUT; in the user manager. - + Defaults to &DEFAULT_TIMEOUT_SEC; in the system manager and &DEFAULT_USER_TIMEOUT_SEC; in the user + manager. diff --git a/man/vconsole.conf.xml b/man/vconsole.conf.xml index 5b3524d729..e5e160cf3d 100644 --- a/man/vconsole.conf.xml +++ b/man/vconsole.conf.xml @@ -75,11 +75,11 @@ KEYMAP= KEYMAP_TOGGLE= - Configures the key mapping table for the keyboard. KEYMAP= - defaults to &DEFAULT_KEYMAP; if not set. Specially, if @kernel - is specified, no keymap will be loaded, i.e. the kernel's default keymap is used. The - KEYMAP_TOGGLE= can be used to configure a second toggle keymap and is by default - unset. + Configures the key mapping table for the keyboard. KEYMAP= + defaults to &SYSTEMD_DEFAULT_KEYMAP; if not set. As a special case, if + @kernel is specified, no keymap will be loaded, i.e. the kernel's default keymap + will be used. The KEYMAP_TOGGLE= can be used to configure a second toggle keymap + and is by default unset. From 7af88c1e1ef9e9549671e7d8e45c10964aad2b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Nov 2025 15:43:34 +0100 Subject: [PATCH 3/5] journald: allow default storage mode to be configured So far the idea was that the default is 'auto', and if appropriate, the distribution will create /var/log/journal/ to tell journald to use persistent mode. This doesn't work well with factory resets, because after a factory reset obviously /var/log is gone. That old default was useful when journald was new and people were reluctant to enable persistent mode and instead relied on rsyslog and such for the persistent storage. But nowadays that is rarer, and anyway various features like user journals only work with persistent storage, so we want people to enable this by default. Add an option to flip the default and distributions can opt in. The default default value remains unchanged. (I also tested using tmpfiles to instead change this, since we already set access mode for /var/log/journal through tmpfiles. Unfortunately, tmpfiles runs too late, after journald has already started, so if tmpfiles creates the directory, it'll only be used after a reboot. This probably could be made to work by adding a new service to flush the journal, but that becomes complicated and we lose the main advantage of simplicity.) Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1387796. --- man/custom-entities.ent.in | 1 + man/journald.conf.xml | 10 +++++++--- meson.build | 4 ++++ meson_options.txt | 2 ++ src/journal/journald-config.c | 2 +- src/journal/journald.conf.in | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/man/custom-entities.ent.in b/man/custom-entities.ent.in index 6338ad13f9..1f3ecefe61 100644 --- a/man/custom-entities.ent.in +++ b/man/custom-entities.ent.in @@ -10,6 +10,7 @@ + diff --git a/man/journald.conf.xml b/man/journald.conf.xml index 1d615b110d..322fe6d17b 100644 --- a/man/journald.conf.xml +++ b/man/journald.conf.xml @@ -1,6 +1,9 @@ + "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ + +%entities; +]> /var/log/journal directory exists, and volatile otherwise (the existence of the directory controls the storage mode). none turns off all storage, all log data received will be dropped (but forwarding to other targets, such as the console, - the kernel log buffer, or a syslog socket will still work). Defaults to auto in - the default journal namespace, and persistent in all others. + the kernel log buffer, or a syslog socket will still work). Defaults to + &JOURNAL_STORAGE_DEFAULT; in the default journal namespace (this value is + determined at compilation time), and persistent in all others. Note that journald will initially use volatile storage, until a call to journalctl --flush (or sending SIGUSR1 to journald) will cause diff --git a/meson.build b/meson.build index 599d2a3217..055ee31ee4 100644 --- a/meson.build +++ b/meson.build @@ -117,6 +117,9 @@ conf.set10('BUMP_PROC_SYS_FS_FILE_MAX', get_option('bump-proc-sys-fs-file-max')) conf.set10('BUMP_PROC_SYS_FS_NR_OPEN', get_option('bump-proc-sys-fs-nr-open')) conf.set('HIGH_RLIMIT_NOFILE', 512*1024) +conf.set('JOURNAL_STORAGE_DEFAULT', get_option('journal-storage-default')) +conf.set('JOURNAL_STORAGE_DEFAULT_VAL', 'STORAGE_' + get_option('journal-storage-default').to_upper()) + # Meson ignores the preceding arguments when joining paths if an absolute # component is encountered, so this should canonicalize various paths when they # are absolute or relative. @@ -3096,6 +3099,7 @@ summary({ 'default locale' : default_locale, 'default nspawn locale' : nspawn_locale, 'default status unit format' : status_unit_format_default, + 'default journal storage mode' : conf.get('JOURNAL_STORAGE_DEFAULT'), 'default user $PATH' : default_user_path != '' ? default_user_path : '(same as system services)', 'systemd service watchdog' : service_watchdog == '' ? 'disabled' : service_watchdog, 'time epoch' : f'@time_epoch@ (@alt_time_epoch@)', diff --git a/meson_options.txt b/meson_options.txt index 1d7c4f4bd2..f8a0fe3712 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -139,6 +139,8 @@ option('timedated', type : 'boolean', description : 'install the systemd-timedated daemon') option('timesyncd', type : 'boolean', description : 'install the systemd-timesyncd daemon') +option('journal-storage-default', type : 'combo', choices : ['auto', 'volatile', 'persistent', 'none'], + description : 'default storage mode for journald (main namespace)') option('remote', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'support for "journal over the network"') option('create-log-dirs', type : 'boolean', diff --git a/src/journal/journald-config.c b/src/journal/journald-config.c index 8cffec880b..de78a40008 100644 --- a/src/journal/journald-config.c +++ b/src/journal/journald-config.c @@ -116,7 +116,7 @@ void manager_merge_configs(Manager *m) { journal_config_done(&m->config); - MERGE_NON_NEGATIVE(storage, STORAGE_AUTO); + MERGE_NON_NEGATIVE(storage, JOURNAL_STORAGE_DEFAULT_VAL); manager_merge_journal_compress_options(m); MERGE_NON_NEGATIVE(seal, true); /* By default, /dev/kmsg is read only by the main namespace instance. */ diff --git a/src/journal/journald.conf.in b/src/journal/journald.conf.in index 9a12ca7657..805b79bc8a 100644 --- a/src/journal/journald.conf.in +++ b/src/journal/journald.conf.in @@ -17,7 +17,7 @@ # See journald.conf(5) for details. [Journal] -#Storage=auto +#Storage={{ JOURNAL_STORAGE_DEFAULT }} #Compress=yes #Seal=yes #SplitMode=uid From 238bb65c0fd95ee3d6331d27c993b01e2103861b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Nov 2025 16:51:21 +0100 Subject: [PATCH 4/5] meson: make persistent journal the default --- NEWS | 6 ++++++ meson_options.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 26148ce1c7..10f8bffd23 100644 --- a/NEWS +++ b/NEWS @@ -19,6 +19,12 @@ CHANGES WITH 259 in spe: command to add recovery keys to existing user accounts. Previously, recovery keys could only be configured during initial user creation. + * The default storage mode for the journal is now 'persistent'. + Previously, the default was 'auto', so the presence or lack of + /var/log/journal determined the default storage mode, if no + overriding configuration was provided. The default can be changed + with -Djournal-storage-default=. + CHANGES WITH 258: Incompatible changes: diff --git a/meson_options.txt b/meson_options.txt index f8a0fe3712..4ce3c7faca 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -139,7 +139,7 @@ option('timedated', type : 'boolean', description : 'install the systemd-timedated daemon') option('timesyncd', type : 'boolean', description : 'install the systemd-timesyncd daemon') -option('journal-storage-default', type : 'combo', choices : ['auto', 'volatile', 'persistent', 'none'], +option('journal-storage-default', type : 'combo', choices : ['persistent', 'auto', 'volatile', 'none'], description : 'default storage mode for journald (main namespace)') option('remote', type : 'feature', deprecated : { 'true' : 'enabled', 'false' : 'disabled' }, description : 'support for "journal over the network"') From 2eaceed0b14228ad27b369db0ff3a9c8c45fb13e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 7 Nov 2025 17:04:03 +0100 Subject: [PATCH 5/5] 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. --- src/journal/journald-config.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/journal/journald-config.c b/src/journal/journald-config.c index de78a40008..b524379b5c 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. */