[lxc-devel] [lxc/lxc] 73363c: conf: non-functional changes

GitHub noreply at github.com
Tue Sep 5 17:52:01 UTC 2017


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 73363c6134c61867ab304a35b233fd5b4d3bddc2
      https://github.com/lxc/lxc/commit/73363c6134c61867ab304a35b233fd5b4d3bddc2
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-09-05 (Tue, 05 Sep 2017)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  conf: non-functional changes

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 2187efd31051513ef0758b6eaa336894e69039f9
      https://github.com/lxc/lxc/commit/2187efd31051513ef0758b6eaa336894e69039f9
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-09-05 (Tue, 05 Sep 2017)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  conf: fix tty creation

We allocate pty {master,slave} file descriptors in the childs namespaces after
we have setup devpts. After we have sent the pty file descriptors to the parent
and set up the pty file descriptors under /dev/tty* and before we exec the init
binary we need to delete these file descriptors in the child. However, one of
my commits made the deletion occur before setting up the file descriptors under
/dev/tty*. This caused a failures when trying to attach to the container's ttys
since they werent actually configured although the file descriptors were
available in the in-memory configuration of the parent.
This commit reworks setting up tty such that deletion occurs after all setup
has been performed. The commit is actually minimal but needs to also move all
the functions into one place since they well now be called from
"lxc_create_ttys()".

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: da0f9977a1946bbb2c2ae7b3f23787e56fccf3a3
      https://github.com/lxc/lxc/commit/da0f9977a1946bbb2c2ae7b3f23787e56fccf3a3
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-09-05 (Tue, 05 Sep 2017)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  conf: do not log uninitialized memory

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 954b7d9bba7b4ac4200033ada6dc967c2ab9f290
      https://github.com/lxc/lxc/commit/954b7d9bba7b4ac4200033ada6dc967c2ab9f290
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2017-09-05 (Tue, 05 Sep 2017)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  conf: fix userns_exec_1()

A bit of context:
userns_exec_1() is only used to operate based on privileges for the user's own
{g,u}id on the host and for the container root's unmapped {g,u}id. This means
we require only to establish a mapping from:
- the container root {g,u}id as seen from the host -> user's host {g,u}id
- the container root -> some sub{g,u}id

This function however was buggy. It relied on some pointer pointing to the same
memory, namely specific idmap entries in the idmap list in the container's
in-memory configuration. However, due to a stupid mistake of mine, the pointers
to be compared pointed to freshly allocated memory. They were never pointing to
the intended memory locations. To reproduce what I'm talking about prior to
this commit simply place:

    chb:999:1000000000
    chb:999:1
    chb:1000:1

in /etc/sub{g,u}id then create a container which requests the following
idmappings:

    lxc.idmap = u 0 999 999
    lxc.idmap = g 0 999 1000000000

and start the container. What we *would expect* is for liblxc to establish the
following mapping:

    newuidmap <pid> 0 999 999
    newgidmap <pid> 0 999 1000000000

since all required mappings are present. Due to the buggy pointer comparisons
what happened was:

    newuidmap <pid> 0 999 999 0 999 999
    newgidmap <pid> 0 999 1000000000 0 999 1000000000

Let's fix this.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 9f520fee3635b3c6e7420f2f1d36084380378d99
      https://github.com/lxc/lxc/commit/9f520fee3635b3c6e7420f2f1d36084380378d99
  Author: Serge Hallyn <serge at hallyn.com>
  Date:   2017-09-05 (Tue, 05 Sep 2017)

  Changed paths:
    M src/lxc/conf.c

  Log Message:
  -----------
  Merge pull request #1788 from brauner/2017-09-05/fix_tty_creation

conf: bugfixes


Compare: https://github.com/lxc/lxc/compare/8a0c5033441d...9f520fee3635


More information about the lxc-devel mailing list