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

Side by Side Diff: sandbox/linux/services/credentials.h

Issue 182453004: Linux Sandbox: add Credentials::SupportsNewUserNS() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Save errno. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sandbox/linux/services/credentials.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SANDBOX_LINUX_SERVICES_CREDENTIALS_H_ 5 #ifndef SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
6 #define SANDBOX_LINUX_SERVICES_CREDENTIALS_H_ 6 #define SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
7 7
8 #include "build/build_config.h" 8 #include "build/build_config.h"
9 // Link errors are tedious to track, raise a compile-time error instead. 9 // Link errors are tedious to track, raise a compile-time error instead.
10 #if defined(OS_ANDROID) 10 #if defined(OS_ANDROID)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // the current process. 44 // the current process.
45 bool DropAllCapabilities(); 45 bool DropAllCapabilities();
46 // Return true iff there is any capability in any of the capabilities sets 46 // Return true iff there is any capability in any of the capabilities sets
47 // of the current process. 47 // of the current process.
48 bool HasAnyCapability() const; 48 bool HasAnyCapability() const;
49 // Returns the capabilities of the current process in textual form, as 49 // Returns the capabilities of the current process in textual form, as
50 // documented in libcap2's cap_to_text(3). This is mostly useful for 50 // documented in libcap2's cap_to_text(3). This is mostly useful for
51 // debugging and tests. 51 // debugging and tests.
52 scoped_ptr<std::string> GetCurrentCapString() const; 52 scoped_ptr<std::string> GetCurrentCapString() const;
53 53
54 // Returns whether the kernel supports CLONE_NEWUSER and whether it would be
55 // possible to immediately move to a new user namespace. There is no point
56 // in using this method right before calling MoveToNewUserNS(), simply call
57 // MoveToNewUserNS() immediately. This method is only useful to test kernel
58 // support ahead of time.
59 static bool SupportsNewUserNS();
60
54 // Move the current process to a new "user namespace" as supported by Linux 61 // Move the current process to a new "user namespace" as supported by Linux
55 // 3.8+ (CLONE_NEWUSER). 62 // 3.8+ (CLONE_NEWUSER).
56 // The uid map will be set-up so that the perceived uid and gid will not 63 // The uid map will be set-up so that the perceived uid and gid will not
57 // change. 64 // change.
58 // If this call succeeds, the current process will be granted a full set of 65 // If this call succeeds, the current process will be granted a full set of
59 // capabilities in the new namespace. 66 // capabilities in the new namespace.
60 bool MoveToNewUserNS(); 67 bool MoveToNewUserNS();
61 68
62 // Remove the ability of the process to access the file system. File 69 // Remove the ability of the process to access the file system. File
63 // descriptors which are already open prior to calling this API remain 70 // descriptors which are already open prior to calling this API remain
64 // available. 71 // available.
65 // The implementation currently uses chroot(2) and requires CAP_SYS_CHROOT. 72 // The implementation currently uses chroot(2) and requires CAP_SYS_CHROOT.
66 // CAP_SYS_CHROOT can be acquired by using the MoveToNewUserNS() API. 73 // CAP_SYS_CHROOT can be acquired by using the MoveToNewUserNS() API.
67 // Make sure to call DropAllCapabilities() after this call to prevent 74 // Make sure to call DropAllCapabilities() after this call to prevent
68 // escapes. 75 // escapes.
69 // To be secure, it's very important for this API to not be called while the 76 // To be secure, it's very important for this API to not be called while the
70 // process has any directory file descriptor open. 77 // process has any directory file descriptor open.
71 bool DropFileSystemAccess(); 78 bool DropFileSystemAccess();
72 79
73 private: 80 private:
74 DISALLOW_COPY_AND_ASSIGN(Credentials); 81 DISALLOW_COPY_AND_ASSIGN(Credentials);
75 }; 82 };
76 83
77 } // namespace sandbox. 84 } // namespace sandbox.
78 85
79 #endif // SANDBOX_LINUX_SERVICES_CREDENTIALS_H_ 86 #endif // SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
OLDNEW
« no previous file with comments | « no previous file | sandbox/linux/services/credentials.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698