Chromium Code Reviews| 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/zygote/zygote_main.h" | 5 #include "content/zygote/zygote_main.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <openssl/rand.h> | 9 #include <openssl/rand.h> |
| 10 #include <pthread.h> | 10 #include <pthread.h> |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 39 #include "content/public/common/content_switches.h" | 39 #include "content/public/common/content_switches.h" |
| 40 #include "content/public/common/main_function_params.h" | 40 #include "content/public/common/main_function_params.h" |
| 41 #include "content/public/common/sandbox_linux.h" | 41 #include "content/public/common/sandbox_linux.h" |
| 42 #include "content/public/common/zygote_fork_delegate_linux.h" | 42 #include "content/public/common/zygote_fork_delegate_linux.h" |
| 43 #include "content/zygote/zygote_linux.h" | 43 #include "content/zygote/zygote_linux.h" |
| 44 #include "sandbox/linux/services/credentials.h" | 44 #include "sandbox/linux/services/credentials.h" |
| 45 #include "sandbox/linux/services/init_process_reaper.h" | 45 #include "sandbox/linux/services/init_process_reaper.h" |
| 46 #include "sandbox/linux/services/namespace_sandbox.h" | 46 #include "sandbox/linux/services/namespace_sandbox.h" |
| 47 #include "sandbox/linux/services/thread_helpers.h" | 47 #include "sandbox/linux/services/thread_helpers.h" |
| 48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" | 48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" |
| 49 #include "third_party/WebKit/public/web/linux/WebFontRendering.h" | |
| 49 #include "third_party/icu/source/i18n/unicode/timezone.h" | 50 #include "third_party/icu/source/i18n/unicode/timezone.h" |
| 50 #include "third_party/skia/include/ports/SkFontConfigInterface.h" | 51 #include "third_party/skia/include/ports/SkFontConfigInterface.h" |
| 51 | 52 |
| 52 #if defined(OS_LINUX) | 53 #if defined(OS_LINUX) |
| 53 #include <sys/prctl.h> | 54 #include <sys/prctl.h> |
| 54 #endif | 55 #endif |
| 55 | 56 |
| 56 #if defined(ENABLE_PLUGINS) | 57 #if defined(ENABLE_PLUGINS) |
| 57 #include "content/common/pepper_plugin_list.h" | 58 #include "content/common/pepper_plugin_list.h" |
| 58 #include "content/public/common/pepper_plugin_info.h" | 59 #include "content/public/common/pepper_plugin_info.h" |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 #if defined(ENABLE_WEBRTC) | 62 #if defined(ENABLE_WEBRTC) |
| 62 #include "third_party/libjingle/overrides/init_webrtc.h" | 63 #include "third_party/libjingle/overrides/init_webrtc.h" |
| 63 #endif | 64 #endif |
| 64 | 65 |
| 65 #if defined(SANITIZER_COVERAGE) | 66 #if defined(SANITIZER_COVERAGE) |
| 66 #include <sanitizer/common_interface_defs.h> | 67 #include <sanitizer/common_interface_defs.h> |
| 67 #include <sanitizer/coverage_interface.h> | 68 #include <sanitizer/coverage_interface.h> |
| 68 #endif | 69 #endif |
| 69 | 70 |
| 71 #include "third_party/skia/include/ports/SkFontMgr_android.h" | |
|
rickyz (no longer on Chrome)
2016/02/25 23:56:56
Move this up with the other skia include
Khushal
2016/02/26 19:21:36
Done.
| |
| 72 | |
| 70 namespace content { | 73 namespace content { |
| 71 | 74 |
| 72 namespace { | 75 namespace { |
| 73 | 76 |
| 74 void CloseFds(const std::vector<int>& fds) { | 77 void CloseFds(const std::vector<int>& fds) { |
| 75 for (const auto& it : fds) { | 78 for (const auto& it : fds) { |
| 76 PCHECK(0 == IGNORE_EINTR(close(it))); | 79 PCHECK(0 == IGNORE_EINTR(close(it))); |
| 77 } | 80 } |
| 78 } | 81 } |
| 79 | 82 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 // will work inside the sandbox. | 340 // will work inside the sandbox. |
| 338 RAND_set_urandom_fd(base::GetUrandomFD()); | 341 RAND_set_urandom_fd(base::GetUrandomFD()); |
| 339 | 342 |
| 340 #if defined(ENABLE_PLUGINS) | 343 #if defined(ENABLE_PLUGINS) |
| 341 // Ensure access to the Pepper plugins before the sandbox is turned on. | 344 // Ensure access to the Pepper plugins before the sandbox is turned on. |
| 342 PreloadPepperPlugins(); | 345 PreloadPepperPlugins(); |
| 343 #endif | 346 #endif |
| 344 #if defined(ENABLE_WEBRTC) | 347 #if defined(ENABLE_WEBRTC) |
| 345 InitializeWebRtcModule(); | 348 InitializeWebRtcModule(); |
| 346 #endif | 349 #endif |
| 350 | |
| 347 SkFontConfigInterface::SetGlobal( | 351 SkFontConfigInterface::SetGlobal( |
| 348 new FontConfigIPC(GetSandboxFD()))->unref(); | 352 new FontConfigIPC(GetSandboxFD()))->unref(); |
| 353 | |
| 354 // Set the android SkFontMgr for blink. We need to ensure this is done | |
| 355 // before the sandbox is initialized to allow the font manager to access | |
| 356 // font configuration files on disk. | |
| 357 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 358 switches::kAndroidFontsPath)) { | |
|
rickyz (no longer on Chrome)
2016/02/25 23:56:56
nit: Indent extra 4 spaces here (unfortunately, th
Khushal
2016/02/26 19:21:36
Ran git cl format on this, looks like it was just
| |
| 359 std::string android_fonts_dir = | |
| 360 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | |
| 361 switches::kAndroidFontsPath); | |
| 362 | |
| 363 if (android_fonts_dir.size() > 0 && android_fonts_dir.back() != '/') | |
| 364 android_fonts_dir += '/'; | |
| 365 std::string font_config = android_fonts_dir + "fonts.xml"; | |
| 366 SkFontMgr_Android_CustomFonts custom = { | |
|
rickyz (no longer on Chrome)
2016/02/25 23:56:56
Can you initialize each member individually, like
Khushal
2016/02/26 19:21:36
Done.
| |
| 367 SkFontMgr_Android_CustomFonts::SystemFontUse::kOnlyCustom, | |
| 368 android_fonts_dir.c_str(), | |
| 369 font_config.c_str(), | |
| 370 nullptr, | |
| 371 true, | |
| 372 }; | |
| 373 | |
| 374 blink::WebFontRendering::setSkiaFontManager(SkFontMgr_New_Android(&custom)); | |
| 375 } | |
| 349 } | 376 } |
| 350 | 377 |
| 351 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { | 378 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { |
| 352 // The current process becomes init(1), this function returns from a | 379 // The current process becomes init(1), this function returns from a |
| 353 // newly created process. | 380 // newly created process. |
| 354 const bool init_created = | 381 const bool init_created = |
| 355 sandbox::CreateInitProcessReaper(post_fork_parent_callback); | 382 sandbox::CreateInitProcessReaper(post_fork_parent_callback); |
| 356 if (!init_created) { | 383 if (!init_created) { |
| 357 LOG(ERROR) << "Error creating an init process to reap zombies"; | 384 LOG(ERROR) << "Error creating an init process to reap zombies"; |
| 358 return false; | 385 return false; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; | 636 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; |
| 610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); | 637 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); |
| 611 | 638 |
| 612 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, | 639 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, |
| 613 extra_fds); | 640 extra_fds); |
| 614 // This function call can return multiple times, once per fork(). | 641 // This function call can return multiple times, once per fork(). |
| 615 return zygote.ProcessRequests(); | 642 return zygote.ProcessRequests(); |
| 616 } | 643 } |
| 617 | 644 |
| 618 } // namespace content | 645 } // namespace content |
| OLD | NEW |