| 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_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_LINUX_SANDBOX_H_ | |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_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 service_manager { | |
| 17 | |
| 18 // Encapsulates all tasks related to raising the sandbox for a standalone | |
| 19 // service. | |
| 20 class LinuxSandbox { | |
| 21 public: | |
| 22 explicit LinuxSandbox( | |
| 23 const std::vector<sandbox::syscall_broker::BrokerFilePermission>& | |
| 24 permissions); | |
| 25 ~LinuxSandbox(); | |
| 26 | |
| 27 // Grabs a file descriptor to /proc. | |
| 28 void Warmup(); | |
| 29 | |
| 30 // Puts the user in a new PID namespace. | |
| 31 void EngageNamespaceSandbox(); | |
| 32 | |
| 33 // Starts a broker process and sets up seccomp-bpf to delegate decisions to | |
| 34 // it. | |
| 35 void EngageSeccompSandbox(); | |
| 36 | |
| 37 // Performs the dropping of access to the outside world (drops the reference | |
| 38 // to /proc acquired in Warmup(). | |
| 39 void Seal(); | |
| 40 | |
| 41 private: | |
| 42 bool warmed_up_; | |
| 43 base::ScopedFD proc_fd_; | |
| 44 std::unique_ptr<sandbox::syscall_broker::BrokerProcess> broker_; | |
| 45 std::unique_ptr<sandbox::bpf_dsl::Policy> policy_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(LinuxSandbox); | |
| 48 }; | |
| 49 | |
| 50 } // namespace service_manager | |
| 51 | |
| 52 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_STANDALONE_SERVICE_LINUX_SANDBOX_
H_ | |
| OLD | NEW |