You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/12/14 22:15:59 UTC

mesos git commit: Fixed `os::chown` error message.

Repository: mesos
Updated Branches:
  refs/heads/master 0a7d46634 -> 784b7f599


Fixed `os::chown` error message.

getpwnam(3) only sets `errno` if there is an error. To detect
the (most common) case where the user account is successfully
not found, we need to clear `errno` and verify that it is
still clear on failure.

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


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

Branch: refs/heads/master
Commit: 784b7f599f8ad8350fc7d6703a4b584301b23edc
Parents: 0a7d466
Author: James Peach <jp...@apache.org>
Authored: Thu Dec 14 14:01:41 2017 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 14 14:01:41 2017 -0800

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/posix/chown.hpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/784b7f59/3rdparty/stout/include/stout/os/posix/chown.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/posix/chown.hpp b/3rdparty/stout/include/stout/os/posix/chown.hpp
index e2214ac..644129e 100644
--- a/3rdparty/stout/include/stout/os/posix/chown.hpp
+++ b/3rdparty/stout/include/stout/os/posix/chown.hpp
@@ -97,8 +97,13 @@ inline Try<Nothing> chown(
     bool recursive = true)
 {
   passwd* passwd;
+
+  errno = 0;
+
   if ((passwd = ::getpwnam(user.c_str())) == nullptr) {
-    return ErrnoError("Failed to get user information for '" + user + "'");
+    return errno
+      ? ErrnoError("Failed to get user information for '" + user + "'")
+      : Error("No such user '" + user + "'");
   }
 
   return chown(passwd->pw_uid, passwd->pw_gid, path, recursive);