blob: e999a98a98d3b2c54f6c1d9096daa56ef1d02b60 [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
Ben Chana0011d82014-05-13 00:19:29 -07005#ifndef SANDBOXED_PROCESS_H_
6#define SANDBOXED_PROCESS_H_
7
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 Chan297c3c22013-07-17 17:34:12 -070017 virtual ~SandboxedProcess();
18
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
Ben Chana0011d82014-05-13 00:19:29 -070044#endif // SANDBOXED_PROCESS_H_