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

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

Issue 276443003: NaCl: Add sanity check for number of open FDs at startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify as suggested in review Created 6 years, 7 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
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)
11 #error "Android is not supported." 11 #error "Android is not supported."
12 #endif // defined(OS_ANDROID). 12 #endif // defined(OS_ANDROID).
13 13
14 #include <string> 14 #include <string>
15 15
16 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "sandbox/sandbox_export.h" 18 #include "sandbox/sandbox_export.h"
19 19
20 namespace sandbox { 20 namespace sandbox {
21 21
22 // This class should be used to manipulate the current process' credentials. 22 // This class should be used to manipulate the current process' credentials.
23 // It is currently a stub used to manipulate POSIX.1e capabilities as 23 // It is currently a stub used to manipulate POSIX.1e capabilities as
24 // implemented by the Linux kernel. 24 // implemented by the Linux kernel.
25 class SANDBOX_EXPORT Credentials { 25 class SANDBOX_EXPORT Credentials {
26 public: 26 public:
27 Credentials(); 27 Credentials();
28 ~Credentials(); 28 ~Credentials();
29 29
30 // Returns the number of file descriptors in the current process's FD
31 // table, excluding |proc_fd|, which should be a file descriptor for
32 // /proc.
33 int CountOpenFds(int proc_fd);
34
30 // Checks whether the current process has any directory file descriptor open. 35 // Checks whether the current process has any directory file descriptor open.
31 // Directory file descriptors are "capabilities" that would let a process use 36 // Directory file descriptors are "capabilities" that would let a process use
32 // system calls such as openat() to bypass restrictions such as 37 // system calls such as openat() to bypass restrictions such as
33 // DropFileSystemAccess(). 38 // DropFileSystemAccess().
34 // Sometimes it's useful to call HasOpenDirectory() after file system access 39 // Sometimes it's useful to call HasOpenDirectory() after file system access
35 // has been dropped. In this case, |proc_fd| should be a file descriptor to 40 // has been dropped. In this case, |proc_fd| should be a file descriptor to
36 // /proc. The file descriptor in |proc_fd| will be ignored by 41 // /proc. The file descriptor in |proc_fd| will be ignored by
37 // HasOpenDirectory() and remains owned by the caller. It is very important 42 // HasOpenDirectory() and remains owned by the caller. It is very important
38 // for the caller to close it. 43 // for the caller to close it.
39 // If /proc is available, |proc_fd| can be passed as -1. 44 // If /proc is available, |proc_fd| can be passed as -1.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 // process has any directory file descriptor open. 83 // process has any directory file descriptor open.
79 bool DropFileSystemAccess(); 84 bool DropFileSystemAccess();
80 85
81 private: 86 private:
82 DISALLOW_COPY_AND_ASSIGN(Credentials); 87 DISALLOW_COPY_AND_ASSIGN(Credentials);
83 }; 88 };
84 89
85 } // namespace sandbox. 90 } // namespace sandbox.
86 91
87 #endif // SANDBOX_LINUX_SERVICES_CREDENTIALS_H_ 92 #endif // SANDBOX_LINUX_SERVICES_CREDENTIALS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698