Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: sandbox/linux/services/credentials.h

Issue 868233011: Start all children in their own PID namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Only drop capabilities if we have any. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/services/credentials.h
diff --git a/sandbox/linux/services/credentials.h b/sandbox/linux/services/credentials.h
index 6b37d4904eca5c53f5f3f18d50fa47aee6936792..117681c6f54c034940049b4b7aaec277e94ea0a3 100644
--- a/sandbox/linux/services/credentials.h
+++ b/sandbox/linux/services/credentials.h
@@ -5,6 +5,8 @@
#ifndef SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
#define SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
+#include <sys/capability.h>
jln (very slow on Chromium) 2015/02/25 21:32:49 :(
rickyz (no longer on Chrome) 2015/03/21 01:35:32 Superseded by https://codereview.chromium.org/9974
+
#include "build/build_config.h"
// Link errors are tedious to track, raise a compile-time error instead.
#if defined(OS_ANDROID)
@@ -12,6 +14,7 @@
#endif // defined(OS_ANDROID).
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -26,7 +29,7 @@ namespace sandbox {
class SANDBOX_EXPORT Credentials {
public:
// Drop all capabilities in the effective, inheritable and permitted sets for
- // the current process. For security reasons, since capabilities are
+ // the current thread. For security reasons, since capabilities are
// per-thread, the caller is responsible for ensuring it is single-threaded
// when calling this API.
// |proc_fd| must be a file descriptor to /proc/ and remains owned by
@@ -34,11 +37,15 @@ class SANDBOX_EXPORT Credentials {
static bool DropAllCapabilities(int proc_fd) WARN_UNUSED_RESULT;
// A similar API which assumes that it can open /proc/self/ by itself.
static bool DropAllCapabilities() WARN_UNUSED_RESULT;
+ // Sets the effective and permitted capability sets for the current thread to
+ // the list of capabiltiies in |caps|. All other capability flags are cleared.
+ static bool SetCapabilities(int proc_fd,
jln (very slow on Chromium) 2015/02/25 21:32:49 Not great to expose that. Probably ok for now, but
rickyz (no longer on Chrome) 2015/03/21 01:35:32 Superseded by https://codereview.chromium.org/9974
+ const std::vector<cap_value_t>& caps);
// Return true iff there is any capability in any of the capabilities sets
- // of the current process.
+ // of the current thread.
static bool HasAnyCapability();
- // Returns the capabilities of the current process in textual form, as
+ // Returns the capabilities of the current thread in textual form, as
// documented in libcap2's cap_to_text(3). This is mostly useful for
// debugging and tests.
static scoped_ptr<std::string> GetCurrentCapString();

Powered by Google App Engine
This is Rietveld 408576698