You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/11/29 19:41:26 UTC

[7/9] mesos git commit: Used environment to pass flags to launch helper.

Used environment to pass flags to launch helper.

Instead of doing that just for command environment variables, this
patch does it consistently by using environment variables to pass
launch helper flags. This will be more secure.

Review: https://reviews.apache.org/r/54099


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9d6cbf0b
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9d6cbf0b
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9d6cbf0b

Branch: refs/heads/master
Commit: 9d6cbf0b32f1760a07fff0c4409fa815ba5d9634
Parents: 08ff876
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Nov 24 23:53:45 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Nov 29 11:40:50 2016 -0800

----------------------------------------------------------------------
 src/slave/containerizer/mesos/containerizer.cpp | 29 ++++++++++++--------
 1 file changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9d6cbf0b/src/slave/containerizer/mesos/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/containerizer.cpp b/src/slave/containerizer/mesos/containerizer.cpp
index 72d55e7..0e42ed7 100644
--- a/src/slave/containerizer/mesos/containerizer.cpp
+++ b/src/slave/containerizer/mesos/containerizer.cpp
@@ -1428,17 +1428,7 @@ Future<bool> MesosContainerizerProcess::_launch(
     MesosContainerizerLaunch::Flags launchFlags;
 
     launchFlags.command = JSON::protobuf(launchCommand.get());
-
-    // The launch helper should inherit the agent's environment.
-    map<string, string> launchEnvironment = os::environment();
-
-    // Passing the command environment via an environment variable
-    // to the launch helper instead of a flag due to the sensitivity
-    // of environment variables. Otherwise the command environment
-    // would have been visible through commands like `ps` which are
-    // not protected from unprivileged users on the host.
-    launchEnvironment["MESOS_CONTAINERIZER_ENVIRONMENT"] =
-      stringify(environment);
+    launchFlags.environment = environment;
 
     if (rootfs.isNone()) {
       // NOTE: If the executor shares the host filesystem, we should
@@ -1555,6 +1545,21 @@ Future<bool> MesosContainerizerProcess::_launch(
     VLOG(1) << "Launching '" << MESOS_CONTAINERIZER << "' with flags '"
             << launchFlags << "'";
 
+    // Passing the launch flags via environment variables to the
+    // launch helper due to the sensitivity of those flags. Otherwise
+    // the launch flags would have been visible through commands like
+    // `ps` which are not protected from unprivileged users on the
+    // host.
+    map<string, string> launchFlagsEnvironment =
+      launchFlags.buildEnvironment("MESOS_CONTAINERIZER_");
+
+    // The launch helper should inherit the agent's environment.
+    map<string, string> launchEnvironment = os::environment();
+
+    launchEnvironment.insert(
+        launchFlagsEnvironment.begin(),
+        launchFlagsEnvironment.end());
+
     // Fork the child using launcher.
     vector<string> argv(2);
     argv[0] = MESOS_CONTAINERIZER;
@@ -1567,7 +1572,7 @@ Future<bool> MesosContainerizerProcess::_launch(
         Subprocess::IO(subprocessInfo.in),
         Subprocess::IO(subprocessInfo.out),
         Subprocess::IO(subprocessInfo.err),
-        &launchFlags,
+        nullptr,
         launchEnvironment,
         // 'enterNamespaces' will be ignored by PosixLauncher.
         _enterNamespaces,