1. 01 Jul, 2021 6 commits
    • conf: improve read-only /sys with read-write /sys/devices/virtual/net · e250f278
      Christian Brauner authored
      Some tools require /sys/devices/virtual/net to be read-write. At the
      same time we want all other parts of /sys to be read-only. To do this we
      created a layout where we hade a read-only instance of sysfs mounted on
      top of a read-write instance of sysfs:
      
      `-/sys                                  sysfs                                                        sysfs      rw,nosuid,nodev,noexec,relatime
        `-/sys                                sysfs                                                        sysfs      ro,nosuid,nodev,noexec,relatime
          |-/sys/devices/virtual/net          sysfs                                                        sysfs      rw,relatime
          | `-/sys/devices/virtual/net        sysfs[/devices/virtual/net]                                  sysfs      rw,nosuid,nodev,noexec,relatime
      
      This causes issues for systemd services that create a separate mount
      namespace as they get confused to what mount options need to be
      respected.
      
      Simplify our mounting logic so we end up with a single read-only mount
      of sysfs on /sys and a read-write bind-mount of /sys/devices/virtual/net:
      
      ├─/sys                                sysfs                                                                                  sysfs         ro,nosuid,nodev,noexec,relatime
      │ ├─/sys/devices/virtual/net          sysfs[/devices/virtual/net]                                                            sysfs         rw,nosuid,nodev,noexec,relatime
      
      Link: systemd/systemd#20032
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
    • initutils: close dirfd in error path · c73a2325
      Simon Deziel authored
      Signed-off-by: 's avatarSimon Deziel <simon.deziel@canonical.com>
    • execute: ensure parent is notified about child exec and close all unneeded fds · 0a953196
      Christian Brauner authored
      lxc_container_init() creates the container payload process as it's child
      so lxc_container_init() itself never really exits and thus the parent
      isn't notified about the child exec'ing since the sync file descriptor
      is never closed. Make sure it's closed to notify the parent about the
      child's exec.
      
      In addition we're currently leaking all file descriptors associated with
      the handler into the stub init. Make sure that all file descriptors
      other than stderr are closed.
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
    • initutils: use vfork() in lxc_container_init() · 91ee6c8b
      Christian Brauner authored
      We can let the child finish calling exec before continuing in the
      parent.
      Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
    • execute: don't exec init, call it · a4295196
      Tycho Andersen authored
      Instead of having a statically linked init that we put on the host fs
      somewhere via packaging, have to either bind mount in or detect fexecve()
      functionality, let's just call it as a library function. This way we don't
      have to do any of that.
      
      This also fixes up a bunch of conditions from:
      
      if (quiet)
          fprintf(stderr, "log message");
      
      to
      
      if (!quiet)
          fprintf(stderr, "log message");
      
      :)
      
      and it drops all the code for fexecve() detection and bind mounting our
      init in, since we no longer need any of that.
      
      A couple other thoughts:
      
      * I left the lxc-init binary in since we ship it, so someone could be using
        it outside of the internal uses.
      * There are lots of unused arguments to lxc-init (including presumably
        --quiet, since nobody noticed the above); those may be part of the API
        though and so we don't want to drop them.
      Signed-off-by: 's avatarTycho Andersen <tycho@tycho.pizza>
  2. 29 Jun, 2021 12 commits
  3. 14 Jun, 2021 5 commits
  4. 08 Jun, 2021 3 commits
  5. 28 May, 2021 14 commits