blob: 0b838f057d44dc26437429afe12dc6b41ff3c58b [file] [log] [blame]
Elly Jonesa44d22d2012-01-05 18:05:56 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Elly Jones0c016cc2011-12-19 16:19:22 -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_SUBPROCESS_TOOL_H_
6#define DEBUGD_SRC_SUBPROCESS_TOOL_H_
Elly Jones0c016cc2011-12-19 16:19:22 -05007
8#include <map>
Ben Chan23142892017-02-15 12:34:13 -08009#include <memory>
Elly Jones0c016cc2011-12-19 16:19:22 -050010#include <string>
Mike Frysinger56379d72019-02-19 16:03:03 -050011#include <vector>
Elly Jones0c016cc2011-12-19 16:19:22 -050012
Ben Chan657bed82014-09-02 20:40:51 -070013#include <base/macros.h>
Eric Carusocc7106c2017-04-27 14:22:42 -070014#include <brillo/errors/error.h>
Elly Jones0c016cc2011-12-19 16:19:22 -050015
Ben Chan23142892017-02-15 12:34:13 -080016#include "debugd/src/process_with_id.h"
Elly Jones0c016cc2011-12-19 16:19:22 -050017
Ben Chan23142892017-02-15 12:34:13 -080018namespace debugd {
Elly Jones0c016cc2011-12-19 16:19:22 -050019
20class SubprocessTool {
21 public:
Ben Chan78f89532014-08-29 09:35:09 -070022 SubprocessTool() = default;
23 virtual ~SubprocessTool() = default;
Elly Jones0c016cc2011-12-19 16:19:22 -050024
Ben Chan0d840a72018-09-27 00:24:48 -070025 virtual ProcessWithId* CreateProcess(bool sandboxed,
26 bool allow_root_mount_ns);
Mike Frysinger56379d72019-02-19 16:03:03 -050027 virtual ProcessWithId* CreateProcess(
Tom Hughesd6c2d392020-08-24 18:12:11 -070028 bool sandboxed,
29 bool allow_root_mount_ns,
Mike Frysinger56379d72019-02-19 16:03:03 -050030 const std::vector<std::string>& minijail_extra_args);
Jorge Lucangeli Obes623f8ca2014-09-18 10:50:06 -070031
Mike Frysingerf9da3d32017-09-19 23:41:27 -040032 // TODO(vapier): Rework sandboxing so we can re-internalize this function.
33 bool RecordProcess(std::unique_ptr<ProcessWithId> process);
34
Eric Carusocc7106c2017-04-27 14:22:42 -070035 virtual bool Stop(const std::string& handle, brillo::ErrorPtr* error);
Ben Chana0011d82014-05-13 00:19:29 -070036
Elly Jones0c016cc2011-12-19 16:19:22 -050037 private:
Ben Chan23142892017-02-15 12:34:13 -080038 std::map<std::string, std::unique_ptr<ProcessWithId>> processes_;
Ben Chana0011d82014-05-13 00:19:29 -070039
Elly Jones0c016cc2011-12-19 16:19:22 -050040 DISALLOW_COPY_AND_ASSIGN(SubprocessTool);
41};
42
Ben Chana0011d82014-05-13 00:19:29 -070043} // namespace debugd
Elly Jones0c016cc2011-12-19 16:19:22 -050044
Alex Vakulenko262be3f2014-07-30 15:25:50 -070045#endif // DEBUGD_SRC_SUBPROCESS_TOOL_H_