[lxc-devel] Inconsistency in clearenv() between command line and API

Stéphane Graber stgraber at ubuntu.com
Mon Feb 18 18:36:45 UTC 2013


Hey Serge,

Updating some production servers to newer IRC I noticed a slight
breakage with the clearenv() change introduced a month or so ago.

We typically want clearenv() to happen just before the final exec so
that we still have the existing environment for anything before that,
most importantly the hooks.

This appears to be the case for the command line tools but not for the
API. With the API, it looks like the clearenv() is done before the hooks
run.

Here's the environment as I get it from a mount hook when using lxc-start:
SUDO_GID=200512
MAIL=/var/mail/root
LANGUAGE=en_US:en
USER=root
HOME=/home/stgraber
COLORTERM=gnome-terminal
SUDO_UID=201105
LOGNAME=root
TERM=xterm
USERNAME=root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LXC_ROOTFS_MOUNT=/usr/lib/x86_64-linux-gnu/lxc
DISPLAY=:0
LXC_CONFIG_FILE=/var/lib/lxc/precise-gui/config
LANG=en_US.UTF-8
XAUTHORITY=/home/stgraber/.Xauthority
SUDO_COMMAND=/usr/bin/lxc-start -n precise-gui
KRB5CCNAME=FILE:/tmp/krb5cc_201105_Lrlyri
SHELL=/bin/bash
SUDO_USER=stgraber
PWD=/home/stgraber/data/vm/lxc/lib
LXC_ROOTFS_PATH=/var/lib/lxc/precise-gui/rootfs
LXC_NAME=precise-gui

And same container but started from the API:
container=lxc
LXC_ROOTFS_MOUNT=/usr/lib/x86_64-linux-gnu/lxc
LXC_CONFIG_FILE=/var/lib/lxc/precise-gui/config
PWD=/
LXC_ROOTFS_PATH=/var/lib/lxc/precise-gui/rootfs
LXC_NAME=precise-gui


The biggest problem here is the absence of PATH, making my hooks fail.
For now I simply hardcoded PATH, but I think we'll want to make the
environment from the API match that of lxc-start and find a way of
moving clearenv a bit closer to the final exec there too.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 901 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130218/2d4797fa/attachment.pgp>


More information about the lxc-devel mailing list