Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <dlfcn.h> | 5 #include <dlfcn.h> |
| 6 #include <fcntl.h> | 6 #include <fcntl.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 #include <sys/epoll.h> | 8 #include <sys/epoll.h> |
| 9 #include <sys/prctl.h> | 9 #include <sys/prctl.h> |
| 10 #include <sys/signal.h> | 10 #include <sys/signal.h> |
| 11 #include <sys/socket.h> | 11 #include <sys/socket.h> |
| 12 #include <sys/stat.h> | 12 #include <sys/stat.h> |
| 13 #include <sys/types.h> | 13 #include <sys/types.h> |
| 14 #include <sys/wait.h> | 14 #include <sys/wait.h> |
| 15 #include <unistd.h> | 15 #include <unistd.h> |
| 16 | 16 |
| 17 #if defined(CHROMIUM_SELINUX) | 17 #if defined(CHROMIUM_SELINUX) |
| 18 #include <selinux/selinux.h> | 18 #include <selinux/selinux.h> |
| 19 #include <selinux/context.h> | 19 #include <selinux/context.h> |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #include "content/browser/zygote_host_linux.h" | 22 #include "content/browser/zygote_host_linux.h" |
| 23 | 23 |
| 24 #include "base/base64.h" | |
|
wtc
2011/03/15 21:37:20
Nit: why does the new code need "base/base64.h"?
| |
| 24 #include "base/basictypes.h" | 25 #include "base/basictypes.h" |
| 25 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 26 #include "base/eintr_wrapper.h" | 27 #include "base/eintr_wrapper.h" |
| 27 #include "base/file_path.h" | 28 #include "base/file_path.h" |
| 28 #include "base/global_descriptors_posix.h" | 29 #include "base/global_descriptors_posix.h" |
| 29 #include "base/hash_tables.h" | 30 #include "base/hash_tables.h" |
| 30 #include "base/linux_util.h" | 31 #include "base/linux_util.h" |
| 32 #include "base/nss_util.h" | |
| 31 #include "base/path_service.h" | 33 #include "base/path_service.h" |
| 32 #include "base/pickle.h" | 34 #include "base/pickle.h" |
| 33 #include "base/process_util.h" | 35 #include "base/process_util.h" |
| 34 #include "base/rand_util.h" | 36 #include "base/rand_util.h" |
| 35 #include "base/scoped_ptr.h" | 37 #include "base/scoped_ptr.h" |
| 36 #include "base/sys_info.h" | 38 #include "base/sys_info.h" |
| 37 #include "build/build_config.h" | 39 #include "build/build_config.h" |
| 38 #include "chrome/common/chrome_descriptors.h" | 40 #include "chrome/common/chrome_descriptors.h" |
| 39 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/font_config_ipc_linux.h" | 42 #include "chrome/common/font_config_ipc_linux.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 595 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 594 // Olson timezone ID by accessing the zoneinfo files on disk. After | 596 // Olson timezone ID by accessing the zoneinfo files on disk. After |
| 595 // TimeZone::createDefault is called once here, the timezone ID is | 597 // TimeZone::createDefault is called once here, the timezone ID is |
| 596 // cached and there's no more need to access the file system. | 598 // cached and there's no more need to access the file system. |
| 597 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 599 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
| 598 | 600 |
| 599 FilePath module_path; | 601 FilePath module_path; |
| 600 if (PathService::Get(base::DIR_MODULE, &module_path)) | 602 if (PathService::Get(base::DIR_MODULE, &module_path)) |
| 601 media::InitializeMediaLibrary(module_path); | 603 media::InitializeMediaLibrary(module_path); |
| 602 | 604 |
| 605 // Remoting requires NSS to function properly. It is not used for other | |
| 606 // reasons so load NSS only if remoting is enabled. | |
| 607 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 608 if (command_line.HasSwitch(switches::kEnableRemoting)) { | |
| 609 // We are going to fork to engage the sandbox and we have not loaded | |
| 610 // any security modules so it is safe to disable the fork check in NSS. | |
| 611 base::DisableNSSForkCheck(); | |
| 612 | |
| 613 // Initialize NSS so that we load the necessary library files | |
| 614 // before we enter the sandbox. | |
| 615 base::ForceNSSNoDBInit(); | |
| 616 base::EnsureNSSInit(); | |
| 617 } | |
| 618 | |
| 603 // Ensure access to the Pepper plugins before the sandbox is turned on. | 619 // Ensure access to the Pepper plugins before the sandbox is turned on. |
| 604 PepperPluginRegistry::PreloadModules(); | 620 PepperPluginRegistry::PreloadModules(); |
| 605 } | 621 } |
| 606 | 622 |
| 607 #if !defined(CHROMIUM_SELINUX) | 623 #if !defined(CHROMIUM_SELINUX) |
| 608 static bool EnterSandbox() { | 624 static bool EnterSandbox() { |
| 609 // The SUID sandbox sets this environment variable to a file descriptor | 625 // The SUID sandbox sets this environment variable to a file descriptor |
| 610 // over which we can signal that we have completed our startup and can be | 626 // over which we can signal that we have completed our startup and can be |
| 611 // chrooted. | 627 // chrooted. |
| 612 const char* const sandbox_fd_string = getenv("SBX_D"); | 628 const char* const sandbox_fd_string = getenv("SBX_D"); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 VLOG(1) << "Enabling experimental Seccomp sandbox."; | 763 VLOG(1) << "Enabling experimental Seccomp sandbox."; |
| 748 sandbox_flags |= ZygoteHost::kSandboxSeccomp; | 764 sandbox_flags |= ZygoteHost::kSandboxSeccomp; |
| 749 } | 765 } |
| 750 } | 766 } |
| 751 #endif // SECCOMP_SANDBOX | 767 #endif // SECCOMP_SANDBOX |
| 752 | 768 |
| 753 Zygote zygote(sandbox_flags); | 769 Zygote zygote(sandbox_flags); |
| 754 // This function call can return multiple times, once per fork(). | 770 // This function call can return multiple times, once per fork(). |
| 755 return zygote.ProcessRequests(); | 771 return zygote.ProcessRequests(); |
| 756 } | 772 } |
| OLD | NEW |