From 7e8aa95e439761d21c8667e503522a21b027a376 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Sun, 21 Feb 2016 01:16:15 -0500 Subject: [PATCH] Fix sshd template on systems with systemd Systems with systemd have /sbin/init as a symlink pointing to real init. Sshd template tries to bind-mount special init implementation. The problem is that one cannot bind-mount to a location that is a symlink. Fix this by deferencing /sbin/init symling and using that as bind-mount location. Signed-off-by: Nikolay Martynov --- templates/lxc-sshd.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/lxc-sshd.in b/templates/lxc-sshd.in index d34b3b455..9b07ea600 100644 --- a/templates/lxc-sshd.in +++ b/templates/lxc-sshd.in @@ -125,6 +125,8 @@ copy_configuration() rootfs=$2 name=$3 + init_path=$(realpath --relative-to=/ $(readlink -f /sbin/init)) + grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config cat <> $path/config lxc.utsname = $name @@ -140,7 +142,7 @@ lxc.mount.entry = /bin bin none ro,bind 0 0 lxc.mount.entry = /usr usr none ro,bind 0 0 lxc.mount.entry = /sbin sbin none ro,bind 0 0 lxc.mount.entry = tmpfs var/run/sshd tmpfs mode=0644 0 0 -lxc.mount.entry = @LXCTEMPLATEDIR@/lxc-sshd sbin/init none ro,bind 0 0 +lxc.mount.entry = @LXCTEMPLATEDIR@/lxc-sshd $init_path none ro,bind 0 0 lxc.mount.entry = /etc/init.d etc/init.d none ro,bind 0 0 lxc.mount.auto = cgroup:mixed proc:mixed sys:mixed -- 2.47.2