Index: content/browser/utility_process_host_impl.cc |
diff --git a/content/browser/utility_process_host_impl.cc b/content/browser/utility_process_host_impl.cc |
index 013c62abc7fb62ef67b4232b887dec57be23d9d2..110a7fdcae2bd483013792c4a48d08a307be5aa4 100644 |
--- a/content/browser/utility_process_host_impl.cc |
+++ b/content/browser/utility_process_host_impl.cc |
@@ -23,13 +23,10 @@ |
#include "content/public/browser/utility_process_host_client.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/process_type.h" |
+#include "content/public/common/sandboxed_process_launcher_delegate.h" |
#include "ipc/ipc_switches.h" |
#include "ui/base/ui_base_switches.h" |
-#if defined(OS_WIN) |
-#include "content/public/common/sandboxed_process_launcher_delegate.h" |
-#endif |
- |
namespace content { |
#if defined(OS_WIN) |
@@ -37,20 +34,63 @@ namespace content { |
class UtilitySandboxedProcessLauncherDelegate |
: public SandboxedProcessLauncherDelegate { |
public: |
- explicit UtilitySandboxedProcessLauncherDelegate( |
- const base::FilePath& exposed_dir) : exposed_dir_(exposed_dir) {} |
+ UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, |
+ bool launch_elevated, |
+ bool /*no_sandbox*/, |
+ base::EnvironmentMap& /*env*/, |
+ ChildProcessHost* /*host*/) |
+ : launch_elevated_(launch_elevated), |
+ exposed_dir_(exposed_dir) {} |
+ |
virtual ~UtilitySandboxedProcessLauncherDelegate() {} |
+ virtual bool LaunchElevated() OVERRIDE { |
+ return launch_elevated_; |
+ } |
virtual void PreSandbox(bool* disable_default_policy, |
base::FilePath* exposed_dir) OVERRIDE { |
*exposed_dir = exposed_dir_; |
} |
private: |
+ bool launch_elevated_; |
base::FilePath exposed_dir_; |
}; |
-#endif |
+#elif defined(OS_POSIX) |
+ |
+// NOTE: changes to this class need to be reviewed by the security team. |
+class UtilitySandboxedProcessLauncherDelegate : |
jam
2014/02/26 19:47:52
ditto
aberent
2014/02/28 08:51:07
Done.
|
+ public SandboxedProcessLauncherDelegate { |
+ public: |
+ UtilitySandboxedProcessLauncherDelegate(const base::FilePath& exposed_dir, |
+ bool /*launch_elevated*/, |
+ bool no_sandbox, |
+ base::EnvironmentMap& env, |
+ ChildProcessHost* host) |
+ : exposed_dir_(exposed_dir), |
+ no_sandbox_(no_sandbox), |
+ env_(env), |
+ ipc_fd_(host->TakeClientFileDescriptor()) {} |
+ |
+ virtual ~UtilitySandboxedProcessLauncherDelegate() {} |
+ |
+ virtual bool UseZygote() OVERRIDE { |
+ return !no_sandbox_ && exposed_dir_.empty(); |
+ } |
+ virtual base::EnvironmentMap GetEnvironment() OVERRIDE { |
+ return env_; |
+ } |
+ virtual int IpcFd() OVERRIDE { |
+ return ipc_fd_; |
+ } |
+private: |
+ base::FilePath exposed_dir_; |
+ bool no_sandbox_; |
+ base::EnvironmentMap env_; |
+ int ipc_fd_; |
+}; |
+#endif // OS_WIN |
UtilityMainThreadFactoryFunction g_utility_main_thread_factory = NULL; |
@@ -73,9 +113,7 @@ UtilityProcessHostImpl::UtilityProcessHostImpl( |
is_batch_mode_(false), |
is_mdns_enabled_(false), |
no_sandbox_(false), |
-#if defined(OS_WIN) |
run_elevated_(false), |
-#endif |
#if defined(OS_LINUX) |
child_flags_(ChildProcessHost::CHILD_ALLOW_SELF), |
#else |
@@ -226,22 +264,11 @@ bool UtilityProcessHostImpl::StartProcess() { |
cmd_line->AppendSwitch(switches::kUtilityProcessRunningElevated); |
#endif |
- bool use_zygote = false; |
- |
-#if defined(OS_LINUX) |
- // The Linux sandbox does not support granting access to a single directory, |
- // so we need to bypass the zygote in that case. |
- use_zygote = !no_sandbox_ && exposed_dir_.empty(); |
-#endif |
- |
process_->Launch( |
-#if defined(OS_WIN) |
- new UtilitySandboxedProcessLauncherDelegate(exposed_dir_), |
- run_elevated_, |
-#elif defined(OS_POSIX) |
- use_zygote, |
- env_, |
-#endif |
+ new UtilitySandboxedProcessLauncherDelegate(exposed_dir_, |
+ run_elevated_, |
+ no_sandbox_, env_, |
+ process_->GetHost()), |
cmd_line); |
} |