blob: ac2b5c4063240f155afe3186ac1ad5170a4f0177 [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jonese7cb5b32011-12-01 14:18:32 -05002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_PROCESS_WITH_ID_H_
6#define DEBUGD_SRC_PROCESS_WITH_ID_H_
Ben Chana0011d82014-05-13 00:19:29 -07007
8#include <string>
Mike Frysinger56379d72019-02-19 16:03:03 -05009#include <vector>
Elly Jonese7cb5b32011-12-01 14:18:32 -050010
Alex Vakulenko262be3f2014-07-30 15:25:50 -070011#include "debugd/src/sandboxed_process.h"
Elly Jonese7cb5b32011-12-01 14:18:32 -050012
13namespace 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-Jonesd9a16cd2012-11-12 16:09:49 -050019class ProcessWithId : public SandboxedProcess {
Elly Jonese7cb5b32011-12-01 14:18:32 -050020 public:
Ben Chan78f89532014-08-29 09:35:09 -070021 ProcessWithId() = default;
22 ~ProcessWithId() override = default;
Ben Chan4b110122014-08-29 08:22:59 -070023
24 bool Init() override;
Mike Frysinger56379d72019-02-19 16:03:03 -050025 bool Init(const std::vector<std::string>& minijail_extra_args) override;
Ben Chan4b110122014-08-29 08:22:59 -070026
Ben Chana0011d82014-05-13 00:19:29 -070027 const std::string& id() const { return id_; }
28
Elly Jonese7cb5b32011-12-01 14:18:32 -050029 private:
Ben Chan92f092e2017-02-15 11:55:47 -080030 void GenerateId();
Ben Chan4b110122014-08-29 08:22:59 -070031
Elly Jonese7cb5b32011-12-01 14:18:32 -050032 std::string id_;
33};
34
Ben Chana0011d82014-05-13 00:19:29 -070035} // namespace debugd
Elly Jonese7cb5b32011-12-01 14:18:32 -050036
Alex Vakulenko262be3f2014-07-30 15:25:50 -070037#endif // DEBUGD_SRC_PROCESS_WITH_ID_H_