]> git.proxmox.com Git - pve-container.git/commitdiff
lxc_config: mount /sys as mixed for unprivileged by default
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 18 Mar 2020 09:46:17 +0000 (10:46 +0100)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 19 Mar 2020 08:17:47 +0000 (09:17 +0100)
CONTAINER_INTERFACE[0] is something systemd people call their API and
we need to adapt to it a bit, even if it means doing stupid
unnecessary things, as else systemd decides to regress and suddenly
break network stack in CT after an upgrade[1].

This mounts the parent /sys as mixed, which is:
> mount /sys as read-only but with /sys/devices/virtual/net writable.
-- man 5 lxc.container.conf

Allow users to overwrite that with a features knob, as surely some
run into other issues else and manually adding a "lxc.mount.auto"
entry in the container .conf is not an nice user experience for most.

Fixes the system regression in up to date Arch installations
introduced by[2].

[0]: https://systemd.io/CONTAINER_INTERFACE/
[1]: https://github.com/systemd/systemd/issues/15101#issuecomment-598607582
[2]: https://github.com/systemd/systemd/commit/bf331d87171b7750d1c72ab0b140a240c0cf32c3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/PVE/LXC.pm
src/PVE/LXC/Config.pm

index 0742a53acfa07f60ed451930cbc250504e3889c7..df52afada999f9d01e10c52230f8bc699ecb74a7 100644 (file)
@@ -662,6 +662,12 @@ sub update_lxc_config {
        $raw .= "lxc.mount.entry = /dev/fuse dev/fuse none bind,create=file 0 0\n";
     }
 
+    if ($unprivileged && !$features->{force_rw_sys}) {
+       # unpriv. CT default to sys:rw, but that doesn't always plays well with
+       # systemd, e.g., systemd-networkd https://systemd.io/CONTAINER_INTERFACE/
+       $raw .= "lxc.mount.auto = sys:mixed\n";
+    }
+
     # WARNING: DO NOT REMOVE this without making sure that loop device nodes
     # cannot be exposed to the container with r/w access (cgroup perms).
     # When this is enabled mounts will still remain in the monitor's namespace
index e88ba0b733369028dadd06d81aae171b271da226..0909773f312432526d2f64f5ca42e1f06681b437 100644 (file)
@@ -331,6 +331,13 @@ my $features_desc = {
            ." This requires a kernel with seccomp trap to user space support (5.3 or newer)."
            ." This is experimental.",
     },
+    force_rw_sys => {
+       optional => 1,
+       type => 'boolean',
+       default => 0,
+       description => "Mount /sys in unprivileged containers as `rw` instead of `mixed`."
+           ." This can break networking under newer (>= v245) systemd-network use."
+    },
 };
 
 my $confdesc = {