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

Side by Side Diff: content/public/common/sandboxed_process_launcher_delegate.h

Issue 1532423003: Have each SandboxedProcessLauncherDelegate maintain a zygote. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 5 #ifndef CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
6 #define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 6 #define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
7 7
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/files/scoped_file.h" 9 #include "base/files/scoped_file.h"
10 #include "base/process/process.h" 10 #include "base/process/process.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "content/common/content_export.h" 12 #include "content/common/content_export.h"
13 #include "content/public/common/sandbox_type.h" 13 #include "content/public/common/sandbox_type.h"
14 14
15 namespace base { 15 namespace base {
16 class FilePath; 16 class FilePath;
17 } 17 }
18 18
19 namespace sandbox { 19 namespace sandbox {
20 class TargetPolicy; 20 class TargetPolicy;
21 } 21 }
22 22
23 namespace content { 23 namespace content {
24 24
25 #if defined(OS_LINUX)
26 class ZygoteCommunication;
27 using ZygoteHandle = ZygoteCommunication*;
28 #else
29 using ZygoteHandle = std::nullptr_t;
Avi (use Gerrit) 2016/01/06 19:07:56 #include <cstddef>
Greg K 2016/01/06 22:24:21 Done.
30 #endif
31
25 // Allows a caller of StartSandboxedProcess or 32 // Allows a caller of StartSandboxedProcess or
26 // BrowserChildProcessHost/ChildProcessLauncher to control the sandbox policy, 33 // BrowserChildProcessHost/ChildProcessLauncher to control the sandbox policy,
27 // i.e. to loosen it if needed. 34 // i.e. to loosen it if needed.
28 // The methods below will be called on the PROCESS_LAUNCHER thread. 35 // The methods below will be called on the PROCESS_LAUNCHER thread.
29 class CONTENT_EXPORT SandboxedProcessLauncherDelegate { 36 class CONTENT_EXPORT SandboxedProcessLauncherDelegate {
30 public: 37 public:
31 virtual ~SandboxedProcessLauncherDelegate() {} 38 virtual ~SandboxedProcessLauncherDelegate() {}
32 39
33 #if defined(OS_WIN) 40 #if defined(OS_WIN)
34 // Override to return true if the process should be launched as an elevated 41 // Override to return true if the process should be launched as an elevated
35 // process (which implies no sandbox). 42 // process (which implies no sandbox).
36 virtual bool ShouldLaunchElevated(); 43 virtual bool ShouldLaunchElevated();
37 44
38 // By default, the process is launched sandboxed. Override this method to 45 // By default, the process is launched sandboxed. Override this method to
39 // return false if the process should be launched without a sandbox 46 // return false if the process should be launched without a sandbox
40 // (i.e. through base::LaunchProcess directly). 47 // (i.e. through base::LaunchProcess directly).
41 virtual bool ShouldSandbox(); 48 virtual bool ShouldSandbox();
42 49
43 // Whether to disable the default policy specified in 50 // Whether to disable the default policy specified in
44 // AddPolicyForSandboxedProcess. 51 // AddPolicyForSandboxedProcess.
45 virtual bool DisableDefaultPolicy(); 52 virtual bool DisableDefaultPolicy();
46 53
47 // Called right before spawning the process. Returns false on failure. 54 // Called right before spawning the process. Returns false on failure.
48 virtual bool PreSpawnTarget(sandbox::TargetPolicy* policy); 55 virtual bool PreSpawnTarget(sandbox::TargetPolicy* policy);
49 56
50 // Called right after the process is launched, but before its thread is run. 57 // Called right after the process is launched, but before its thread is run.
51 virtual void PostSpawnTarget(base::ProcessHandle process) {} 58 virtual void PostSpawnTarget(base::ProcessHandle process) {}
52 59
53 #elif defined(OS_POSIX) 60 #elif defined(OS_POSIX)
61 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
54 // Override this to return true to use the setuid sandbox. 62 // Override this to return true to use the setuid sandbox.
55 virtual bool ShouldUseZygote(); 63 virtual ZygoteHandle* GetZygote();
64 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID)
56 65
57 // Override this if the process needs a non-empty environment map. 66 // Override this if the process needs a non-empty environment map.
58 virtual base::EnvironmentMap GetEnvironment(); 67 virtual base::EnvironmentMap GetEnvironment();
59 68
60 // Return the file descriptor for the IPC channel. 69 // Return the file descriptor for the IPC channel.
61 virtual base::ScopedFD TakeIpcFd() = 0; 70 virtual base::ScopedFD TakeIpcFd() = 0;
62 #endif 71 #endif
63 72
64 // Returns the SandboxType to enforce on the process, or SANDBOX_TYPE_INVALID 73 // Returns the SandboxType to enforce on the process, or SANDBOX_TYPE_INVALID
65 // for no sandbox policy. 74 // for no sandbox policy.
66 virtual SandboxType GetSandboxType(); 75 virtual SandboxType GetSandboxType();
67 }; 76 };
68 77
69 } // namespace content 78 } // namespace content
70 79
71 #endif // CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_ 80 #endif // CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698