The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1809

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
From 149857af109151d8a073a59d34225afb991a5989 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@ubuntu.com>
Date: Wed, 13 Sep 2017 04:01:41 +0200
Subject: [PATCH] start: set environment variables correctly

Signed-off-by: Christian Brauner <christian.brau...@ubuntu.com>
---
 src/lxc/start.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/src/lxc/start.c b/src/lxc/start.c
index 2186c7530..ae59c6711 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -913,16 +913,10 @@ static int do_start(void *data)
                INFO("Unshared CLONE_NEWCGROUP.");
        }
 
-       /* The clearenv() and putenv() calls have been moved here to allow us to
-        * use environment variables passed to the various hooks, such as the
-        * start hook above. Not all of the variables like CONFIG_PATH or ROOTFS
-        * are valid in this context but others are.
+       /* Add the requested environment variables to the current environment to
+        * allow them to be used by the various hooks, such as the start hook
+        * above.
         */
-       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);
@@ -1005,6 +999,21 @@ static int do_start(void *data)
        if (lxc_sync_barrier_parent(handler, LXC_SYNC_CGROUP_LIMITS))
                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")) {
                SYSERROR("Failed to set environment variable: container=lxc.");
                goto out_warn_father;
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to