You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2014/03/14 20:56:02 UTC
git commit: Display warning for credentials file permissions.
Repository: mesos
Updated Branches:
refs/heads/master c51205fdb -> 28d6580ab
Display warning for credentials file permissions.
Review: https://reviews.apache.org/r/19093
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/28d6580a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/28d6580a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/28d6580a
Branch: refs/heads/master
Commit: 28d6580ab581976c82d42d5fbc2a07e13bbeef7c
Parents: c51205f
Author: Isabel Jimenez <co...@isabeljimenez.com>
Authored: Fri Mar 14 12:55:51 2014 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Fri Mar 14 12:55:51 2014 -0700
----------------------------------------------------------------------
3rdparty/libprocess/3rdparty/stout/Makefile.am | 1 +
.../3rdparty/stout/include/stout/os.hpp | 1 +
.../stout/include/stout/os/permissions.hpp | 67 ++++++++++++++++++++
src/master/master.cpp | 18 ++++--
4 files changed, 82 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/28d6580a/3rdparty/libprocess/3rdparty/stout/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/Makefile.am b/3rdparty/libprocess/3rdparty/stout/Makefile.am
index 1075b46..df149dd 100644
--- a/3rdparty/libprocess/3rdparty/stout/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/Makefile.am
@@ -51,6 +51,7 @@ EXTRA_DIST = \
include/stout/os/sendfile.hpp \
include/stout/os/shell.hpp \
include/stout/os/signals.hpp \
+ include/stout/os/permissions.hpp \
include/stout/os/pstree.hpp \
include/stout/os/sysctl.hpp \
include/stout/path.hpp \
http://git-wip-us.apache.org/repos/asf/mesos/blob/28d6580a/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 3f475a4..901e555 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os.hpp
@@ -73,6 +73,7 @@
#ifdef __APPLE__
#include <stout/os/osx.hpp>
#endif // __APPLE__
+#include <stout/os/permissions.hpp>
#include <stout/os/pstree.hpp>
#include <stout/os/read.hpp>
#include <stout/os/sendfile.hpp>
http://git-wip-us.apache.org/repos/asf/mesos/blob/28d6580a/3rdparty/libprocess/3rdparty/stout/include/stout/os/permissions.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/os/permissions.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/os/permissions.hpp
new file mode 100644
index 0000000..ba8463c
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/os/permissions.hpp
@@ -0,0 +1,67 @@
+/**
+ * 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_PERMISSIONS_HPP__
+#define __STOUT_OS_PERMISSIONS_HPP__
+
+#include <sys/stat.h>
+
+#include <string>
+
+namespace os {
+
+struct Permissions
+{
+ explicit Permissions(mode_t mode)
+ {
+ owner.r = mode & S_IRUSR;
+ owner.w = mode & S_IWUSR;
+ owner.x = mode & S_IXUSR;
+ owner.rwx = mode & S_IRWXU;
+ group.r = mode & S_IRGRP;
+ group.w = mode & S_IWGRP;
+ group.x = mode & S_IXGRP;
+ group.rwx = mode & S_IRWXG;
+ others.r = mode & S_IROTH;
+ others.w = mode & S_IWOTH;
+ others.x = mode & S_IXOTH;
+ others.rwx = mode & S_IRWXO;
+ setuid = mode & S_ISUID;
+ setgid = mode & S_ISGID;
+ sticky = mode & S_ISVTX;
+ }
+
+ struct {
+ bool r;
+ bool w;
+ bool x;
+ bool rwx;
+ } owner, group, others;
+
+ bool setuid;
+ bool setgid;
+ bool sticky;
+};
+
+inline Try<Permissions> permissions(const std::string& path)
+{
+ struct stat s;
+ if (::stat(path.c_str(), &s) < 0) {
+ return ErrnoError();
+ }
+ return Permissions(s.st_mode);
+}
+
+} // namespace os {
+
+#endif // __STOUT_OS_PERMISSIONS_HPP__
http://git-wip-us.apache.org/repos/asf/mesos/blob/28d6580a/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index 2a40333..008f435 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -278,12 +278,10 @@ void Master::initialize()
if (flags.credentials.isSome()) {
vector<Credential> credentials;
- const std::string& path = flags.credentials.get();
+ const std::string& path =
+ strings::remove(flags.credentials.get(), "file://", strings::PREFIX);
- // TODO(vinod): Warn if the credentials file has bad file
- // permissions (e.g., world readable!).
- Try<string> read = os::read(
- strings::remove(path, "file://", strings::PREFIX));
+ Try<string> read = os::read(path);
if (read.isError()) {
EXIT(1) << "Failed to read credentials file '" << path
<< "': " << read.error();
@@ -291,6 +289,16 @@ void Master::initialize()
LOG(WARNING) << "Empty credentials file '" << path << "'. "
<< "!!No frameworks will be allowed to register!!";
} else {
+ Try<os::Permissions> permissions = os::permissions(path);
+ if (permissions.isError()) {
+ LOG(WARNING) << "Failed to stat credentials file '" << path
+ << "': " << permissions.error();
+ } else if (permissions.get().others.rwx) {
+ LOG(WARNING) << "Permissions on credentials file '" << path
+ << "' are too open. It is recommended that your "
+ << "credentials file is NOT accessible by others.";
+ }
+
foreach (const string& line, strings::tokenize(read.get(), "\n")) {
const vector<string>& pairs = strings::tokenize(line, " ");
if (pairs.size() != 2) {