浏览代码

package/systemd: handle creation of /var/log/journal

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 don't want your
log duplicated and journald should be tuned to account for
having only RAM available.

With this commit, the directory will no longer be created automatically,
but instead it's created only if the root filesystem is writeable.

It is rather easy for users to opt-in by either creating that directory
(e.g. with a tmpfiles fragment) or editing /etc/systemd/journald.conf.

Signed-off-by: Norbert Lange <nolange79@gmail.com>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
Norbert Lange 2 年之前
父节点
当前提交
23c5fe7909
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      package/systemd/systemd.mk

+ 7 - 0
package/systemd/systemd.mk

@@ -63,6 +63,7 @@ SYSTEMD_SELINUX_MODULES = systemd udev xdg
 SYSTEMD_PROVIDES = udev
 SYSTEMD_PROVIDES = udev
 
 
 SYSTEMD_CONF_OPTS += \
 SYSTEMD_CONF_OPTS += \
+	-Dcreate-log-dirs=false \
 	-Ddbus=false \
 	-Ddbus=false \
 	-Ddbus-interfaces-dir=no \
 	-Ddbus-interfaces-dir=no \
 	-Ddefault-compression='auto' \
 	-Ddefault-compression='auto' \
@@ -111,6 +112,10 @@ ifeq ($(BR2_nios2),y)
 SYSTEMD_LDFLAGS = $(TARGET_LDFLAGS) -Wl,--no-fatal-warnings
 SYSTEMD_LDFLAGS = $(TARGET_LDFLAGS) -Wl,--no-fatal-warnings
 endif
 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)
 ifeq ($(BR2_PACKAGE_ACL),y)
 SYSTEMD_DEPENDENCIES += acl
 SYSTEMD_DEPENDENCIES += acl
 SYSTEMD_CONF_OPTS += -Dacl=true
 SYSTEMD_CONF_OPTS += -Dacl=true
@@ -621,6 +626,7 @@ define SYSTEMD_PERMISSIONS
 	/var/lib/private d 700 0 0 - - - - -
 	/var/lib/private d 700 0 0 - - - - -
 	/var/log/private d 700 0 0 - - - - -
 	/var/log/private d 700 0 0 - - - - -
 	/var/cache/private d 700 0 0 - - - - -
 	/var/cache/private d 700 0 0 - - - - -
+	$(SYSTEMD_JOURNALD_PERMISSIONS)
 	$(SYSTEMD_LOGIND_PERMISSIONS)
 	$(SYSTEMD_LOGIND_PERMISSIONS)
 	$(SYSTEMD_MACHINED_PERMISSIONS)
 	$(SYSTEMD_MACHINED_PERMISSIONS)
 	$(SYSTEMD_HOMED_PERMISSIONS)
 	$(SYSTEMD_HOMED_PERMISSIONS)
@@ -800,6 +806,7 @@ HOST_SYSTEMD_CONF_OPTS = \
 	--libdir=lib \
 	--libdir=lib \
 	--sysconfdir=/etc \
 	--sysconfdir=/etc \
 	--localstatedir=/var \
 	--localstatedir=/var \
+	-Dcreate-log-dirs=false \
 	-Dmode=release \
 	-Dmode=release \
 	-Dutmp=false \
 	-Dutmp=false \
 	-Dhibernate=false \
 	-Dhibernate=false \