Commit 6e33c86b authored by jorgelo@chromium.org's avatar jorgelo@chromium.org

Add a mechanism to launch the utility process from the zygote on Linux.

Allow the users of the utility process to specify whether the zygote
should be used on Linux. This will allow sandboxing the uses of the
utility process that don't do FS access.

This is the first step to get the utility process sandboxed
on Linux. Since most of the uses of the utility process
don't do file access, launching all of those from the zygote
will simplify sandboxing the one that does: extension
unpacking.

Subsequent CLs will port the uses of the utility process
that don't do file access to launch from the zygote.

BUG=93109
TEST=No functional changes yet, but test that nothing broke by
running browser_tests::ExtensionWebstorePrivateApiTest.* and also
logging into Chromium and installing an extension from the Web Store.


Review URL: http://codereview.chromium.org/8849007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113914 0039d316-1c4b-4281-b951-d872f2087c98
parent 4079fe0c
...@@ -192,6 +192,7 @@ int RunZygote(const content::MainFunctionParams& main_function_params, ...@@ -192,6 +192,7 @@ int RunZygote(const content::MainFunctionParams& main_function_params,
{ switches::kRendererProcess, RendererMain }, { switches::kRendererProcess, RendererMain },
{ switches::kWorkerProcess, WorkerMain }, { switches::kWorkerProcess, WorkerMain },
{ switches::kPpapiPluginProcess, PpapiPluginMain }, { switches::kPpapiPluginProcess, PpapiPluginMain },
{ switches::kUtilityProcess, UtilityMain },
}; };
scoped_ptr<content::ZygoteForkDelegate> zygote_fork_delegate; scoped_ptr<content::ZygoteForkDelegate> zygote_fork_delegate;
......
...@@ -46,6 +46,7 @@ UtilityProcessHost::UtilityProcessHost(Client* client, ...@@ -46,6 +46,7 @@ UtilityProcessHost::UtilityProcessHost(Client* client,
#else #else
child_flags_(ChildProcessHost::CHILD_NORMAL), child_flags_(ChildProcessHost::CHILD_NORMAL),
#endif #endif
use_linux_zygote_(false),
started_(false) { started_(false) {
} }
...@@ -129,11 +130,17 @@ bool UtilityProcessHost::StartProcess() { ...@@ -129,11 +130,17 @@ bool UtilityProcessHost::StartProcess() {
cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_); cmd_line->AppendSwitchPath(switches::kUtilityProcessAllowedDir, exposed_dir_);
#endif #endif
bool use_zygote = false;
#if defined(OS_LINUX)
use_zygote = !no_sandbox_ && use_linux_zygote_;
#endif
Launch( Launch(
#if defined(OS_WIN) #if defined(OS_WIN)
exposed_dir_, exposed_dir_,
#elif defined(OS_POSIX) #elif defined(OS_POSIX)
false, use_zygote,
env_, env_,
#endif #endif
cmd_line); cmd_line);
......
...@@ -66,6 +66,7 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost { ...@@ -66,6 +66,7 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost {
void set_exposed_dir(const FilePath& dir) { exposed_dir_ = dir; } void set_exposed_dir(const FilePath& dir) { exposed_dir_ = dir; }
void set_no_sandbox(bool flag) { no_sandbox_ = flag; } void set_no_sandbox(bool flag) { no_sandbox_ = flag; }
void set_child_flags(int flags) { child_flags_ = flags; } void set_child_flags(int flags) { child_flags_ = flags; }
void set_use_linux_zygote(bool flag) { use_linux_zygote_ = flag; }
#if defined(OS_POSIX) #if defined(OS_POSIX)
void set_env(const base::environment_vector& env) { env_ = env; } void set_env(const base::environment_vector& env) { env_ = env; }
#endif #endif
...@@ -102,6 +103,11 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost { ...@@ -102,6 +103,11 @@ class CONTENT_EXPORT UtilityProcessHost : public BrowserChildProcessHost {
// Flags defined in ChildProcessHost with which to start the process. // Flags defined in ChildProcessHost with which to start the process.
int child_flags_; int child_flags_;
// If the |no_sandbox_| flag is off, and we are on Linux, launch the
// utility process from the zygote. Defaults to false.
// Can only be used for tasks that do not require FS access.
bool use_linux_zygote_;
base::environment_vector env_; base::environment_vector env_;
bool started_; bool started_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment