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

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

Issue 11557025: Linux sandbox: add a new low-level broker process mechanism. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move implementation constants out of interface. Created 8 years 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
(Empty)
1 #ifndef SANDBOX_LINUX_SERVICES_BROKER_PROCESS_H_
2 #define SANDBOX_LINUX_SERVICES_BROKER_PROCESS_H_
3
4 #include <string>
5 #include <vector>
6
7 #include "base/basictypes.h"
8 #include "base/process.h"
9
10 namespace sandbox {
11
12 // Create a new "broker" process to which we can send requests via an IPC
13 // channel.
14 // This is a low level IPC mechanism that is suitable to be called from a
15 // signal handler.
16 // A process would typically create a broker process before entering
17 // sandboxing.
18 // 1. BrokerProcess open_broker(file_whitelist);
19 // 2. CHECK(open_broker.Init(NULL));
20 // 3. Enable sandbox.
21 // 4. Use open_broker.Open() to open files.
22 class BrokerProcess {
23 public:
24 // |allowed_file_names| is a white list of files that can be opened later via
25 // the Open() API.
26 // |fast_check_in_client| is reserved for unit tests, don't use it.
27 explicit BrokerProcess(const std::vector<std::string>& allowed_file_names,
28 bool fast_check_in_client = true);
29 ~BrokerProcess();
30 // Will initialize the broker process. There should be no threads at this
31 // point, since we need to fork().
32 // sandbox_callback should be NULL as this feature is not implemented yet.
33 bool Init(void* sandbox_callback);
34
35 // Can be used in lieu of open(). Will be async signal safe.
Jorge Lucangeli Obes 2012/12/13 04:46:33 Nit: In place?
36 // The implementation only supports O_RDONLY for now.
37 // It's similar to the open() system call and will return -errno.
38 int Open(const char* pathname, int flags) const;
39
40 int broker_pid() const { return broker_pid_; }
41
42 private:
43 bool initialized_; // Whether we've been through Init() yet.
44 bool is_child_; // Whether we're the child (broker process).
45 bool fast_check_in_client_; // Whether to forward a request that we know
46 // will be denied to the broker.
47 pid_t broker_pid_; // The PID of the broker (child).
48 std::vector<std::string> allowed_file_names_;
49 int ipc_socketpair_; // Our communication channel to parent or child.
50 DISALLOW_IMPLICIT_CONSTRUCTORS(BrokerProcess);
51 };
52
53 } // namespace sandbox
54
55 #endif // SANDBOX_LINUX_SERVICES_BROKER_PROCESS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698