blob: d2fc592a8bc9d79fa639b9abe277da75d5431161 [file] [log] [blame]
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -05001// Copyright (c) 2012 The Chromium OS 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
Alex Vakulenko262be3f2014-07-30 15:25:50 -07005#ifndef DEBUGD_SRC_SANDBOXED_PROCESS_H_
6#define DEBUGD_SRC_SANDBOXED_PROCESS_H_
Ben Chana0011d82014-05-13 00:19:29 -07007
8#include <string>
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -05009
10#include <chromeos/process.h>
11
12namespace debugd {
13
14class SandboxedProcess : public chromeos::ProcessImpl {
15 public:
16 SandboxedProcess();
Ben Chan78f89532014-08-29 09:35:09 -070017 ~SandboxedProcess() override = default;
Ben Chan297c3c22013-07-17 17:34:12 -070018
19 // Get the full path of a helper executable located at the |relative_path|
20 // relative to the debugd helpers directory. Return false if the full path
21 // is too long.
22 static bool GetHelperPath(const std::string& relative_path,
23 std::string* full_path);
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050024
25 virtual bool Init();
26
27 // Disable the default sandboxing for this process
28 virtual void DisableSandbox();
29
30 // Change the default sandboxing for this process
31 virtual void SandboxAs(const std::string& user, const std::string& group);
32
Elly Fong-Jones215b5622013-03-20 14:32:18 -040033 static const char *kDefaultUser;
34 static const char *kDefaultGroup;
35
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050036 private:
37 bool sandboxing_;
38 std::string user_;
39 std::string group_;
40};
41
Ben Chana0011d82014-05-13 00:19:29 -070042} // namespace debugd
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050043
Alex Vakulenko262be3f2014-07-30 15:25:50 -070044#endif // DEBUGD_SRC_SANDBOXED_PROCESS_H_