You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/03/01 23:40:41 UTC
[1/2] mesos git commit: Stout: Marked `os::su` as deleted on Windows.
Repository: mesos
Updated Branches:
refs/heads/master 12de94803 -> 9f1b115a6
Stout: Marked `os::su` as deleted on Windows.
Review: https://reviews.apache.org/r/40939/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/9f1b115a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/9f1b115a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/9f1b115a
Branch: refs/heads/master
Commit: 9f1b115a67a1625a4807c2a7d4e1a41bca1af2a6
Parents: a1f7317
Author: Daniel Pravat <dp...@outlook.com>
Authored: Tue Mar 1 14:18:41 2016 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Mar 1 14:40:15 2016 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/Makefile.am | 3 +
.../3rdparty/stout/include/stout/os.hpp | 1 +
.../stout/include/stout/os/posix/su.hpp | 216 +++++++++++++++++++
.../3rdparty/stout/include/stout/os/su.hpp | 26 +++
.../stout/include/stout/os/windows/su.hpp | 64 ++++++
.../3rdparty/stout/include/stout/posix/os.hpp | 182 ----------------
6 files changed, 310 insertions(+), 182 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index f447a86..c10c6d9 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -93,6 +93,7 @@ nobase_include_HEADERS = \
stout/os/signals.hpp \
stout/os/stat.hpp \
stout/os/strerror.hpp \
+ stout/os/su.hpp \
stout/os/sysctl.hpp \
stout/os/touch.hpp \
stout/os/utime.hpp \
@@ -113,6 +114,7 @@ nobase_include_HEADERS = \
stout/os/posix/shell.hpp \
stout/os/posix/signals.hpp \
stout/os/posix/stat.hpp \
+ stout/os/posix/su.hpp \
stout/os/raw/environment.hpp \
stout/os/windows/bootid.hpp \
stout/os/windows/chroot.hpp \
@@ -129,6 +131,7 @@ nobase_include_HEADERS = \
stout/os/windows/shell.hpp \
stout/os/windows/signals.hpp \
stout/os/windows/stat.hpp \
+ stout/os/windows/su.hpp \
stout/path.hpp \
stout/preprocessor.hpp \
stout/proc.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index 40584bb..a3c21e4 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -55,6 +55,7 @@
#include <stout/os/rmdir.hpp>
#include <stout/os/shell.hpp>
#include <stout/os/stat.hpp>
+#include <stout/os/su.hpp>
// For readability, we minimize the number of #ifdef blocks in the code by
// splitting platform specifc system calls into separate directories.
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/su.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/su.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/su.hpp
new file mode 100644
index 0000000..43e91d6
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/su.hpp
@@ -0,0 +1,216 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_POSIX_SU_HPP__
+#define __STOUT_OS_POSIX_SU_HPP__
+
+#include <string>
+
+#include <grp.h>
+#include <pwd.h>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+#include <stout/unreachable.hpp>
+
+namespace os {
+
+inline Result<uid_t> getuid(const Option<std::string>& user = None())
+{
+ if (user.isNone()) {
+ return ::getuid();
+ }
+
+ struct passwd passwd;
+ struct passwd* result = NULL;
+
+ int size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size == -1) {
+ // Initial value for buffer size.
+ size = 1024;
+ }
+
+ while (true) {
+ char* buffer = new char[size];
+
+ if (getpwnam_r(user.get().c_str(), &passwd, buffer, size, &result) == 0) {
+ // The usual interpretation of POSIX is that getpwnam_r will
+ // return 0 but set result == NULL if the user is not found.
+ if (result == NULL) {
+ delete[] buffer;
+ return None();
+ }
+
+ uid_t uid = passwd.pw_uid;
+ delete[] buffer;
+ return uid;
+ } else {
+ // RHEL7 (and possibly other systems) will return non-zero and
+ // set one of the following errors for "The given name or uid
+ // was not found." See 'man getpwnam_r'. We only check for the
+ // errors explicitly listed, and do not consider the ellipsis.
+ if (errno == ENOENT ||
+ errno == ESRCH ||
+ errno == EBADF ||
+ errno == EPERM) {
+ delete[] buffer;
+ return None();
+ }
+
+ if (errno != ERANGE) {
+ delete[] buffer;
+ return ErrnoError("Failed to get username information");
+ }
+ // getpwnam_r set ERANGE so try again with a larger buffer.
+ size *= 2;
+ delete[] buffer;
+ }
+ }
+
+ UNREACHABLE();
+}
+
+
+inline Result<gid_t> getgid(const Option<std::string>& user = None())
+{
+ if (user.isNone()) {
+ return ::getgid();
+ }
+
+ struct passwd passwd;
+ struct passwd* result = NULL;
+
+ int size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size == -1) {
+ // Initial value for buffer size.
+ size = 1024;
+ }
+
+ while (true) {
+ char* buffer = new char[size];
+
+ if (getpwnam_r(user.get().c_str(), &passwd, buffer, size, &result) == 0) {
+ // The usual interpretation of POSIX is that getpwnam_r will
+ // return 0 but set result == NULL if the group is not found.
+ if (result == NULL) {
+ delete[] buffer;
+ return None();
+ }
+
+ gid_t gid = passwd.pw_gid;
+ delete[] buffer;
+ return gid;
+ } else {
+ // RHEL7 (and possibly other systems) will return non-zero and
+ // set one of the following errors for "The given name or uid
+ // was not found." See 'man getpwnam_r'. We only check for the
+ // errors explicitly listed, and do not consider the ellipsis.
+ if (errno == ENOENT ||
+ errno == ESRCH ||
+ errno == EBADF ||
+ errno == EPERM) {
+ delete[] buffer;
+ return None();
+ }
+
+ if (errno != ERANGE) {
+ delete[] buffer;
+ return ErrnoError("Failed to get username information");
+ }
+ // getpwnam_r set ERANGE so try again with a larger buffer.
+ size *= 2;
+ delete[] buffer;
+ }
+ }
+
+ UNREACHABLE();
+}
+
+
+inline Result<std::string> user(Option<uid_t> uid = None())
+{
+ if (uid.isNone()) {
+ uid = ::getuid();
+ }
+
+ int size = sysconf(_SC_GETPW_R_SIZE_MAX);
+ if (size == -1) {
+ // Initial value for buffer size.
+ size = 1024;
+ }
+
+ struct passwd passwd;
+ struct passwd* result = NULL;
+
+ while (true) {
+ char* buffer = new char[size];
+
+ if (getpwuid_r(uid.get(), &passwd, buffer, size, &result) == 0) {
+ // getpwuid_r will return 0 but set result == NULL if the uid is
+ // not found.
+ if (result == NULL) {
+ delete[] buffer;
+ return None();
+ }
+
+ std::string user(passwd.pw_name);
+ delete[] buffer;
+ return user;
+ } else {
+ if (errno != ERANGE) {
+ delete[] buffer;
+ return ErrnoError();
+ }
+
+ // getpwuid_r set ERANGE so try again with a larger buffer.
+ size *= 2;
+ delete[] buffer;
+ }
+ }
+}
+
+inline Try<Nothing> su(const std::string& user)
+{
+ Result<gid_t> gid = os::getgid(user);
+ if (gid.isError() || gid.isNone()) {
+ return Error("Failed to getgid: " +
+ (gid.isError() ? gid.error() : "unknown user"));
+ } else if (::setgid(gid.get())) {
+ return ErrnoError("Failed to set gid");
+ }
+
+ // Set the supplementary group list. We ignore EPERM because
+ // performing a no-op call (switching to same group) still
+ // requires being privileged, unlike 'setgid' and 'setuid'.
+ if (::initgroups(user.c_str(), gid.get()) == -1 && errno != EPERM) {
+ return ErrnoError("Failed to set supplementary groups");
+ }
+
+ Result<uid_t> uid = os::getuid(user);
+ if (uid.isError() || uid.isNone()) {
+ return Error("Failed to getuid: " +
+ (uid.isError() ? uid.error() : "unknown user"));
+ } else if (::setuid(uid.get())) {
+ return ErrnoError("Failed to setuid");
+ }
+
+ return Nothing();
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_POSIX_SU_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/stout/os/su.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/su.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/su.hpp
new file mode 100644
index 0000000..1023202
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/su.hpp
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_SU_HPP__
+#define __STOUT_OS_SU_HPP__
+
+#ifdef __WINDOWS__
+#include <stout/os/windows/su.hpp>
+#else
+#include <stout/os/posix/su.hpp>
+#endif // __WINDOWS__
+
+#endif // __STOUT_OS_SU_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/su.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/su.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/su.hpp
new file mode 100644
index 0000000..777140e
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/su.hpp
@@ -0,0 +1,64 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_WINDOWS_SU_HPP__
+#define __STOUT_OS_WINDOWS_SU_HPP__
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/result.hpp>
+#include <stout/try.hpp>
+
+#include <stout/windows.hpp>
+
+namespace os {
+
+// NOTE: We delete these functions because they are not meaningful on Windows.
+// `su` and `user` are the most important of these functions. The POSIX code
+// uses them prodigiously, but in Windows we have been able to divest ourselves
+// of all uses.
+//
+// `su` is important to the launcher API; if the `user` flag (not to be
+// confused with the `user` function, which we delete below) is present, we
+// will `su` to that user before launching the command. On Windows we avoid
+// this problem by simply conditionally compiling out the `user` flag
+// altogether, which means that we never have to call `su`.
+//
+// The `user` function itself is already mostly conditionally compiled out of
+// every platform except linux. So in this case it is simply safe to return an
+// error on Windows.
+
+
+inline Result<uid_t> getuid(const Option<std::string>& user = None()) = delete;
+
+
+inline Result<gid_t> getgid(const Option<std::string>& user = None()) = delete;
+
+
+inline Result<std::string> user(Option<uid_t> uid = None())
+{
+ SetLastError(ERROR_NOT_SUPPORTED);
+ return WindowsError();
+}
+
+
+inline Try<Nothing> su(const std::string& user) = delete;
+
+} // namespace os {
+
+#endif // __STOUT_OS_WINDOWS_SU_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/9f1b115a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
index 1a340aa..0b23957 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
@@ -154,188 +154,6 @@ inline Try<Nothing> mknod(
}
-inline Result<uid_t> getuid(const Option<std::string>& user = None())
-{
- if (user.isNone()) {
- return ::getuid();
- }
-
- struct passwd passwd;
- struct passwd* result = NULL;
-
- int size = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (size == -1) {
- // Initial value for buffer size.
- size = 1024;
- }
-
- while (true) {
- char* buffer = new char[size];
-
- if (getpwnam_r(user.get().c_str(), &passwd, buffer, size, &result) == 0) {
- // The usual interpretation of POSIX is that getpwnam_r will
- // return 0 but set result == NULL if the user is not found.
- if (result == NULL) {
- delete[] buffer;
- return None();
- }
-
- uid_t uid = passwd.pw_uid;
- delete[] buffer;
- return uid;
- } else {
- // RHEL7 (and possibly other systems) will return non-zero and
- // set one of the following errors for "The given name or uid
- // was not found." See 'man getpwnam_r'. We only check for the
- // errors explicitly listed, and do not consider the ellipsis.
- if (errno == ENOENT ||
- errno == ESRCH ||
- errno == EBADF ||
- errno == EPERM) {
- delete[] buffer;
- return None();
- }
-
- if (errno != ERANGE) {
- delete[] buffer;
- return ErrnoError("Failed to get username information");
- }
- // getpwnam_r set ERANGE so try again with a larger buffer.
- size *= 2;
- delete[] buffer;
- }
- }
-
- UNREACHABLE();
-}
-
-
-inline Result<gid_t> getgid(const Option<std::string>& user = None())
-{
- if (user.isNone()) {
- return ::getgid();
- }
-
- struct passwd passwd;
- struct passwd* result = NULL;
-
- int size = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (size == -1) {
- // Initial value for buffer size.
- size = 1024;
- }
-
- while (true) {
- char* buffer = new char[size];
-
- if (getpwnam_r(user.get().c_str(), &passwd, buffer, size, &result) == 0) {
- // The usual interpretation of POSIX is that getpwnam_r will
- // return 0 but set result == NULL if the group is not found.
- if (result == NULL) {
- delete[] buffer;
- return None();
- }
-
- gid_t gid = passwd.pw_gid;
- delete[] buffer;
- return gid;
- } else {
- // RHEL7 (and possibly other systems) will return non-zero and
- // set one of the following errors for "The given name or uid
- // was not found." See 'man getpwnam_r'. We only check for the
- // errors explicitly listed, and do not consider the ellipsis.
- if (errno == ENOENT ||
- errno == ESRCH ||
- errno == EBADF ||
- errno == EPERM) {
- delete[] buffer;
- return None();
- }
-
- if (errno != ERANGE) {
- delete[] buffer;
- return ErrnoError("Failed to get username information");
- }
- // getpwnam_r set ERANGE so try again with a larger buffer.
- size *= 2;
- delete[] buffer;
- }
- }
-
- UNREACHABLE();
-}
-
-
-inline Try<Nothing> su(const std::string& user)
-{
- Result<gid_t> gid = os::getgid(user);
- if (gid.isError() || gid.isNone()) {
- return Error("Failed to getgid: " +
- (gid.isError() ? gid.error() : "unknown user"));
- } else if (::setgid(gid.get())) {
- return ErrnoError("Failed to set gid");
- }
-
- // Set the supplementary group list. We ignore EPERM because
- // performing a no-op call (switching to same group) still
- // requires being privileged, unlike 'setgid' and 'setuid'.
- if (::initgroups(user.c_str(), gid.get()) == -1 && errno != EPERM) {
- return ErrnoError("Failed to set supplementary groups");
- }
-
- Result<uid_t> uid = os::getuid(user);
- if (uid.isError() || uid.isNone()) {
- return Error("Failed to getuid: " +
- (uid.isError() ? uid.error() : "unknown user"));
- } else if (::setuid(uid.get())) {
- return ErrnoError("Failed to setuid");
- }
-
- return Nothing();
-}
-
-
-inline Result<std::string> user(Option<uid_t> uid = None())
-{
- if (uid.isNone()) {
- uid = ::getuid();
- }
-
- int size = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (size == -1) {
- // Initial value for buffer size.
- size = 1024;
- }
-
- struct passwd passwd;
- struct passwd* result = NULL;
-
- while (true) {
- char* buffer = new char[size];
-
- if (getpwuid_r(uid.get(), &passwd, buffer, size, &result) == 0) {
- // getpwuid_r will return 0 but set result == NULL if the uid is
- // not found.
- if (result == NULL) {
- delete[] buffer;
- return None();
- }
-
- std::string user(passwd.pw_name);
- delete[] buffer;
- return user;
- } else {
- if (errno != ERANGE) {
- delete[] buffer;
- return ErrnoError();
- }
-
- // getpwuid_r set ERANGE so try again with a larger buffer.
- size *= 2;
- delete[] buffer;
- }
- }
-}
// Suspends execution for the given duration.
[2/2] mesos git commit: Stout: Marked `os::chroot` as deleted on
Windows.
Posted by jo...@apache.org.
Stout: Marked `os::chroot` as deleted on Windows.
Review: https://reviews.apache.org/r/40938/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a1f73174
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a1f73174
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a1f73174
Branch: refs/heads/master
Commit: a1f731746657b1cbcf136ddb2bf154ca3da271fc
Parents: 12de948
Author: Daniel Pravat <dp...@outlook.com>
Authored: Tue Mar 1 14:16:08 2016 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Tue Mar 1 14:40:15 2016 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/Makefile.am | 3 ++
.../3rdparty/stout/include/stout/os.hpp | 1 +
.../3rdparty/stout/include/stout/os/chroot.hpp | 26 +++++++++++++
.../stout/include/stout/os/posix/chroot.hpp | 39 +++++++++++++++++++
.../stout/include/stout/os/windows/chroot.hpp | 40 ++++++++++++++++++++
.../3rdparty/stout/include/stout/posix/os.hpp | 10 -----
.../3rdparty/stout/include/stout/windows/os.hpp | 6 ---
7 files changed, 109 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index 57a5732..f447a86 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -59,6 +59,7 @@ nobase_include_HEADERS = \
stout/os.hpp \
stout/os/bootid.hpp \
stout/os/chdir.hpp \
+ stout/os/chroot.hpp \
stout/os/close.hpp \
stout/os/constants.hpp \
stout/os/direntsize.hpp \
@@ -98,6 +99,7 @@ nobase_include_HEADERS = \
stout/os/write.hpp \
stout/os/posix/bootid.hpp \
stout/os/posix/chown.hpp \
+ stout/os/posix/chroot.hpp \
stout/os/posix/direntsize.hpp \
stout/os/posix/exists.hpp \
stout/os/posix/fcntl.hpp \
@@ -113,6 +115,7 @@ nobase_include_HEADERS = \
stout/os/posix/stat.hpp \
stout/os/raw/environment.hpp \
stout/os/windows/bootid.hpp \
+ stout/os/windows/chroot.hpp \
stout/os/windows/direntsize.hpp \
stout/os/windows/exists.hpp \
stout/os/windows/fcntl.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
index f1d3802..40584bb 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -44,6 +44,7 @@
#include <stout/os/bootid.hpp>
#include <stout/os/chdir.hpp>
+#include <stout/os/chroot.hpp>
#include <stout/os/exists.hpp>
#include <stout/os/ls.hpp>
#include <stout/os/mkdir.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/os/chroot.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/chroot.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/chroot.hpp
new file mode 100644
index 0000000..d487ec0
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/chroot.hpp
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_CHROOT_CLOSE_HPP__
+#define __STOUT_OS_CHROOT_CLOSE_HPP__
+
+#ifdef __WINDOWS__
+#include <stout/os/windows/chroot.hpp>
+#else
+#include <stout/os/posix/chroot.hpp>
+#endif // __WINDOWS__
+
+#endif // __STOUT_OS_CHROOT_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chroot.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chroot.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chroot.hpp
new file mode 100644
index 0000000..1309c52
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chroot.hpp
@@ -0,0 +1,39 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_POSIX_CHROOT_HPP__
+#define __STOUT_OS_POSIX_CHROOT_HPP__
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+namespace os {
+
+inline Try<Nothing> chroot(const std::string& directory)
+{
+ if (::chroot(directory.c_str()) < 0) {
+ return ErrnoError();
+ }
+
+ return Nothing();
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_POSIX_CHROOT_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/chroot.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/chroot.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/chroot.hpp
new file mode 100644
index 0000000..0833d2f
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/windows/chroot.hpp
@@ -0,0 +1,40 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __STOUT_OS_WINDOWS_CHROOT_HPP__
+#define __STOUT_OS_WINDOWS_CHROOT_HPP__
+
+#include <string>
+
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+
+namespace os {
+
+// NOTE: `chroot` is deleted because Windows does not support POSIX `chroot`
+// semantics. On POSIX platforms it remains important to (e.g.) the launcher
+// API; passing in the `rootfs` flag, for example, will tell the launcher to
+// `chroot` to that directory, before launching the process. On Windows, we
+// simply conditionally compile out the `rootfs` flag so we can be guaranteed
+// to never have to invoke `chroot`.
+
+inline Try<Nothing> chroot(const std::string& directory) = delete;
+
+} // namespace os {
+
+
+#endif // __STOUT_OS_WINDOWS_CHROOT_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
index 84a2a02..1a340aa 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
@@ -141,16 +141,6 @@ inline Try<Nothing> chmod(const std::string& path, int mode)
}
-inline Try<Nothing> chroot(const std::string& directory)
-{
- if (::chroot(directory.c_str()) < 0) {
- return ErrnoError();
- }
-
- return Nothing();
-}
-
-
inline Try<Nothing> mknod(
const std::string& path,
mode_t mode,
http://git-wip-us.apache.org/repos/asf/mesos/blob/a1f73174/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
index c8e19f4..6a391ff 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/os.hpp
@@ -98,12 +98,6 @@ inline Try<Nothing> chmod(const std::string& path, int mode)
}
-inline Try<Nothing> chroot(const std::string& directory)
-{
- UNIMPLEMENTED;
-}
-
-
inline Try<Nothing> mknod(
const std::string& path,
mode_t mode,