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/09/23 04:31:40 UTC
[1/4] mesos git commit: Added 'os::spawn()' to stout as 'argv'
counterpart to 'os::system()'.
Repository: mesos
Updated Branches:
refs/heads/1.0.x d6132c58c -> 7b322c9ef
Added 'os::spawn()' to stout as 'argv' counterpart to 'os::system()'.
Review: https://reviews.apache.org/r/52184/
*** Modified for 1.0.x ***
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/d73c57e2
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/d73c57e2
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/d73c57e2
Branch: refs/heads/1.0.x
Commit: d73c57e24aa6de7e342306f52032c0a7a9d26150
Parents: d6132c5
Author: Kevin Klues <kl...@gmail.com>
Authored: Thu Sep 22 20:45:52 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Sep 22 21:21:11 2016 -0700
----------------------------------------------------------------------
3rdparty/stout/include/stout/os/posix/shell.hpp | 31 ++++++++++++++++++++
.../stout/include/stout/os/windows/shell.hpp | 17 +++++++++++
2 files changed, 48 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/d73c57e2/3rdparty/stout/include/stout/os/posix/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/posix/shell.hpp b/3rdparty/stout/include/stout/os/posix/shell.hpp
index 1d73ae5..928c230 100644
--- a/3rdparty/stout/include/stout/os/posix/shell.hpp
+++ b/3rdparty/stout/include/stout/os/posix/shell.hpp
@@ -27,6 +27,7 @@
#include <stout/format.hpp>
#include <stout/try.hpp>
+#include <stout/os/raw/argv.hpp>
namespace os {
@@ -144,6 +145,36 @@ inline int system(const std::string& command)
}
}
+// Executes a command by calling "<command> <arguments...>", and
+// returns after the command has been completed. Returns 0 if
+// succeeds, and -1 on error (e.g., fork/exec/waitpid failed). This
+// function is async signal safe. We return int instead of returning a
+// Try because Try involves 'new', which is not async signal safe.
+inline int spawn(
+ const std::string& command,
+ const std::vector<std::string>& arguments)
+{
+ pid_t pid = ::fork();
+
+ if (pid == -1) {
+ return -1;
+ } else if (pid == 0) {
+ // In child process.
+ ::execvp(command.c_str(), os::raw::Argv(arguments));
+ ::exit(127);
+ } else {
+ // In parent process.
+ int status;
+ while (::waitpid(pid, &status, 0) == -1) {
+ if (errno != EINTR) {
+ return -1;
+ }
+ }
+
+ return status;
+ }
+}
+
template<typename... T>
inline int execlp(const char* file, T... t)
http://git-wip-us.apache.org/repos/asf/mesos/blob/d73c57e2/3rdparty/stout/include/stout/os/windows/shell.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/shell.hpp b/3rdparty/stout/include/stout/os/windows/shell.hpp
index c6e141a..dcec3a7 100644
--- a/3rdparty/stout/include/stout/os/windows/shell.hpp
+++ b/3rdparty/stout/include/stout/os/windows/shell.hpp
@@ -21,6 +21,8 @@
#include <stout/try.hpp>
+#include <stout/os/raw/argv.hpp>
+
namespace os {
namespace Shell {
@@ -104,6 +106,21 @@ inline int system(const std::string& command)
}
+// Executes a command by calling "<command> <arguments...>", and
+// returns after the command has been completed. Returns 0 if
+// succeeds, and -1 on error.
+inline int spawn(
+ const std::string& command,
+ const std::vector<std::string>& arguments)
+{
+ return ::_spawnvp(_P_WAIT, command.c_str(), os::raw::Argv(arguments));
+}
+
+
+// On Windows, the `_spawnlp` call creates a new process.
+// In order to emulate the semantics of `execlp`, we spawn with `_P_WAIT`,
+// which forces the parent process to block on the child. When the child exits,
+// the exit code is propagated back through the parent via `exit()`.
template<typename... T>
inline int execlp(const char* file, T... t)
{
[3/4] mesos git commit: Added MESOS-6235 to 1.0.2 CHANGELOG.
Posted by ji...@apache.org.
Added MESOS-6235 to 1.0.2 CHANGELOG.
Review: https://reviews.apache.org/r/52187
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/778253ca
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/778253ca
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/778253ca
Branch: refs/heads/1.0.x
Commit: 778253caba9b66ee09aa5aef519295fa96f4f367
Parents: 08d871d
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Sep 22 21:17:25 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Sep 22 21:31:19 2016 -0700
----------------------------------------------------------------------
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/778253ca/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 97d0b6a..ba1438d 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,6 +9,7 @@ All Issues:
* [MESOS-6122] - Mesos slave throws systemd errors even when passed a flag to disable systemd.
* [MESOS-6104] - Potential FD double close in libevent's implementation of `sendfile`.
* [MESOS-6152] - Resource leak in libevent_ssl_socket.cpp.
+ * [MESOS-6235] - Add 'argv' variant of 'os::system'.
Release Notes - Mesos - Version 1.0.1
[4/4] mesos git commit: Added MESOS-6075 to 1.0.2 CHANGELOG.
Posted by ji...@apache.org.
Added MESOS-6075 to 1.0.2 CHANGELOG.
Review: https://reviews.apache.org/r/52188
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/7b322c9e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/7b322c9e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/7b322c9e
Branch: refs/heads/1.0.x
Commit: 7b322c9efb135d3e1cb52019dc1ed628cdb079fb
Parents: 778253c
Author: Jie Yu <yu...@gmail.com>
Authored: Thu Sep 22 21:18:27 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Sep 22 21:31:25 2016 -0700
----------------------------------------------------------------------
CHANGELOG | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/7b322c9e/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index ba1438d..a0fa681 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,10 +6,11 @@ All Issues:
** Bug
* [MESOS-6013] - Use readdir instead of readdir_r.
* [MESOS-6074] - Master check failure if the metrics endpoint is polled soon after it starts.
+ * [MESOS-6075] - Avoid libprocess functions in `mesos-containerizer launch`.
* [MESOS-6122] - Mesos slave throws systemd errors even when passed a flag to disable systemd.
* [MESOS-6104] - Potential FD double close in libevent's implementation of `sendfile`.
* [MESOS-6152] - Resource leak in libevent_ssl_socket.cpp.
- * [MESOS-6235] - Add 'argv' variant of 'os::system'.
+ * [MESOS-6235] - Add 'os::spawn', 'argv' variant of 'os::system'.
Release Notes - Mesos - Version 1.0.1
[2/4] mesos git commit: Updated launch helper to avoid initializing
libprocess.
Posted by ji...@apache.org.
Updated launch helper to avoid initializing libprocess.
Previously, we used 'process::subprocess()' to run all of our pre-exec
commands. However, doing so causes us to (unnecesssarily) initialize
all of libprocess (and subsequently creating a whole bunch of unused
threads, etc.) just to run a simple script.
To avoid this, we now use `os::system()` and the new `os::spawn()`
functions to give us our shell/non-shell variant of commands we want
to launch.
In the past, we used 'os::system()' alone to avoid initializing
libprocess, but this caused security issues with allowing arbitrary
shell commands to be appended to root-level pre-exec commands that
take strings as their last argument (e.g. mount --bind <src> <target>,
where target is user supplied and is set to "target_dir; rm -rf /").
We now handle this case by using `os::spawn()` instead.
Review: https://reviews.apache.org/r/52011/
*** Modified for 1.0.x ***
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/08d871dd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/08d871dd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/08d871dd
Branch: refs/heads/1.0.x
Commit: 08d871ddeeb1ed96fcb1544ebe2e8ddceb60164b
Parents: d73c57e
Author: Kevin Klues <kl...@gmail.com>
Authored: Thu Sep 22 20:45:55 2016 -0700
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Sep 22 21:23:17 2016 -0700
----------------------------------------------------------------------
src/slave/containerizer/mesos/launch.cpp | 33 +++++++--------------------
1 file changed, 8 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/08d871dd/src/slave/containerizer/mesos/launch.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp
index 2db8db5..e1853cb 100644
--- a/src/slave/containerizer/mesos/launch.cpp
+++ b/src/slave/containerizer/mesos/launch.cpp
@@ -22,8 +22,6 @@
#include <iostream>
-#include <process/subprocess.hpp>
-
#include <stout/foreach.hpp>
#include <stout/os.hpp>
#include <stout/protobuf.hpp>
@@ -44,8 +42,6 @@ using std::endl;
using std::string;
using std::vector;
-using process::Subprocess;
-
namespace mesos {
namespace internal {
namespace slave {
@@ -219,37 +215,24 @@ int MesosContainerizerLaunch::execute()
cout << "Executing pre-exec command '" << value << "'" << endl;
- Try<Subprocess> s = Error("Not launched");
+ int status = 0;
if (parse->shell()) {
- s = subprocess(parse->value(), Subprocess::PATH("/dev/null"));
+ // Execute the command using the system shell.
+ status = os::system(parse->value());
} else {
- // Launch non-shell command as a subprocess to avoid injecting
- // arbitrary shell commands.
+ // Directly spawn all non-shell commands to prohibit users
+ // from injecting arbitrary shell commands in the arguments.
vector<string> args;
foreach (const string& arg, parse->arguments()) {
args.push_back(arg);
}
- s = subprocess(parse->value(), args, Subprocess::PATH("/dev/null"));
+ status = os::spawn(parse->value(), args);
}
- if (s.isError()) {
- cerr << "Failed to create the pre-exec subprocess: "
- << s.error() << endl;
- return EXIT_FAILURE;
- }
-
- s->status().await();
-
- Option<int> status = s->status().get();
- if (status.isNone()) {
- cerr << "Failed to reap the pre-exec subprocess "
- << "'" << value << "'" << endl;
- return EXIT_FAILURE;
- } else if (status.get() != 0) {
- cerr << "The pre-exec subprocess '" << value << "' "
- << "failed" << endl;
+ if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
+ cerr << "Failed to execute pre-exec command '" << value << "'" << endl;
return EXIT_FAILURE;
}
}