1
0
Fork 0

Mounting /etc/hostname as /run/host/hostname in systemd-nspawn container.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
This commit is contained in:
Daniel Baumann 2025-06-25 18:10:45 +02:00
parent ae96d061a6
commit 51334545e5
Signed by: daniel.baumann
GPG key ID: BCC918A2ABD66424
2 changed files with 20 additions and 0 deletions

View file

@ -0,0 +1,19 @@
Author: Daniel Baumann <daniel.baumann@progress-linux.org>
Description: Mount /etc/hostname as /run/host/hostname in systemd-nspawn container.
diff -Naurp systemd.orig/src/nspawn/nspawn-mount.c systemd/src/nspawn/nspawn-mount.c
--- systemd.orig/src/nspawn/nspawn-mount.c
+++ systemd/src/nspawn/nspawn-mount.c
@@ -607,6 +607,12 @@ int mount_all(const char *dest,
MOUNT_FATAL|MOUNT_MKDIR },
{ "/run/host", "/run/host", NULL, NULL, MS_BIND,
MOUNT_FATAL|MOUNT_MKDIR|MOUNT_PREFIX_ROOT }, /* Prepare this so that we can make it read-only when we are done */
+ { "/etc/hostname", "/run/host/hostname", NULL, NULL, MS_BIND,
+ MOUNT_TOUCH }, /* As per kernel interface requirements, bind mount first (creating mount points) and make read-only later */
+ { NULL, "/run/host/hostname", NULL, NULL, MS_BIND|MS_RDONLY|MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_REMOUNT,
+ MOUNT_FATAL },
+ { NULL, "/run/host/hostname", NULL, NULL, MS_PRIVATE,
+ MOUNT_FATAL }, /* Turn off propagation (we only want that for the mount propagation tunnel dir) */
{ "/etc/os-release", "/run/host/os-release", NULL, NULL, MS_BIND,
MOUNT_TOUCH }, /* As per kernel interface requirements, bind mount first (creating mount points) and make read-only later */
{ "/usr/lib/os-release", "/run/host/os-release", NULL, NULL, MS_BIND,

View file

@ -2,3 +2,4 @@ progress-linux/0001-agetty-nohostname.patch
progress-linux/0002-logind-noautovts.patch
progress-linux/0003-logind-reservevt.patch
progress-linux/0004-proc-hidepid.patch
progress-linux/0005-nspawn-hostname.patch