OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_ | |
6 #define SERVICES_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_ | |
7 | |
8 #include <memory> | |
9 | |
10 #include "base/files/scoped_file.h" | |
11 #include "base/macros.h" | |
12 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" | |
13 #include "sandbox/linux/bpf_dsl/policy.h" | |
14 #include "sandbox/linux/syscall_broker/broker_process.h" | |
15 | |
16 namespace shell { | |
17 | |
18 // Encapsulates all tasks related to raising the sandbox for mojo runner. | |
19 class LinuxSandbox { | |
20 public: | |
21 explicit LinuxSandbox( | |
22 const std::vector<sandbox::syscall_broker::BrokerFilePermission>& | |
23 permissions); | |
24 ~LinuxSandbox(); | |
25 | |
26 // Grabs a file descriptor to /proc. | |
27 void Warmup(); | |
28 | |
29 // Puts the user in a new PID namespace. | |
30 void EngageNamespaceSandbox(); | |
31 | |
32 // Starts a broker process and sets up seccomp-bpf to delegate decisions to | |
33 // it. | |
34 void EngageSeccompSandbox(); | |
35 | |
36 // Performs the dropping of access to the outside world (drops the reference | |
37 // to /proc acquired in Warmup(). | |
38 void Seal(); | |
39 | |
40 private: | |
41 bool warmed_up_; | |
42 base::ScopedFD proc_fd_; | |
43 std::unique_ptr<sandbox::syscall_broker::BrokerProcess> broker_; | |
44 std::unique_ptr<sandbox::bpf_dsl::Policy> policy_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox); | |
47 }; | |
48 | |
49 } // namespace shell | |
50 | |
51 #endif // SERVICES_SHELL_RUNNER_HOST_LINUX_SANDBOX_H_ | |
OLD | NEW |