diff mbox series

[6/7] package/systemd: handle creation of /var/log/journal

Message ID 20230115125253.280257-7-nolange79@gmail.com
State Accepted
Headers show
Series Extent options for read-only /var handling | expand

Commit Message

Norbert Lange Jan. 15, 2023, 12:52 p.m. UTC
journald will always have a runtime log in /run/systemd/journal,
and a persistent one in /var/log/journal under certain conditions.
By default it will check for the existence of that directory.

When /var is not backed by mass-storage you typically dont want your
log duplicated and journald should be tuned to account for
having only RAM available.

Buildroot will now create this directory conditionally together with
it's handling of /var under a read-only filesystem.

It is rather easy for users to opt-in by either creating that directory
or editing /etc/systemd/journald.conf.

Signed-off-by: Norbert Lange <nolange79@gmail.com>
---
 package/systemd/systemd.mk | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Arnout Vandecappelle Oct. 10, 2023, 8:33 p.m. UTC | #1
On 15/01/2023 13:52, Norbert Lange wrote:
> journald will always have a runtime log in /run/systemd/journal,
> and a persistent one in /var/log/journal under certain conditions.
> By default it will check for the existence of that directory.
> 
> When /var is not backed by mass-storage you typically dont want your
> log duplicated and journald should be tuned to account for
> having only RAM available.
> 
> Buildroot will now create this directory conditionally together with
> it's handling of /var under a read-only filesystem.

  The patch now only creates the directory if rootfs-rw is enabled.

  This is actually not great IMHO - we have too many things hinging on that 
config setting that give meaning to it which doesn't really exist. Still, 
there's no better way to do it, really.


> It is rather easy for users to opt-in by either creating that directory
> or editing /etc/systemd/journald.conf.

  We really should have documentation of how to do this, and a runtime test that 
proves that it works.

  But OK, I anyway already committed this to master, thanks.

  Regards,
  Arnout

> 
> Signed-off-by: Norbert Lange <nolange79@gmail.com>
> ---
>   package/systemd/systemd.mk | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
> index b96873b73f..420197005c 100644
> --- a/package/systemd/systemd.mk
> +++ b/package/systemd/systemd.mk
> @@ -61,6 +61,7 @@ SYSTEMD_SELINUX_MODULES = systemd udev xdg
>   SYSTEMD_PROVIDES = udev
>   
>   SYSTEMD_CONF_OPTS += \
> +	-Dcreate-log-dirs=false \
>   	-Ddefault-hierarchy=unified \
>   	-Didn=true \
>   	-Dima=false \
> @@ -100,6 +101,10 @@ ifeq ($(BR2_nios2),y)
>   SYSTEMD_LDFLAGS = $(TARGET_LDFLAGS) -Wl,--no-fatal-warnings
>   endif
>   
> +ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
> +SYSTEMD_JOURNALD_PERMISSIONS = /var/log/journal d 2755 root systemd-journal - - - - -
> +endif
> +
>   ifeq ($(BR2_PACKAGE_ACL),y)
>   SYSTEMD_DEPENDENCIES += acl
>   SYSTEMD_CONF_OPTS += -Dacl=true
> @@ -603,6 +608,7 @@ define SYSTEMD_PERMISSIONS
>   	/var/lib/private d 700 0 0 - - - - -
>   	/var/log/private d 700 0 0 - - - - -
>   	/var/cache/private d 700 0 0 - - - - -
> +	$(SYSTEMD_JOURNALD_PERMISSIONS)
>   	$(SYSTEMD_LOGIND_PERMISSIONS)
>   	$(SYSTEMD_MACHINED_PERMISSIONS)
>   	$(SYSTEMD_HOMED_PERMISSIONS)
> @@ -782,6 +788,7 @@ HOST_SYSTEMD_CONF_OPTS = \
>   	--libdir=lib \
>   	--sysconfdir=/etc \
>   	--localstatedir=/var \
> +	-Dcreate-log-dirs=false \
>   	-Dmode=release \
>   	-Dutmp=false \
>   	-Dhibernate=false \
diff mbox series

Patch

diff --git a/package/systemd/systemd.mk b/package/systemd/systemd.mk
index b96873b73f..420197005c 100644
--- a/package/systemd/systemd.mk
+++ b/package/systemd/systemd.mk
@@ -61,6 +61,7 @@  SYSTEMD_SELINUX_MODULES = systemd udev xdg
 SYSTEMD_PROVIDES = udev
 
 SYSTEMD_CONF_OPTS += \
+	-Dcreate-log-dirs=false \
 	-Ddefault-hierarchy=unified \
 	-Didn=true \
 	-Dima=false \
@@ -100,6 +101,10 @@  ifeq ($(BR2_nios2),y)
 SYSTEMD_LDFLAGS = $(TARGET_LDFLAGS) -Wl,--no-fatal-warnings
 endif
 
+ifeq ($(BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW),y)
+SYSTEMD_JOURNALD_PERMISSIONS = /var/log/journal d 2755 root systemd-journal - - - - -
+endif
+
 ifeq ($(BR2_PACKAGE_ACL),y)
 SYSTEMD_DEPENDENCIES += acl
 SYSTEMD_CONF_OPTS += -Dacl=true
@@ -603,6 +608,7 @@  define SYSTEMD_PERMISSIONS
 	/var/lib/private d 700 0 0 - - - - -
 	/var/log/private d 700 0 0 - - - - -
 	/var/cache/private d 700 0 0 - - - - -
+	$(SYSTEMD_JOURNALD_PERMISSIONS)
 	$(SYSTEMD_LOGIND_PERMISSIONS)
 	$(SYSTEMD_MACHINED_PERMISSIONS)
 	$(SYSTEMD_HOMED_PERMISSIONS)
@@ -782,6 +788,7 @@  HOST_SYSTEMD_CONF_OPTS = \
 	--libdir=lib \
 	--sysconfdir=/etc \
 	--localstatedir=/var \
+	-Dcreate-log-dirs=false \
 	-Dmode=release \
 	-Dutmp=false \
 	-Dhibernate=false \