| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <unistd.h> | 5 #include <unistd.h> |
| 6 #include <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 #include <sys/types.h> | 7 #include <sys/types.h> |
| 8 #include <sys/socket.h> | 8 #include <sys/socket.h> |
| 9 #include <sys/signal.h> | 9 #include <sys/signal.h> |
| 10 #include <sys/prctl.h> | 10 #include <sys/prctl.h> |
| 11 #include <sys/wait.h> | 11 #include <sys/wait.h> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/eintr_wrapper.h" | 15 #include "base/eintr_wrapper.h" |
| 16 #include "base/global_descriptors_posix.h" | 16 #include "base/global_descriptors_posix.h" |
| 17 #include "base/path_service.h" |
| 17 #include "base/pickle.h" | 18 #include "base/pickle.h" |
| 18 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 19 #include "base/unix_domain_socket_posix.h" | 20 #include "base/unix_domain_socket_posix.h" |
| 20 | 21 |
| 21 #include "chrome/browser/zygote_host_linux.h" | 22 #include "chrome/browser/zygote_host_linux.h" |
| 22 #include "chrome/common/chrome_descriptors.h" | 23 #include "chrome/common/chrome_descriptors.h" |
| 23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/main_function_params.h" | 25 #include "chrome/common/main_function_params.h" |
| 25 #include "chrome/common/process_watcher.h" | 26 #include "chrome/common/process_watcher.h" |
| 26 #include "chrome/common/sandbox_methods_linux.h" | 27 #include "chrome/common/sandbox_methods_linux.h" |
| 27 | 28 |
| 29 #include "media/base/media.h" |
| 30 |
| 28 #include "skia/ext/SkFontHost_fontconfig_control.h" | 31 #include "skia/ext/SkFontHost_fontconfig_control.h" |
| 29 | 32 |
| 30 // http://code.google.com/p/chromium/wiki/LinuxZygote | 33 // http://code.google.com/p/chromium/wiki/LinuxZygote |
| 31 | 34 |
| 32 static const int kMagicSandboxIPCDescriptor = 5; | 35 static const int kMagicSandboxIPCDescriptor = 5; |
| 33 | 36 |
| 34 // This is the object which implements the zygote. The ZygoteMain function, | 37 // This is the object which implements the zygote. The ZygoteMain function, |
| 35 // which is called from ChromeMain, at the the bottom and simple constructs one | 38 // which is called from ChromeMain, at the the bottom and simple constructs one |
| 36 // of these objects and runs it. | 39 // of these objects and runs it. |
| 37 class Zygote { | 40 class Zygote { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 // WebCore String out of the renderer and using string16 in place of | 319 // WebCore String out of the renderer and using string16 in place of |
| 317 // FilePath for IPC. | 320 // FilePath for IPC. |
| 318 const char* locale = setlocale(LC_ALL, ""); | 321 const char* locale = setlocale(LC_ALL, ""); |
| 319 LOG_IF(WARNING, locale == NULL) << "setlocale failed."; | 322 LOG_IF(WARNING, locale == NULL) << "setlocale failed."; |
| 320 | 323 |
| 321 #if defined(ARCH_CPU_X86) | 324 #if defined(ARCH_CPU_X86) |
| 322 PATCH_GLOBAL_OFFSET_TABLE(localtime, sandbox_wrapper::localtime); | 325 PATCH_GLOBAL_OFFSET_TABLE(localtime, sandbox_wrapper::localtime); |
| 323 PATCH_GLOBAL_OFFSET_TABLE(localtime_r, sandbox_wrapper::localtime_r); | 326 PATCH_GLOBAL_OFFSET_TABLE(localtime_r, sandbox_wrapper::localtime_r); |
| 324 #endif | 327 #endif |
| 325 | 328 |
| 329 FilePath module_path; |
| 330 if (PathService::Get(base::DIR_MODULE, &module_path)) |
| 331 media::InitializeMediaLibrary(module_path); |
| 332 |
| 326 static const char kChrootMe = 'C'; | 333 static const char kChrootMe = 'C'; |
| 327 static const char kChrootMeSuccess = 'O'; | 334 static const char kChrootMeSuccess = 'O'; |
| 328 | 335 |
| 329 if (HANDLE_EINTR(write(fd, &kChrootMe, 1)) != 1) { | 336 if (HANDLE_EINTR(write(fd, &kChrootMe, 1)) != 1) { |
| 330 LOG(ERROR) << "Failed to write to chroot pipe: " << errno; | 337 LOG(ERROR) << "Failed to write to chroot pipe: " << errno; |
| 331 return false; | 338 return false; |
| 332 } | 339 } |
| 333 | 340 |
| 334 // We need to reap the chroot helper process in any event: | 341 // We need to reap the chroot helper process in any event: |
| 335 wait(NULL); | 342 wait(NULL); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 bool ZygoteMain(const MainFunctionParams& params) { | 389 bool ZygoteMain(const MainFunctionParams& params) { |
| 383 if (!MaybeEnterChroot()) { | 390 if (!MaybeEnterChroot()) { |
| 384 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " | 391 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " |
| 385 << errno << ")"; | 392 << errno << ")"; |
| 386 return false; | 393 return false; |
| 387 } | 394 } |
| 388 | 395 |
| 389 Zygote zygote; | 396 Zygote zygote; |
| 390 return zygote.ProcessRequests(); | 397 return zygote.ProcessRequests(); |
| 391 } | 398 } |
| OLD | NEW |