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 | e7cb5b3 | 2011-12-01 14:18:32 -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_PROCESS_WITH_ID_H_ |
| 6 | #define DEBUGD_SRC_PROCESS_WITH_ID_H_ |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 7 | |
| 8 | #include <string> |
Mike Frysinger | 56379d7 | 2019-02-19 16:03:03 -0500 | [diff] [blame] | 9 | #include <vector> |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 10 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 11 | #include "debugd/src/sandboxed_process.h" |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 12 | |
| 13 | namespace debugd { |
| 14 | |
| 15 | // @brief Represents a process with an immutable ID. |
| 16 | // |
| 17 | // The ID is random, unguessable, and may be given to other processes. It is a |
| 18 | // null-terminated ASCII string. |
Elly Fong-Jones | d9a16cd | 2012-11-12 16:09:49 -0500 | [diff] [blame] | 19 | class ProcessWithId : public SandboxedProcess { |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 20 | public: |
Ben Chan | 78f8953 | 2014-08-29 09:35:09 -0700 | [diff] [blame] | 21 | ProcessWithId() = default; |
| 22 | ~ProcessWithId() override = default; |
Ben Chan | 4b11012 | 2014-08-29 08:22:59 -0700 | [diff] [blame] | 23 | |
| 24 | bool Init() override; |
Mike Frysinger | 56379d7 | 2019-02-19 16:03:03 -0500 | [diff] [blame] | 25 | bool Init(const std::vector<std::string>& minijail_extra_args) override; |
Ben Chan | 4b11012 | 2014-08-29 08:22:59 -0700 | [diff] [blame] | 26 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 27 | const std::string& id() const { return id_; } |
| 28 | |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 29 | private: |
Ben Chan | 92f092e | 2017-02-15 11:55:47 -0800 | [diff] [blame] | 30 | void GenerateId(); |
Ben Chan | 4b11012 | 2014-08-29 08:22:59 -0700 | [diff] [blame] | 31 | |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 32 | std::string id_; |
| 33 | }; |
| 34 | |
Ben Chan | a0011d8 | 2014-05-13 00:19:29 -0700 | [diff] [blame] | 35 | } // namespace debugd |
Elly Jones | e7cb5b3 | 2011-12-01 14:18:32 -0500 | [diff] [blame] | 36 | |
Alex Vakulenko | 262be3f | 2014-07-30 15:25:50 -0700 | [diff] [blame] | 37 | #endif // DEBUGD_SRC_PROCESS_WITH_ID_H_ |