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 2017/07/07 19:32:30 UTC

mesos git commit: Searched executables from the current working directory.

Repository: mesos
Updated Branches:
  refs/heads/master c90bea804 -> 6271682e6


Searched executables from the current working directory.

If a framework specifies use of its own executor (in the sandbox) and
sets shell to false, the executor is never found. This is becase if
the PATH env variable is set, `execvp` or `execvpe` won't look into
the current working directory for executables. This patch adds the
support for searching the current working directory for executables.

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


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

Branch: refs/heads/master
Commit: 6271682e67e0afa4c2d9395f7296e3bebbe909ff
Parents: c90bea8
Author: Aaron Wood <aa...@verizon.com>
Authored: Fri Jul 7 11:53:55 2017 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Jul 7 12:32:18 2017 -0700

----------------------------------------------------------------------
 src/slave/containerizer/mesos/launch.cpp | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/6271682e/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp
index 162ca1c..973b248 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -796,13 +796,31 @@ int MesosContainerizerLaunch::execute()
   }
 #endif // __WINDOWS__
 
+#ifndef __WINDOWS__
+  // Search executable in the current working directory as well.
+  // execvpe and execvp will only search executable from the current
+  // working directory if environment variable PATH is not set.
+  // TODO(aaron.wood): 'os::which' current does not work on Windows.
+  // Remove the ifndef guard once it's supported on Windows.
+  if (!path::absolute(executable) &&
+      launchInfo.has_working_directory()) {
+    Option<string> which = os::which(
+        executable,
+        launchInfo.working_directory());
+
+    if (which.isSome()) {
+      executable = which.get();
+    }
+  }
+#endif // __WINDOWS__
+
   if (envp.isSome()) {
     os::execvpe(executable.c_str(), argv, envp.get());
   } else {
     os::execvp(executable.c_str(), argv);
   }
 
-  // If we get here, the execle call failed.
+  // If we get here, the execvp call failed.
   cerr << "Failed to execute command: " << os::strerror(errno) << endl;
   exitWithStatus(EXIT_FAILURE);
   UNREACHABLE();