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/01/29 06:59:06 UTC

[1/2] mesos git commit: Windows: Ported slave/paths.cpp.

Repository: mesos
Updated Branches:
  refs/heads/master 7b7a7bd38 -> 9dec31197


Windows: Ported slave/paths.cpp.

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


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

Branch: refs/heads/master
Commit: 9dec31197e4058735633f5839bd2bb1bcffd3645
Parents: e4547ee
Author: Alex Naparu <al...@outlook.com>
Authored: Thu Jan 28 21:15:53 2016 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Jan 28 21:57:47 2016 -0800

----------------------------------------------------------------------
 src/CMakeLists.txt  | 2 +-
 src/slave/paths.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/9dec3119/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 93caf00..f13e1f2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -202,6 +202,7 @@ set(SCHEDULER_SRC
 set(AGENT_SRC
   ${AGENT_SRC}
   slave/constants.cpp
+  slave/paths.cpp
   slave/state.cpp
   )
 
@@ -213,7 +214,6 @@ if (NOT WIN32)
     slave/http.cpp
     slave/metrics.cpp
     slave/monitor.cpp
-    slave/paths.cpp
     slave/qos_controller.cpp
     slave/qos_controllers/noop.cpp
     slave/resource_estimator.cpp

http://git-wip-us.apache.org/repos/asf/mesos/blob/9dec3119/src/slave/paths.cpp
----------------------------------------------------------------------
diff --git a/src/slave/paths.cpp b/src/slave/paths.cpp
index 2b18b83..5c650c6 100644
--- a/src/slave/paths.cpp
+++ b/src/slave/paths.cpp
@@ -462,6 +462,8 @@ string createExecutorDirectory(
     << "Failed to symlink directory '" << directory
     << "' to '" << latest << "'";
 
+// `os::chown()` is not available on Windows.
+#ifndef __WINDOWS__
   if (user.isSome()) {
     // Per MESOS-2592, we need to set the ownership of the executor
     // directory during its creation. We should not rely on subsequent
@@ -484,6 +486,7 @@ string createExecutorDirectory(
                    << chown.error();
     }
   }
+#endif // __WINDOWS__
 
   return directory;
 }


[2/2] mesos git commit: Windows: Made 'os::chown' a POSIX-only function.

Posted by jo...@apache.org.
Windows: Made 'os::chown' a POSIX-only function.

https://reviews.apache.org/r/40613/


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

Branch: refs/heads/master
Commit: e4547eedfce01c24c3faa3b11cf51b526409dc0b
Parents: 7b7a7bd
Author: Alex Naparu <al...@microsoft.com>
Authored: Mon Nov 23 12:50:19 2015 -0800
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Jan 28 21:57:47 2016 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/include/Makefile.am          |  1 +
 .../stout/include/stout/os/posix/chown.hpp      | 72 ++++++++++++++++++++
 .../3rdparty/stout/include/stout/posix/os.hpp   | 45 +-----------
 3 files changed, 74 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/e4547eed/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 8eef318..34c14fd 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -96,6 +96,7 @@ nobase_include_HEADERS =		\
   stout/os/utime.hpp			\
   stout/os/write.hpp			\
   stout/os/posix/bootid.hpp		\
+  stout/os/posix/chown.hpp		\
   stout/os/posix/direntsize.hpp		\
   stout/os/posix/exists.hpp		\
   stout/os/posix/fcntl.hpp		\

http://git-wip-us.apache.org/repos/asf/mesos/blob/e4547eed/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chown.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chown.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chown.hpp
new file mode 100644
index 0000000..6068409
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/posix/chown.hpp
@@ -0,0 +1,72 @@
+// Licensed 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_CHOWN_HPP__
+#define __STOUT_OS_POSIX_CHOWN_HPP__
+
+#include <sys/types.h>
+#include <pwd.h>
+
+#include <stout/error.hpp>
+#include <stout/nothing.hpp>
+#include <stout/try.hpp>
+
+#include <stout/os/shell.hpp>
+
+namespace os {
+
+inline Try<Nothing> chown(
+    uid_t uid,
+    gid_t gid,
+    const std::string& path,
+    bool recursive)
+{
+  if (recursive) {
+    // TODO(bmahler): Consider walking the file tree instead. We would need
+    // to be careful to not miss dotfiles.
+    std::string command =
+      "chown -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
+
+    int status = os::system(command);
+    if (status != 0) {
+      return ErrnoError(
+          "Failed to execute '" + command +
+          "' (exit status: " + stringify(status) + ")");
+    }
+  } else {
+    if (::chown(path.c_str(), uid, gid) < 0) {
+      return ErrnoError();
+    }
+  }
+
+  return Nothing();
+}
+
+
+// Changes the specified path's user and group ownership to that of
+// the specified user.
+inline Try<Nothing> chown(
+    const std::string& user,
+    const std::string& path,
+    bool recursive = true)
+{
+  passwd* passwd;
+  if ((passwd = ::getpwnam(user.c_str())) == NULL) {
+    return ErrnoError("Failed to get user information for '" + user + "'");
+  }
+
+  return chown(passwd->pw_uid, passwd->pw_gid, path, recursive);
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_POSIX_CHOWN_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/e4547eed/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 d0fb308..2eed65d 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/os.hpp
@@ -85,6 +85,7 @@
 #include <stout/os/sysctl.hpp>
 #endif // __APPLE__ || __FreeBSD__
 
+#include <stout/os/posix/chown.hpp>
 #include <stout/os/raw/environment.hpp>
 
 #include <stout/os/shell.hpp>
@@ -133,50 +134,6 @@ inline int execvpe(const char* file, char** argv, char** envp)
 }
 
 
-inline Try<Nothing> chown(
-    uid_t uid,
-    gid_t gid,
-    const std::string& path,
-    bool recursive)
-{
-  if (recursive) {
-    // TODO(bmahler): Consider walking the file tree instead. We would need
-    // to be careful to not miss dotfiles.
-    std::string command =
-      "chown -R " + stringify(uid) + ':' + stringify(gid) + " '" + path + "'";
-
-    int status = os::system(command);
-    if (status != 0) {
-      return ErrnoError(
-          "Failed to execute '" + command +
-          "' (exit status: " + stringify(status) + ")");
-    }
-  } else {
-    if (::chown(path.c_str(), uid, gid) < 0) {
-      return ErrnoError();
-    }
-  }
-
-  return Nothing();
-}
-
-
-// Changes the specified path's user and group ownership to that of
-// the specified user.
-inline Try<Nothing> chown(
-    const std::string& user,
-    const std::string& path,
-    bool recursive = true)
-{
-  passwd* passwd;
-  if ((passwd = ::getpwnam(user.c_str())) == NULL) {
-    return ErrnoError("Failed to get user information for '" + user + "'");
-  }
-
-  return chown(passwd->pw_uid, passwd->pw_gid, path, recursive);
-}
-
-
 inline Try<Nothing> chmod(const std::string& path, int mode)
 {
   if (::chmod(path.c_str(), mode) < 0) {