| 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/pickle.h" | 17 #include "base/pickle.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/sys_info.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 |
| 28 #include "skia/ext/SkFontHost_fontconfig_control.h" | 29 #include "skia/ext/SkFontHost_fontconfig_control.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 char* endptr; | 304 char* endptr; |
| 304 const long fd_long = strtol(sandbox_fd_string, &endptr, 10); | 305 const long fd_long = strtol(sandbox_fd_string, &endptr, 10); |
| 305 if (!*sandbox_fd_string || *endptr || fd_long < 0 || fd_long > INT_MAX) | 306 if (!*sandbox_fd_string || *endptr || fd_long < 0 || fd_long > INT_MAX) |
| 306 return false; | 307 return false; |
| 307 const int fd = fd_long; | 308 const int fd = fd_long; |
| 308 | 309 |
| 309 // Before entering the sandbox, "prime" any systems that need to open | 310 // Before entering the sandbox, "prime" any systems that need to open |
| 310 // files and cache the results or the descriptors. | 311 // files and cache the results or the descriptors. |
| 311 base::RandUint64(); | 312 base::RandUint64(); |
| 312 | 313 |
| 314 base::SysInfo::MaxSharedMemorySize(); |
| 315 |
| 313 // To make wcstombs/mbstowcs work in a renderer, setlocale() has to be | 316 // To make wcstombs/mbstowcs work in a renderer, setlocale() has to be |
| 314 // called before the sandbox is triggered. It's possible to avoid calling | 317 // called before the sandbox is triggered. It's possible to avoid calling |
| 315 // setlocale() by pulling out the conversion between FilePath and | 318 // setlocale() by pulling out the conversion between FilePath and |
| 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); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 bool ZygoteMain(const MainFunctionParams& params) { | 385 bool ZygoteMain(const MainFunctionParams& params) { |
| 383 if (!MaybeEnterChroot()) { | 386 if (!MaybeEnterChroot()) { |
| 384 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " | 387 LOG(FATAL) << "Failed to enter sandbox. Fail safe abort. (errno: " |
| 385 << errno << ")"; | 388 << errno << ")"; |
| 386 return false; | 389 return false; |
| 387 } | 390 } |
| 388 | 391 |
| 389 Zygote zygote; | 392 Zygote zygote; |
| 390 return zygote.ProcessRequests(); | 393 return zygote.ProcessRequests(); |
| 391 } | 394 } |
| OLD | NEW |