]> git.proxmox.com Git - mirror_lxc.git/commit
start: rework ns sharing + add userns sharing
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 29 Oct 2017 22:11:22 +0000 (23:11 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 3 Nov 2017 07:37:09 +0000 (08:37 +0100)
commitfa3a5b220528f55c0e7eae4b708729256e71397c
tree5228d4ff91a8b84f90d689519a91904a28f114bb
parent2469f9b65e46b559e51ebeb3d1f6107f5408cfcf
start: rework ns sharing + add userns sharing

- Implement inheriting user namespaces.
  - When inheriting user namespaces make sure to not try and map ids again. The
    kernel will not allow you to do this.
- Change clone() logic:
  1. If we inherit no namespaces simply call lxc_clone().
  2. If we inherit any namespaces call lxc_fork_attach_clone(). Here's why:
     - Causes one syscall (fork()) instead of two syscalls (setns() to
       inherited namespace and setns() back to parent namespace) to be
       performed.
     - Allows us to get rid of a bunch of variables and helper functions/code.
     - Sharing a user namespaces requires us to setns() to the inherited user
       namespace but the kernel does not allow reattaching to a parent user
       namespace. So the old logic made user namespace inheritance impossible.
       By using the lxc_fork_attach_clone() model we can simply setns() to the
       inherited user namespace in the fork()ed child and be done with it.
       The only thing we need to do is to specify CLONE_PARENT when calling
       clone() in lxc_fork_attach_clone() so that we can wait on the child.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c