blob: a4941ed284246a8f860a5c10cd632952b4cd4911 [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
Jorge Lucangeli Obesc99a12a2014-09-17 16:43:40 -070027 // Disable the default sandboxing for this process.
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050028 virtual void DisableSandbox();
29
Jorge Lucangeli Obesc99a12a2014-09-17 16:43:40 -070030 // Change the default sandboxing for this process.
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050031 virtual void SandboxAs(const std::string& user, const std::string& group);
32
Jorge Lucangeli Obesc99a12a2014-09-17 16:43:40 -070033 // Allow this process to access the root mount namespace.
34 virtual void AllowAccessRootMountNamespace();
35
Elly Fong-Jones215b5622013-03-20 14:32:18 -040036 static const char *kDefaultUser;
37 static const char *kDefaultGroup;
38
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050039 private:
40 bool sandboxing_;
Jorge Lucangeli Obesc99a12a2014-09-17 16:43:40 -070041 bool access_root_mount_ns_;
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050042 std::string user_;
43 std::string group_;
44};
45
Ben Chana0011d82014-05-13 00:19:29 -070046} // namespace debugd
Elly Fong-Jonesd9a16cd2012-11-12 16:09:49 -050047
Alex Vakulenko262be3f2014-07-30 15:25:50 -070048#endif // DEBUGD_SRC_SANDBOXED_PROCESS_H_