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> |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 // ICU DateFormat class (used in base/time_format.cc) needs to get the | 594 // ICU DateFormat class (used in base/time_format.cc) needs to get the |
595 // Olson timezone ID by accessing the zoneinfo files on disk. After | 595 // Olson timezone ID by accessing the zoneinfo files on disk. After |
596 // TimeZone::createDefault is called once here, the timezone ID is | 596 // TimeZone::createDefault is called once here, the timezone ID is |
597 // cached and there's no more need to access the file system. | 597 // cached and there's no more need to access the file system. |
598 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); | 598 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); |
599 | 599 |
600 FilePath module_path; | 600 FilePath module_path; |
601 if (PathService::Get(base::DIR_MODULE, &module_path)) | 601 if (PathService::Get(base::DIR_MODULE, &module_path)) |
602 media::InitializeMediaLibrary(module_path); | 602 media::InitializeMediaLibrary(module_path); |
603 | 603 |
604 // Remoting requires NSS to function properly. It is not used for other | 604 // NSS libraries are loaded before sandbox is activated. This is to allow |
605 // reasons so load NSS only if remoting is enabled. | 605 // successful initialization of NSS which tries to load extra library files. |
606 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 606 // Doing so will allow NSS to be used within sandbox for chromoting. |
607 if (command_line.HasSwitch(switches::kEnableRemoting)) { | 607 #if defined(USE_NSS) |
608 // We are going to fork to engage the sandbox and we have not loaded | 608 base::LoadNSSLibraries(); |
609 // any security modules so it is safe to disable the fork check in NSS. | 609 #endif |
610 base::DisableNSSForkCheck(); | |
611 | |
612 // Initialize NSS so that we load the necessary library files | |
613 // before we enter the sandbox. | |
614 base::ForceNSSNoDBInit(); | |
615 base::EnsureNSSInit(); | |
616 } | |
617 | 610 |
618 // Ensure access to the Pepper plugins before the sandbox is turned on. | 611 // Ensure access to the Pepper plugins before the sandbox is turned on. |
619 PepperPluginRegistry::PreloadModules(); | 612 PepperPluginRegistry::PreloadModules(); |
620 } | 613 } |
621 | 614 |
622 #if !defined(CHROMIUM_SELINUX) | 615 #if !defined(CHROMIUM_SELINUX) |
623 static bool EnterSandbox() { | 616 static bool EnterSandbox() { |
624 // The SUID sandbox sets this environment variable to a file descriptor | 617 // The SUID sandbox sets this environment variable to a file descriptor |
625 // over which we can signal that we have completed our startup and can be | 618 // over which we can signal that we have completed our startup and can be |
626 // chrooted. | 619 // chrooted. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 VLOG(1) << "Enabling experimental Seccomp sandbox."; | 755 VLOG(1) << "Enabling experimental Seccomp sandbox."; |
763 sandbox_flags |= ZygoteHost::kSandboxSeccomp; | 756 sandbox_flags |= ZygoteHost::kSandboxSeccomp; |
764 } | 757 } |
765 } | 758 } |
766 #endif // SECCOMP_SANDBOX | 759 #endif // SECCOMP_SANDBOX |
767 | 760 |
768 Zygote zygote(sandbox_flags); | 761 Zygote zygote(sandbox_flags); |
769 // This function call can return multiple times, once per fork(). | 762 // This function call can return multiple times, once per fork(). |
770 return zygote.ProcessRequests(); | 763 return zygote.ProcessRequests(); |
771 } | 764 } |
OLD | NEW |