mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-08-16 11:01:26 +00:00
Merge pull request #1809 from brauner/2017-09-12/start_move_env_setup
start: set environment variables correctly
This commit is contained in:
commit
dbac6c0256
@ -913,16 +913,10 @@ static int do_start(void *data)
|
|||||||
INFO("Unshared CLONE_NEWCGROUP.");
|
INFO("Unshared CLONE_NEWCGROUP.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The clearenv() and putenv() calls have been moved here to allow us to
|
/* Add the requested environment variables to the current environment to
|
||||||
* use environment variables passed to the various hooks, such as the
|
* allow them to be used by the various hooks, such as the start hook
|
||||||
* start hook above. Not all of the variables like CONFIG_PATH or ROOTFS
|
* above.
|
||||||
* are valid in this context but others are.
|
|
||||||
*/
|
*/
|
||||||
if (clearenv()) {
|
|
||||||
SYSERROR("Failed to clear environment.");
|
|
||||||
/* Don't error out though. */
|
|
||||||
}
|
|
||||||
|
|
||||||
lxc_list_for_each(iterator, &handler->conf->environment) {
|
lxc_list_for_each(iterator, &handler->conf->environment) {
|
||||||
if (putenv((char *)iterator->elem)) {
|
if (putenv((char *)iterator->elem)) {
|
||||||
SYSERROR("Failed to set environment variable: %s.", (char *)iterator->elem);
|
SYSERROR("Failed to set environment variable: %s.", (char *)iterator->elem);
|
||||||
@ -1005,6 +999,21 @@ static int do_start(void *data)
|
|||||||
if (lxc_sync_barrier_parent(handler, LXC_SYNC_CGROUP_LIMITS))
|
if (lxc_sync_barrier_parent(handler, LXC_SYNC_CGROUP_LIMITS))
|
||||||
goto out_warn_father;
|
goto out_warn_father;
|
||||||
|
|
||||||
|
/* Reset the environment variables the user requested in a clear
|
||||||
|
* environment.
|
||||||
|
*/
|
||||||
|
if (clearenv()) {
|
||||||
|
SYSERROR("Failed to clear environment.");
|
||||||
|
/* Don't error out though. */
|
||||||
|
}
|
||||||
|
|
||||||
|
lxc_list_for_each(iterator, &handler->conf->environment) {
|
||||||
|
if (putenv((char *)iterator->elem)) {
|
||||||
|
SYSERROR("Failed to set environment variable: %s.", (char *)iterator->elem);
|
||||||
|
goto out_warn_father;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (putenv("container=lxc")) {
|
if (putenv("container=lxc")) {
|
||||||
SYSERROR("Failed to set environment variable: container=lxc.");
|
SYSERROR("Failed to set environment variable: container=lxc.");
|
||||||
goto out_warn_father;
|
goto out_warn_father;
|
||||||
|
Loading…
Reference in New Issue
Block a user