Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: sandbox/linux/suid/client/setuid_sandbox_host.h

Issue 903273002: Update from https://crrev.com/315085 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium 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
5 #ifndef SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_
6 #define SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_
7
8 #include "base/files/file_path.h"
9 #include "base/files/scoped_file.h"
10 #include "base/macros.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/process/launch.h"
13 #include "sandbox/sandbox_export.h"
14
15 namespace sandbox {
16
17 // Helper class to use the setuid sandbox. This class is to be used
18 // before launching the setuid helper.
19 // This class is difficult to use. It has been created by refactoring very old
20 // code scathered through the Chromium code base.
21 //
22 // A typical use for "A" launching a sandboxed process "B" would be:
23 // 1. A calls SetupLaunchEnvironment()
24 // 2. A sets up a base::CommandLine and then amends it with
25 // PrependWrapper() (or manually, by relying on GetSandboxBinaryPath()).
26 // 3. A uses SetupLaunchOptions() to arrange for a dummy descriptor for the
27 // setuid sandbox ABI.
28 // 4. A launches B with base::LaunchProcess, using the amended
29 // base::CommandLine.
30 // (The remaining steps are described within setuid_sandbox_client.h.)
31 class SANDBOX_EXPORT SetuidSandboxHost {
32 public:
33 // All instantation should go through this factory method.
34 static SetuidSandboxHost* Create();
35 ~SetuidSandboxHost();
36
37 // The setuid sandbox may still be disabled via the environment.
38 // This is tracked in crbug.com/245376.
39 bool IsDisabledViaEnvironment();
40 // Get the sandbox binary path. This method knows about the
41 // CHROME_DEVEL_SANDBOX environment variable used for user-managed builds. If
42 // the sandbox binary cannot be found, it will return an empty FilePath.
43 base::FilePath GetSandboxBinaryPath();
44 // Modify |cmd_line| to launch via the setuid sandbox. Crash if the setuid
45 // sandbox binary cannot be found. |cmd_line| must not be NULL.
46 void PrependWrapper(base::CommandLine* cmd_line);
47 // Set-up the launch options for launching via the setuid sandbox. Caller is
48 // responsible for keeping |dummy_fd| alive until LaunchProcess() completes.
49 // |options| and |fds_to_remap| must not be NULL.
50 // (Keeping |dummy_fd| alive is an unfortunate historical artifact of the
51 // chrome-sandbox ABI.)
52 void SetupLaunchOptions(base::LaunchOptions* options,
53 base::FileHandleMappingVector* fds_to_remap,
54 base::ScopedFD* dummy_fd);
55 // Set-up the environment. This should be done prior to launching the setuid
56 // helper.
57 void SetupLaunchEnvironment();
58
59 private:
60 explicit SetuidSandboxHost(base::Environment* env);
61
62 // Holds the environment. Will never be NULL.
63 scoped_ptr<base::Environment> env_;
64
65 DISALLOW_COPY_AND_ASSIGN(SetuidSandboxHost);
66 };
67
68 } // namespace sandbox
69
70 #endif // SANDBOX_LINUX_SUID_SETUID_SANDBOX_HOST_H_
OLDNEW
« no previous file with comments | « sandbox/linux/suid/client/setuid_sandbox_client_unittest.cc ('k') | sandbox/linux/suid/client/setuid_sandbox_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698