OLD | NEW |
---|---|
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 #include "content/browser/browser_main_loop.h" | 5 #include "content/browser/browser_main_loop.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 // One of the linux specific headers defines this as a macro. | 187 // One of the linux specific headers defines this as a macro. |
188 #ifdef DestroyAll | 188 #ifdef DestroyAll |
189 #undef DestroyAll | 189 #undef DestroyAll |
190 #endif | 190 #endif |
191 | 191 |
192 namespace content { | 192 namespace content { |
193 namespace { | 193 namespace { |
194 | 194 |
195 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 195 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
196 void SetupSandbox(const base::CommandLine& parsed_command_line) { | 196 void TickleSandbox() { |
197 TRACE_EVENT0("startup", "SetupSandbox"); | |
198 base::FilePath sandbox_binary; | |
199 | |
200 scoped_ptr<sandbox::SetuidSandboxHost> setuid_sandbox_host( | |
201 sandbox::SetuidSandboxHost::Create()); | |
202 | |
203 const bool want_setuid_sandbox = | |
204 !parsed_command_line.HasSwitch(switches::kNoSandbox) && | |
205 !parsed_command_line.HasSwitch(switches::kDisableSetuidSandbox) && | |
206 !setuid_sandbox_host->IsDisabledViaEnvironment(); | |
207 | |
208 static const char no_suid_error[] = | |
209 "Running without the SUID sandbox! See " | |
210 "https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_s andbox_development.md " | |
211 "for more information on developing with the sandbox on."; | |
212 if (want_setuid_sandbox) { | |
213 sandbox_binary = setuid_sandbox_host->GetSandboxBinaryPath(); | |
214 if (sandbox_binary.empty()) { | |
215 // This needs to be fatal. Talk to security@chromium.org if you feel | |
216 // otherwise. | |
217 LOG(FATAL) << no_suid_error; | |
218 } | |
219 } else { | |
220 LOG(ERROR) << no_suid_error; | |
221 } | |
Dirk Pranke
2016/03/29 21:17:47
Do we need to keep this logic on ChromeOS (i.e., c
| |
222 | |
223 // Tickle the sandbox host and zygote host so they fork now. | |
224 RenderSandboxHostLinux::GetInstance()->Init(); | 197 RenderSandboxHostLinux::GetInstance()->Init(); |
225 ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value()); | 198 // ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value()); |
mdempsky
2016/03/29 19:02:47
We still need to call Init here.
| |
226 *GetGenericZygote() = CreateZygote(); | 199 *GetGenericZygote() = CreateZygote(); |
227 RenderProcessHostImpl::EarlyZygoteLaunch(); | 200 RenderProcessHostImpl::EarlyZygoteLaunch(); |
228 } | 201 } |
229 #endif | 202 #endif |
230 | |
231 #if defined(USE_GLIB) | 203 #if defined(USE_GLIB) |
232 static void GLibLogHandler(const gchar* log_domain, | 204 static void GLibLogHandler(const gchar* log_domain, |
233 GLogLevelFlags log_level, | 205 GLogLevelFlags log_level, |
234 const gchar* message, | 206 const gchar* message, |
235 gpointer userdata) { | 207 gpointer userdata) { |
236 if (!log_domain) | 208 if (!log_domain) |
237 log_domain = "<unknown>"; | 209 log_domain = "<unknown>"; |
238 if (!message) | 210 if (!message) |
239 message = "<no message>"; | 211 message = "<no message>"; |
240 | 212 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); | 405 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); |
434 } | 406 } |
435 | 407 |
436 // BrowserMainLoop stages ================================================== | 408 // BrowserMainLoop stages ================================================== |
437 | 409 |
438 void BrowserMainLoop::EarlyInitialization() { | 410 void BrowserMainLoop::EarlyInitialization() { |
439 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); | 411 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); |
440 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::EarlyInitialization"); | 412 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::EarlyInitialization"); |
441 | 413 |
442 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 414 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
443 // No thread should be created before this call, as SetupSandbox() | 415 TickleSandbox(); |
444 // will end-up using fork(). | |
445 SetupSandbox(parsed_command_line_); | |
446 #endif | 416 #endif |
447 | |
448 #if defined(USE_X11) | 417 #if defined(USE_X11) |
449 if (UsingInProcessGpu()) { | 418 if (UsingInProcessGpu()) { |
450 if (!gfx::InitializeThreadedX11()) { | 419 if (!gfx::InitializeThreadedX11()) { |
451 LOG(ERROR) << "Failed to put Xlib into threaded mode."; | 420 LOG(ERROR) << "Failed to put Xlib into threaded mode."; |
452 } | 421 } |
453 } | 422 } |
454 #endif | 423 #endif |
455 | 424 |
456 // GLib's spawning of new processes is buggy, so it's important that at this | 425 // GLib's spawning of new processes is buggy, so it's important that at this |
457 // point GLib does not need to start DBUS. Chrome should always start with | 426 // point GLib does not need to start DBUS. Chrome should always start with |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1446 DCHECK(is_tracing_startup_for_duration_); | 1415 DCHECK(is_tracing_startup_for_duration_); |
1447 | 1416 |
1448 is_tracing_startup_for_duration_ = false; | 1417 is_tracing_startup_for_duration_ = false; |
1449 TracingController::GetInstance()->StopTracing( | 1418 TracingController::GetInstance()->StopTracing( |
1450 TracingController::CreateFileSink( | 1419 TracingController::CreateFileSink( |
1451 startup_trace_file_, | 1420 startup_trace_file_, |
1452 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1421 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1453 } | 1422 } |
1454 | 1423 |
1455 } // namespace content | 1424 } // namespace content |
OLD | NEW |