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

Side by Side Diff: content/utility/utility_main.cc

Issue 10920057: Linux: initialize the sandbox in the utility process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « content/common/sandbox_seccomp_bpf_linux.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/hi_res_timer_manager.h" 6 #include "base/hi_res_timer_manager.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/system_monitor/system_monitor.h" 8 #include "base/system_monitor/system_monitor.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "content/common/child_process.h" 10 #include "content/common/child_process.h"
11 #include "content/public/common/content_switches.h" 11 #include "content/public/common/content_switches.h"
12 #include "content/public/common/main_function_params.h" 12 #include "content/public/common/main_function_params.h"
13 #include "content/public/common/sandbox_init.h"
13 #include "content/utility/utility_thread_impl.h" 14 #include "content/utility/utility_thread_impl.h"
14 15
15 #if defined(OS_WIN) 16 #if defined(OS_WIN)
16 #include "sandbox/win/src/sandbox.h" 17 #include "sandbox/win/src/sandbox.h"
17 #endif 18 #endif
18 19
19 // Mainline routine for running as the utility process. 20 // Mainline routine for running as the utility process.
20 int UtilityMain(const content::MainFunctionParams& parameters) { 21 int UtilityMain(const content::MainFunctionParams& parameters) {
21 // The main message loop of the utility process. 22 // The main message loop of the utility process.
22 MessageLoop main_message_loop; 23 MessageLoop main_message_loop;
23 base::PlatformThread::SetName("CrUtilityMain"); 24 base::PlatformThread::SetName("CrUtilityMain");
24 25
25 base::SystemMonitor system_monitor; 26 base::SystemMonitor system_monitor;
26 HighResolutionTimerManager hi_res_timer_manager; 27 HighResolutionTimerManager hi_res_timer_manager;
27 28
29 #if defined(OS_LINUX)
30 // Initialize the sandbox before any thread is created.
31 content::InitializeSandbox();
32 #endif
33
28 ChildProcess utility_process; 34 ChildProcess utility_process;
29 utility_process.set_main_thread(new UtilityThreadImpl()); 35 utility_process.set_main_thread(new UtilityThreadImpl());
30 36
31 #if defined(OS_WIN) 37 #if defined(OS_WIN)
32 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox); 38 bool no_sandbox = parameters.command_line.HasSwitch(switches::kNoSandbox);
33 if (!no_sandbox) { 39 if (!no_sandbox) {
34 sandbox::TargetServices* target_services = 40 sandbox::TargetServices* target_services =
35 parameters.sandbox_info->target_services; 41 parameters.sandbox_info->target_services;
36 if (!target_services) 42 if (!target_services)
37 return false; 43 return false;
38 target_services->LowerToken(); 44 target_services->LowerToken();
39 } 45 }
40 #endif 46 #endif
41 47
42 MessageLoop::current()->Run(); 48 MessageLoop::current()->Run();
43 49
44 return 0; 50 return 0;
45 } 51 }
OLDNEW
« no previous file with comments | « content/common/sandbox_seccomp_bpf_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698