Elly Jones | a44d22d | 2012-01-05 18:05:56 -0500 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 5 | #ifndef DEBUGD_SRC_SUBPROCESS_TOOL_H_ |
| 6 | #define DEBUGD_SRC_SUBPROCESS_TOOL_H_ |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 7 | |
| 8 | #include <map> |
Ben Chan | 2314289 | 2017-02-15 12:34:13 -0800 | [diff] [blame] | 9 | #include <memory> |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 10 | #include <string> |
Mike Frysinger | 56379d7 | 2019-02-19 16:03:03 -0500 | [diff] [blame] | 11 | #include <vector> |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 12 | |
Ben Chan | 657bed8 | 2014-09-02 20:40:51 -0700 | [diff] [blame] | 13 | #include <base/macros.h> |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 14 | #include <brillo/errors/error.h> |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 15 | |
Ben Chan | 2314289 | 2017-02-15 12:34:13 -0800 | [diff] [blame] | 16 | #include "debugd/src/process_with_id.h" |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 17 | |
Ben Chan | 2314289 | 2017-02-15 12:34:13 -0800 | [diff] [blame] | 18 | namespace debugd { |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 19 | |
| 20 | class SubprocessTool { |
| 21 | public: |
Ben Chan | 78f8953 | 2014-08-29 09:35:09 -0700 | [diff] [blame] | 22 | SubprocessTool() = default; |
Qijiang Fan | 6bc59e1 | 2020-11-11 02:51:06 +0900 | [diff] [blame^] | 23 | SubprocessTool(const SubprocessTool&) = delete; |
| 24 | SubprocessTool& operator=(const SubprocessTool&) = delete; |
| 25 | |
Ben Chan | 78f8953 | 2014-08-29 09:35:09 -0700 | [diff] [blame] | 26 | virtual ~SubprocessTool() = default; |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 27 | |
Ben Chan | 0d840a7 | 2018-09-27 00:24:48 -0700 | [diff] [blame] | 28 | virtual ProcessWithId* CreateProcess(bool sandboxed, |
| 29 | bool allow_root_mount_ns); |
Mike Frysinger | 56379d7 | 2019-02-19 16:03:03 -0500 | [diff] [blame] | 30 | virtual ProcessWithId* CreateProcess( |
Tom Hughes | d6c2d39 | 2020-08-24 18:12:11 -0700 | [diff] [blame] | 31 | bool sandboxed, |
| 32 | bool allow_root_mount_ns, |
Mike Frysinger | 56379d7 | 2019-02-19 16:03:03 -0500 | [diff] [blame] | 33 | const std::vector<std::string>& minijail_extra_args); |
Jorge Lucangeli Obes | 623f8ca | 2014-09-18 10:50:06 -0700 | [diff] [blame] | 34 | |
Mike Frysinger | f9da3d3 | 2017-09-19 23:41:27 -0400 | [diff] [blame] | 35 | // TODO(vapier): Rework sandboxing so we can re-internalize this function. |
| 36 | bool RecordProcess(std::unique_ptr<ProcessWithId> process); |
| 37 | |
Eric Caruso | cc7106c | 2017-04-27 14:22:42 -0700 | [diff] [blame] | 38 | virtual bool Stop(const std::string& handle, brillo::ErrorPtr* error); |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 39 | |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 40 | private: |
Ben Chan | 2314289 | 2017-02-15 12:34:13 -0800 | [diff] [blame] | 41 | std::map<std::string, std::unique_ptr<ProcessWithId>> processes_; |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 42 | }; |
| 43 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 44 | } // namespace debugd |
Elly Jones | 0c016cc | 2011-12-19 16:19:22 -0500 | [diff] [blame] | 45 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 46 | #endif // DEBUGD_SRC_SUBPROCESS_TOOL_H_ |