1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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
@@ -553,6 +553,10 @@ 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 },
{ "/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,
|