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

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

Issue 997463002: Add SetCapabilities for setting capabilities to an exact set. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 5 years, 9 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
« no previous file with comments | « no previous file | sandbox/linux/services/credentials.cc » ('j') | sandbox/linux/services/credentials.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/credentials.h
diff --git a/sandbox/linux/services/credentials.h b/sandbox/linux/services/credentials.h
index 91435611851f81a0d2136feb3975180d5158874a..2d2ec5de33ee7bef2ce84c6340d788bb35af9198 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>
+
#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,19 @@ 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, const std::vector<cap_value_t>& caps)
+ WARN_UNUSED_RESULT;
+
+ // Returns true if the current thread has either the CAP_EFFECTIVE or
+ // CAP_PERMITTED flag set for the given capability.
+ static bool HasCapability(cap_value_t cap);
// 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();
« no previous file with comments | « no previous file | sandbox/linux/services/credentials.cc » ('j') | sandbox/linux/services/credentials.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698