[lxc-devel] [lxc/lxc] 7a8060: Revert "rexec: remove needless /proc/cmdline parsing"

Stéphane Graber noreply at github.com
Thu Feb 14 15:58:12 UTC 2019


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 7a80606d7b3e31516d3cb223c899be25e67cbc0d
      https://github.com/lxc/lxc/commit/7a80606d7b3e31516d3cb223c899be25e67cbc0d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2019-02-14 (Thu, 14 Feb 2019)

  Changed paths:
    M src/lxc/rexec.c
    M src/lxc/rexec.h
    M src/lxc/tools/lxc_attach.c

  Log Message:
  -----------
  Revert "rexec: remove needless /proc/cmdline parsing"

The ELF binary spec does specify in [1]:

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means libcs other than glibc might not pass down argc and argv to
constructors.

This reverts commit 0c816b346788afa9d601766e31544fdcce67d780.

[1]: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

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


  Commit: cee55b59cd0f7446bae25d02bcd23805ce43aaa4
      https://github.com/lxc/lxc/commit/cee55b59cd0f7446bae25d02bcd23805ce43aaa4
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2019-02-14 (Thu, 14 Feb 2019)

  Changed paths:
    M src/lxc/rexec.c

  Log Message:
  -----------
  rexec: remove envp parsing in favour of environ

My first attempt to simplify this and make it less costly focussed on
the way constructors are called. I was under the impression that the ELF
specification mandated that arg, argv, and actually even envp need to be
passed to functions located in the .init_array section (aka
"constructors"). Actually, the specifications is (cf. [2]):

SHT_INIT_ARRAY
This section contains an array of pointers to initialization functions,
as described in ``Initialization and Termination Functions'' in Chapter
5. Each pointer in the array is taken as a parameterless procedure with
a void return.

which means that this becomes a libc specific decision. Glibc passes
down those args, musl doesn't. So this approach can't work. However, we
can at least remove the environment parsing part based on POSIX since
[1] mandates that there should be an environ variable defined in
unistd.h which provides access to the environment. See also the relevant
Open Group specification [1].

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/
[2]: http://www.sco.com/developers/gabi/latest/ch4.sheader.html#init_array

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


  Commit: 2cd64122513b73d84e67dd20566e39525ec7f0cf
      https://github.com/lxc/lxc/commit/2cd64122513b73d84e67dd20566e39525ec7f0cf
  Author: Stéphane Graber <stgraber at stgraber.org>
  Date:   2019-02-14 (Thu, 14 Feb 2019)

  Changed paths:
    M src/lxc/rexec.c
    M src/lxc/rexec.h
    M src/lxc/tools/lxc_attach.c

  Log Message:
  -----------
  Merge pull request #2852 from brauner/2019-02-14/revert_simplify_argv_parsing

rexec: cmdline and environ parsing improvements


Compare: https://github.com/lxc/lxc/compare/257e396bed4d...2cd64122513b


More information about the lxc-devel mailing list