chiark / gitweb /
nspawn: fallback on bind mount when mknod fails
authorAlban Crequy <alban@endocode.com>
Tue, 31 Mar 2015 15:14:48 +0000 (17:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 31 Mar 2015 15:21:03 +0000 (17:21 +0200)
commit81f5049b7c35752182e855cdb06d707db92d7ac8
tree8043f5c94ac2053b0f6296b1ec61329fb9409932
parent4f923a1984476de3441922ee5bf7102ebdd250ef
nspawn: fallback on bind mount when mknod fails

Some systems abusively restrict mknod, even when the device node already
exists in /dev. This is unfortunate because it prevents systemd-nspawn
from creating the basic devices in /dev in the container.

This patch implements a workaround: when mknod fails, fallback on bind
mounts.

Additionally, /dev/console was created with a mknod with the same
major/minor as /dev/null before bind mounting a pts on it. This patch
removes the mknod and creates an empty regular file instead.

In order to test this patch, I used the following configuration, which I
think should replicate the system with the abusive restriction on mknod:

  # grep devices /proc/self/cgroup
  4:devices:/user.slice/restrict
  # cat /sys/fs/cgroup/devices/user.slice/restrict/devices.list
  c 1:9 r
  c 5:2 rw
  c 136:* rw
  # systemd-nspawn --register=false -D .

v2:
 - remove "bind", it is not needed since there is already MS_BIND
v3:
 - fix error management when calling touch()
 - fix lowercase in error message
src/nspawn/nspawn.c