OLD | NEW |
---|---|
(Empty) | |
1 #ifndef SANDBOX_LINUX_SERVICES_OPEN_BROKER_H_ | |
2 #define SANDBOX_LINUX_SERVICES_OPEN_BROKER_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 static const int kMaxMessageLength = 4096; | |
25 static const int kCommandOpen = 'O'; | |
26 | |
27 // allowed_file_names is a white list of files that can be opened later via | |
28 // the Open() API. | |
29 explicit BrokerProcess(const std::vector<std::string>& allowed_file_names); | |
30 // The constructor below should be reserved for unit tests. | |
31 BrokerProcess(const std::vector<std::string>& allowed_file_names, | |
32 bool fast_check_in_client); | |
33 ~BrokerProcess(); | |
34 // Will initialize the broker process. There should be no threads at this | |
35 // point, since we need to fork(). | |
36 // sandbox_callback should be NULL as this feature is not implemented yet. | |
37 bool Init(void* sandbox_callback); | |
38 | |
39 // Can be used in lieu of open(). Will be async signal safe. | |
40 // The implementation only supports O_RDONLY for now. | |
Jorge Lucangeli Obes
2012/12/13 02:14:54
I need to check if the /dev/dri/card0 thing libva
jln (very slow on Chromium)
2012/12/13 02:33:14
Ok. It's trivial to add support for RD_WRITE anywa
Jorge Lucangeli Obes (Google)
2012/12/13 04:28:52
Confirmed libva is opening /dev/dri/card0 O_RDWR.
| |
41 // It's similar to the open() system call and will return -errno. | |
42 int Open(const char* pathname, int flags) const; | |
43 | |
44 int broker_pid() const { return broker_pid_; } | |
45 | |
46 private: | |
47 BrokerProcess(); | |
48 bool initialized_; // Whether we've been through Init() yet. | |
49 bool is_child_; // Whether we're the child (broker process). | |
50 bool fast_check_in_client_; // Whether to forward a request that we know | |
51 // will be denied to the broker. | |
52 pid_t broker_pid_; // The PID of the broker (child). | |
53 std::vector<std::string> allowed_file_names_; | |
54 int ipc_socketpair_; // Our communication channel to parent or child. | |
55 DISALLOW_COPY_AND_ASSIGN(BrokerProcess); | |
56 }; | |
57 | |
58 } // namespace sandbox | |
59 | |
60 #endif // SANDBOX_LINUX_SERVICES_OPEN_BROKER_H_ | |
OLD | NEW |