| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/zygote_host_linux.h" | 5 #include "content/browser/zygote_host_linux.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <pthread.h> | 9 #include <pthread.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| 11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
| 12 #include <sys/types.h> | 12 #include <sys/types.h> |
| 13 #include <sys/wait.h> | 13 #include <sys/wait.h> |
| 14 #include <unistd.h> | 14 #include <unistd.h> |
| 15 | 15 |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/eintr_wrapper.h" | 18 #include "base/eintr_wrapper.h" |
| 19 #include "base/file_path.h" | 19 #include "base/file_path.h" |
| 20 #include "base/global_descriptors_posix.h" | 20 #include "base/global_descriptors_posix.h" |
| 21 #include "base/hash_tables.h" | 21 #include "base/hash_tables.h" |
| 22 #include "base/linux_util.h" | 22 #include "base/linux_util.h" |
| 23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/path_service.h" | |
| 25 #include "base/pickle.h" | 24 #include "base/pickle.h" |
| 26 #include "base/process_util.h" | 25 #include "base/process_util.h" |
| 27 #include "base/rand_util.h" | 26 #include "base/rand_util.h" |
| 28 #include "base/sys_info.h" | 27 #include "base/sys_info.h" |
| 29 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 30 #include "crypto/nss_util.h" | 29 #include "crypto/nss_util.h" |
| 31 #include "chrome/common/chrome_paths.h" | |
| 32 #include "content/common/chrome_descriptors.h" | 30 #include "content/common/chrome_descriptors.h" |
| 33 #include "content/common/content_switches.h" | 31 #include "content/common/content_switches.h" |
| 34 #include "content/common/font_config_ipc_linux.h" | 32 #include "content/common/font_config_ipc_linux.h" |
| 35 #include "content/common/main_function_params.h" | 33 #include "content/common/main_function_params.h" |
| 36 #include "content/common/pepper_plugin_registry.h" | 34 #include "content/common/pepper_plugin_registry.h" |
| 37 #include "content/common/process_watcher.h" | 35 #include "content/common/process_watcher.h" |
| 38 #include "content/common/result_codes.h" | 36 #include "content/common/result_codes.h" |
| 39 #include "content/common/sandbox_methods_linux.h" | 37 #include "content/common/sandbox_methods_linux.h" |
| 40 #include "content/common/set_process_title.h" | 38 #include "content/common/set_process_title.h" |
| 41 #include "content/common/unix_domain_socket_posix.h" | 39 #include "content/common/unix_domain_socket_posix.h" |
| 42 #include "media/base/media.h" | |
| 43 #include "seccompsandbox/sandbox.h" | 40 #include "seccompsandbox/sandbox.h" |
| 44 #include "skia/ext/SkFontHost_fontconfig_control.h" | 41 #include "skia/ext/SkFontHost_fontconfig_control.h" |
| 45 #include "unicode/timezone.h" | 42 #include "unicode/timezone.h" |
| 46 | 43 |
| 47 #if defined(OS_LINUX) | 44 #if defined(OS_LINUX) |
| 48 #include <sys/epoll.h> | 45 #include <sys/epoll.h> |
| 49 #include <sys/prctl.h> | 46 #include <sys/prctl.h> |
| 50 #include <sys/signal.h> | 47 #include <sys/signal.h> |
| 51 #else | 48 #else |
| 52 #include <signal.h> | 49 #include <signal.h> |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 base::RandUint64(); | 593 base::RandUint64(); |
| 597 | 594 |
| 598 base::SysInfo::MaxSharedMemorySize(); | 595 base::SysInfo::MaxSharedMemorySize(); |
| 599 | 596 |
| 600 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 597 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
| 601 // Olson timezone ID by accessing the zoneinfo files on disk. After | 598 // Olson timezone ID by accessing the zoneinfo files on disk. After |
| 602 // TimeZone::createDefault is called once here, the timezone ID is | 599 // TimeZone::createDefault is called once here, the timezone ID is |
| 603 // cached and there's no more need to access the file system. | 600 // cached and there's no more need to access the file system. |
| 604 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 601 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
| 605 | 602 |
| 606 // Each Renderer we spawn will re-attempt initialization of the media | |
| 607 // libraries, at which point failure will be detected and handled, so | |
| 608 // we do not need to cope with initialization failures here. | |
| 609 FilePath media_path; | |
| 610 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) | |
| 611 media::InitializeMediaLibrary(media_path); | |
| 612 #if defined(USE_NSS) | 603 #if defined(USE_NSS) |
| 613 // NSS libraries are loaded before sandbox is activated. This is to allow | 604 // NSS libraries are loaded before sandbox is activated. This is to allow |
| 614 // successful initialization of NSS which tries to load extra library files. | 605 // successful initialization of NSS which tries to load extra library files. |
| 615 // Doing so will allow NSS to be used within sandbox for chromoting. | 606 // Doing so will allow NSS to be used within sandbox for chromoting. |
| 616 crypto::LoadNSSLibraries(); | 607 crypto::LoadNSSLibraries(); |
| 617 #else | 608 #else |
| 618 // TODO(bulach): implement openssl support. | 609 // TODO(bulach): implement openssl support. |
| 619 NOTREACHED() << "Remoting is not supported for openssl"; | 610 NOTREACHED() << "Remoting is not supported for openssl"; |
| 620 #endif | 611 #endif |
| 621 | 612 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 VLOG(1) << "Enabling experimental Seccomp sandbox."; | 757 VLOG(1) << "Enabling experimental Seccomp sandbox."; |
| 767 sandbox_flags |= ZygoteHost::kSandboxSeccomp; | 758 sandbox_flags |= ZygoteHost::kSandboxSeccomp; |
| 768 } | 759 } |
| 769 } | 760 } |
| 770 #endif // SECCOMP_SANDBOX | 761 #endif // SECCOMP_SANDBOX |
| 771 | 762 |
| 772 Zygote zygote(sandbox_flags); | 763 Zygote zygote(sandbox_flags); |
| 773 // This function call can return multiple times, once per fork(). | 764 // This function call can return multiple times, once per fork(). |
| 774 return zygote.ProcessRequests(); | 765 return zygote.ProcessRequests(); |
| 775 } | 766 } |
| OLD | NEW |