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...) 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 SetupSandbox() { |
197 TRACE_EVENT0("startup", "SetupSandbox"); | |
198 base::FilePath sandbox_binary; | 197 base::FilePath sandbox_binary; |
199 | |
200 scoped_ptr<sandbox::SetuidSandboxHost> setuid_sandbox_host( | |
mdempsky
2016/03/30 19:10:41
We still need this code for Chrome OS. You can't
| |
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 } | |
222 | |
223 // Tickle the sandbox host and zygote host so they fork now. | |
224 RenderSandboxHostLinux::GetInstance()->Init(); | 198 RenderSandboxHostLinux::GetInstance()->Init(); |
225 ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value()); | 199 ZygoteHostImpl::GetInstance()->Init(sandbox_binary.value()); |
226 *GetGenericZygote() = CreateZygote(); | 200 *GetGenericZygote() = CreateZygote(); |
227 RenderProcessHostImpl::EarlyZygoteLaunch(); | 201 RenderProcessHostImpl::EarlyZygoteLaunch(); |
228 } | 202 } |
229 #endif | 203 #endif |
230 | |
231 #if defined(USE_GLIB) | 204 #if defined(USE_GLIB) |
232 static void GLibLogHandler(const gchar* log_domain, | 205 static void GLibLogHandler(const gchar* log_domain, |
233 GLogLevelFlags log_level, | 206 GLogLevelFlags log_level, |
234 const gchar* message, | 207 const gchar* message, |
235 gpointer userdata) { | 208 gpointer userdata) { |
236 if (!log_domain) | 209 if (!log_domain) |
237 log_domain = "<unknown>"; | 210 log_domain = "<unknown>"; |
238 if (!message) | 211 if (!message) |
239 message = "<no message>"; | 212 message = "<no message>"; |
240 | 213 |
(...skipping 192 matching lines...) Loading... | |
433 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); | 406 GetContentClient()->browser()->CreateBrowserMainParts(parameters_)); |
434 } | 407 } |
435 | 408 |
436 // BrowserMainLoop stages ================================================== | 409 // BrowserMainLoop stages ================================================== |
437 | 410 |
438 void BrowserMainLoop::EarlyInitialization() { | 411 void BrowserMainLoop::EarlyInitialization() { |
439 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); | 412 TRACE_EVENT0("startup", "BrowserMainLoop::EarlyInitialization"); |
440 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::EarlyInitialization"); | 413 TRACK_SCOPED_REGION("Startup", "BrowserMainLoop::EarlyInitialization"); |
441 | 414 |
442 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 415 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
443 // No thread should be created before this call, as SetupSandbox() | 416 SetupSandbox(); |
444 // will end-up using fork(). | |
445 SetupSandbox(parsed_command_line_); | |
446 #endif | 417 #endif |
447 | |
448 #if defined(USE_X11) | 418 #if defined(USE_X11) |
449 if (UsingInProcessGpu()) { | 419 if (UsingInProcessGpu()) { |
450 if (!gfx::InitializeThreadedX11()) { | 420 if (!gfx::InitializeThreadedX11()) { |
451 LOG(ERROR) << "Failed to put Xlib into threaded mode."; | 421 LOG(ERROR) << "Failed to put Xlib into threaded mode."; |
452 } | 422 } |
453 } | 423 } |
454 #endif | 424 #endif |
455 | 425 |
456 // GLib's spawning of new processes is buggy, so it's important that at this | 426 // 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 | 427 // point GLib does not need to start DBUS. Chrome should always start with |
(...skipping 988 matching lines...) Loading... | |
1446 DCHECK(is_tracing_startup_for_duration_); | 1416 DCHECK(is_tracing_startup_for_duration_); |
1447 | 1417 |
1448 is_tracing_startup_for_duration_ = false; | 1418 is_tracing_startup_for_duration_ = false; |
1449 TracingController::GetInstance()->StopTracing( | 1419 TracingController::GetInstance()->StopTracing( |
1450 TracingController::CreateFileSink( | 1420 TracingController::CreateFileSink( |
1451 startup_trace_file_, | 1421 startup_trace_file_, |
1452 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); | 1422 base::Bind(OnStoppedStartupTracing, startup_trace_file_))); |
1453 } | 1423 } |
1454 | 1424 |
1455 } // namespace content | 1425 } // namespace content |
OLD | NEW |