[Buildroot] [PATCH v3] package/openssh: Add tmpfiles.d snippet to create /var/empty

Chris Lesiak chris.lesiak at licor.com
Fri Feb 16 18:11:41 UTC 2018


The openssh privilege separation feature, enabled by default,
requires that the path /var/empty exist; see README.privsep
included as part of the openssh distribution.

On a volatile or stateless system, that path might not exist.
Use systemd-tmpfiles (if enabled) to ensure that the path exists
and has the correct permissions.

Signed-off-by: Chris Lesiak <chris.lesiak at licor.com>
---
Changes v2 --> v3
  - Provide a more detailed explanation as suggested by
    Arnout Vandecappelle<arnout at mind.be>.
  - Only bother if BR2_PACKAGE_SYSTEMD_TMPFILES=y
Changes v1 --> v2
  - Use 0755 as the permission of /var/empty as suggested by
    Samual Martin <s.martin49 at gmail.com> and the README.privsep
    included with openssh-7.6p1.
---
 package/openssh/openssh.mk        | 8 ++++++++
 package/openssh/ssh_tmpfiles.conf | 1 +
 2 files changed, 9 insertions(+)
 create mode 100644 package/openssh/ssh_tmpfiles.conf

diff --git a/package/openssh/openssh.mk b/package/openssh/openssh.mk
index 5d099ceb13..cdafdedae4 100644
--- a/package/openssh/openssh.mk
+++ b/package/openssh/openssh.mk
@@ -67,6 +67,13 @@ define OPENSSH_INSTALL_SYSTEMD_SYSUSERS
 endef
 endif
 
+ifeq ($(BR2_PACKAGE_SYSTEMD_TMPFILES),y)
+define OPENSSH_INSTALL_SYSTEMD_TMPFILES
+	$(INSTALL) -m 0644 -D package/openssh/ssh_tmpfiles.conf \
+		$(TARGET_DIR)/usr/lib/tmpfiles.d/ssh.conf
+endef
+endif
+
 define OPENSSH_INSTALL_INIT_SYSTEMD
 	$(INSTALL) -D -m 644 package/openssh/sshd.service \
 		$(TARGET_DIR)/usr/lib/systemd/system/sshd.service
@@ -74,6 +81,7 @@ define OPENSSH_INSTALL_INIT_SYSTEMD
 	ln -fs ../../../../usr/lib/systemd/system/sshd.service \
 		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/sshd.service
 	$(OPENSSH_INSTALL_SYSTEMD_SYSUSERS)
+	$(OPENSSH_INSTALL_SYSTEMD_TMPFILES)
 endef
 
 define OPENSSH_INSTALL_INIT_SYSV
diff --git a/package/openssh/ssh_tmpfiles.conf b/package/openssh/ssh_tmpfiles.conf
new file mode 100644
index 0000000000..ca2a393542
--- /dev/null
+++ b/package/openssh/ssh_tmpfiles.conf
@@ -0,0 +1 @@
+d /var/empty 0755 root root
-- 
2.14.3



More information about the buildroot mailing list