diff options
author | robert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 19:56:35 +0000 |
---|---|---|
committer | robert.nagy@gmail.com <robert.nagy@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-11 19:56:35 +0000 |
commit | e60c023a07150052e4aefe6fd95ce5d09fc8767a (patch) | |
tree | 94577597f228dd8dce7e5aed8d0f98c3fe2487b8 /chrome | |
parent | 10d7c0e4a5e5e15c0574b9ac4a94a93605c733bd (diff) | |
download | chromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.zip chromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.tar.gz chromium_src-e60c023a07150052e4aefe6fd95ce5d09fc8767a.tar.bz2 |
share all the needed linux code with OpenBSD in chrome and content
disabled code for OpenBSD:
- AdjustRendererOOMScore()
- SECCOMP_SANDBOX
BUG=
TEST=compile
Review URL: http://codereview.chromium.org/8341052
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 12 | ||||
-rw-r--r-- | chrome/browser/chrome_content_browser_client.cc | 10 | ||||
-rw-r--r-- | chrome/browser/net/connection_tester.cc | 2 | ||||
-rw-r--r-- | chrome/browser/process_singleton.h | 4 | ||||
-rw-r--r-- | chrome/common/child_process_logging.h | 2 | ||||
-rw-r--r-- | chrome/common/chrome_paths.cc | 2 | ||||
-rw-r--r-- | chrome/common/multi_process_lock.h | 7 | ||||
-rw-r--r-- | chrome/common/multi_process_lock_linux.cc | 23 | ||||
-rw-r--r-- | chrome/common/multi_process_lock_mac.cc | 6 | ||||
-rw-r--r-- | chrome/common/multi_process_lock_unittest.cc | 24 | ||||
-rw-r--r-- | chrome/common/multi_process_lock_win.cc | 4 | ||||
-rw-r--r-- | chrome/common/url_constants.cc | 2 | ||||
-rw-r--r-- | chrome/common/url_constants.h | 2 | ||||
-rw-r--r-- | chrome/renderer/chrome_ppb_pdf_impl.cc | 6 | ||||
-rw-r--r-- | chrome/renderer/nacl_desc_wrapper_chrome.cc | 4 | ||||
-rw-r--r-- | chrome/test/automation/proxy_launcher.cc | 4 | ||||
-rw-r--r-- | chrome/test/ui/ui_layout_test.cc | 2 |
17 files changed, 65 insertions, 51 deletions
diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 6e4d126..bc76afc 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -80,7 +80,7 @@ #include "chrome/browser/chromeos/version_loader.h" #include "chrome/browser/oom_priority_manager.h" #include "content/browser/zygote_host_linux.h" -#elif defined(OS_LINUX) +#elif defined(OS_LINUX) || defined(OS_OPENBSD) #include "content/browser/zygote_host_linux.h" #endif @@ -152,7 +152,7 @@ const char* const kChromePaths[] = { #if defined(OS_WIN) chrome::kChromeUIConflictsHost, #endif -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) chrome::kChromeUILinuxProxyConfigHost, chrome::kChromeUISandboxHost, #endif @@ -188,7 +188,7 @@ const char* const kAboutSourceNames[] = { #if defined(USE_TCMALLOC) chrome::kChromeUITCMallocHost, #endif -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) chrome::kChromeUILinuxProxyConfigHost, chrome::kChromeUISandboxHost, #endif @@ -1062,7 +1062,7 @@ std::string AboutStats(const std::string& query) { return data; } -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) std::string AboutLinuxProxyConfig() { std::string data; AppendHeader(&data, 0, @@ -1447,7 +1447,7 @@ void AboutSource::StartDataRequest(const std::string& path, return; } else if (host == chrome::kChromeUIHistogramsHost) { response = AboutHistograms(path); -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) } else if (host == chrome::kChromeUILinuxProxyConfigHost) { response = AboutLinuxProxyConfig(); #endif @@ -1463,7 +1463,7 @@ void AboutSource::StartDataRequest(const std::string& path, response = ResourceBundle::GetSharedInstance().GetRawDataResource( IDR_OS_CREDITS_HTML).as_string(); #endif -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) } else if (host == chrome::kChromeUISandboxHost) { response = AboutSandbox(); #endif diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 365b2b2..94b16fa 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -84,7 +84,7 @@ #include "chrome/browser/chrome_browser_main_mac.h" #elif defined(OS_CHROMEOS) #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" -#elif defined(OS_LINUX) +#elif defined(OS_LINUX) || defined(OS_OPENBSD) #include "chrome/browser/chrome_browser_main_linux.h" #elif defined(OS_POSIX) #include "chrome/browser/chrome_browser_main_posix.h" @@ -102,7 +102,7 @@ #include "chrome/browser/chrome_browser_parts_aura.h" #endif -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) #include "base/linux_util.h" #include "chrome/browser/crash_handler_host_linux.h" #endif @@ -226,7 +226,7 @@ void ChromeContentBrowserClient::CreateBrowserMainParts( parts_list->push_back(new ChromeBrowserMainPartsMac(parameters)); #elif defined(OS_CHROMEOS) parts_list->push_back(new ChromeBrowserMainPartsChromeos(parameters)); -#elif defined(OS_LINUX) +#elif defined(OS_LINUX) || defined(OS_OPENBSD) parts_list->push_back(new ChromeBrowserMainPartsLinux(parameters)); #elif defined(OS_POSIX) parts_list->push_back(new ChromeBrowserMainPartsPosix(parameters)); @@ -1024,7 +1024,7 @@ std::string ChromeContentBrowserClient::GetDefaultDownloadName() { return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); } -#if defined(OS_LINUX) +#if defined(OS_POSIX) && !defined(OS_MACOSX) int ChromeContentBrowserClient::GetCrashSignalFD( const CommandLine& command_line) { if (command_line.HasSwitch(switches::kExtensionProcess)) { @@ -1050,7 +1050,7 @@ int ChromeContentBrowserClient::GetCrashSignalFD( return -1; } -#endif // defined(OS_LINUX) +#endif // defined(OS_POSIX) && !defined(OS_MACOSX) #if defined(OS_WIN) const wchar_t* ChromeContentBrowserClient::GetResourceDllName() { diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc index 4578ded..2425ddd 100644 --- a/chrome/browser/net/connection_tester.cc +++ b/chrome/browser/net/connection_tester.cc @@ -211,7 +211,7 @@ class ExperimentURLRequestContext : public net::URLRequestContext { // Otherwise returns a network error code. int CreateSystemProxyConfigService( scoped_ptr<net::ProxyConfigService>* config_service) { -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) // TODO(eroman): This is not supported on Linux yet, because of how // construction needs ot happen on the UI thread. return net::ERR_NOT_IMPLEMENTED; diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h index 19a67f5..502b75f 100644 --- a/chrome/browser/process_singleton.h +++ b/chrome/browser/process_singleton.h @@ -67,7 +67,7 @@ class ProcessSingleton : public base::NonThreadSafe { // instance. NotifyResult NotifyOtherProcessOrCreate(); -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) // Exposed for testing. We use a timeout on Linux, and in tests we want // this timeout to be short. NotifyResult NotifyOtherProcessWithTimeout(const CommandLine& command_line, @@ -76,7 +76,7 @@ class ProcessSingleton : public base::NonThreadSafe { NotifyResult NotifyOtherProcessWithTimeoutOrCreate( const CommandLine& command_line, int timeout_seconds); -#endif // defined(OS_LINUX) +#endif // defined(OS_LINUX) || defined(OS_OPENBSD) #if defined(OS_WIN) && !defined(USE_AURA) // Used in specific cases to let us know that there is an existing instance diff --git a/chrome/common/child_process_logging.h b/chrome/common/child_process_logging.h index 8b5a733..b5894f0 100644 --- a/chrome/common/child_process_logging.h +++ b/chrome/common/child_process_logging.h @@ -33,7 +33,7 @@ static const size_t kMaxSwitches = 15; namespace child_process_logging { -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) // These are declared here so the crash reporter can access them directly in // compromised context without going through the standard library. extern char g_active_url[]; diff --git a/chrome/common/chrome_paths.cc b/chrome/common/chrome_paths.cc index ed27d7a..77d8d38 100644 --- a/chrome/common/chrome_paths.cc +++ b/chrome/common/chrome_paths.cc @@ -305,7 +305,7 @@ bool PathProvider(int key, FilePath* result) { if (!file_util::PathExists(cur)) // We don't want to create this return false; break; -#if defined(OS_POSIX) && !defined(OS_MACOSX) +#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) case chrome::DIR_POLICY_FILES: { #if defined(GOOGLE_CHROME_BUILD) cur = FilePath(FILE_PATH_LITERAL("/etc/opt/chrome/policies")); diff --git a/chrome/common/multi_process_lock.h b/chrome/common/multi_process_lock.h index 24754f5..8116e84 100644 --- a/chrome/common/multi_process_lock.h +++ b/chrome/common/multi_process_lock.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -15,11 +15,6 @@ class MultiProcessLock { public: - // The length of a multi-process lock name is limited on Linux, so - // it is limited it on all platforms for consistency. This length does - // not include a terminator. - static const size_t MULTI_PROCESS_LOCK_NAME_MAX_LEN = 106; - // Factory method for creating a multi-process lock. // |name| is the name of the lock. The name has special meaning on Windows // where the prefix can determine the namespace of the lock. diff --git a/chrome/common/multi_process_lock_linux.cc b/chrome/common/multi_process_lock_linux.cc index c5b70a4..f610237 100644 --- a/chrome/common/multi_process_lock_linux.cc +++ b/chrome/common/multi_process_lock_linux.cc @@ -24,33 +24,30 @@ class MultiProcessLockLinux : public MultiProcessLock { } virtual bool TryLock() { + struct sockaddr_un address; + + // +1 for terminator, +1 for 0 in position 0 that makes it an + // abstract named socket. + const size_t max_len = sizeof(address.sun_path) - 2; + if (fd_ != -1) { DLOG(ERROR) << "MultiProcessLock is already locked - " << name_; return true; } - if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) { + if (name_.length() > max_len) { LOG(ERROR) << "Socket name too long (" << name_.length() - << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_; + << " > " << max_len << ") - " << name_; return false; } - struct sockaddr_un address; - - // +1 for terminator, +1 for 0 in position 0 that makes it an - // abstract named socket. - // If this assert fails it is because sockaddr_un.sun_path size has been - // redefined and MULTI_PROCESS_LOCK_NAME_MAX_LEN can change accordingly. - COMPILE_ASSERT(sizeof(address.sun_path) - == MULTI_PROCESS_LOCK_NAME_MAX_LEN + 2, sun_path_size_changed); - memset(&address, 0, sizeof(address)); int print_length = snprintf(&address.sun_path[1], - MULTI_PROCESS_LOCK_NAME_MAX_LEN + 1, + max_len + 1, "%s", name_.c_str()); if (print_length < 0 || - print_length > static_cast<int>(MULTI_PROCESS_LOCK_NAME_MAX_LEN)) { + print_length > static_cast<int>(max_len)) { PLOG(ERROR) << "Couldn't create sun_path - " << name_; return false; } diff --git a/chrome/common/multi_process_lock_mac.cc b/chrome/common/multi_process_lock_mac.cc index 9a9cbe21..8a05b94 100644 --- a/chrome/common/multi_process_lock_mac.cc +++ b/chrome/common/multi_process_lock_mac.cc @@ -8,6 +8,8 @@ #include "base/mac/scoped_cftyperef.h" #include "base/sys_string_conversions.h" +#include <servers/bootstrap.h> + class MultiProcessLockMac : public MultiProcessLock { public: explicit MultiProcessLockMac(const std::string& name) : name_(name) { } @@ -24,9 +26,9 @@ class MultiProcessLockMac : public MultiProcessLock { return true; } - if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) { + if (name_.length() >= BOOTSTRAP_MAX_NAME_LEN) { LOG(ERROR) << "Socket name too long (" << name_.length() - << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_; + << " >= " << BOOTSTRAP_MAX_NAME_LEN << ") - " << name_; return false; } diff --git a/chrome/common/multi_process_lock_unittest.cc b/chrome/common/multi_process_lock_unittest.cc index e1408ee..30c4d7b 100644 --- a/chrome/common/multi_process_lock_unittest.cc +++ b/chrome/common/multi_process_lock_unittest.cc @@ -77,13 +77,27 @@ TEST_F(MultiProcessLockTest, BasicCreationTest) { } TEST_F(MultiProcessLockTest, LongNameTest) { - // Linux has a max path name of 108 characters. - // http://lxr.linux.no/linux+v2.6.36/include/linux/un.h - // This is enforced on all platforms. + // Every platform has has it's own max path name size, + // so different checks are needed for them. + // POSIX: sizeof(address.sun_path) - 2 + // Mac OS X: BOOTSTRAP_MAX_NAME_LEN + // Windows: MAX_PATH LOG(INFO) << "Following error log due to long name is expected"; +#if defined(OS_MACOSX) + std::string name("This is a name that is longer than one hundred and " + "twenty-eight characters to make sure that we fail appropriately on " + "Mac OS X when we have a path that is too long for Mac OS X to handle"); +#elif defined(OS_POSIX) std::string name("This is a name that is longer than one hundred and eight " - "characters to make sure that we fail appropriately on linux when we " - "have a path that is to long for linux to handle"); + "characters to make sure that we fail appropriately on POSIX systems " + "when we have a path that is too long for the system to handle"); +#elif defined(OS_WIN) + std::string name("This is a name that is longer than two hundred and sixty " + "characters to make sure that we fail appropriately on Windows when we " + "have a path that is too long for Windows to handle " + "This limitation comes from the MAX_PATH definition which is obviously " + "defined to be a maximum of two hundred and sixty characters "); +#endif scoped_ptr<MultiProcessLock> test_lock(MultiProcessLock::Create(name)); EXPECT_FALSE(test_lock->TryLock()); } diff --git a/chrome/common/multi_process_lock_win.cc b/chrome/common/multi_process_lock_win.cc index b668f78..d35258e 100644 --- a/chrome/common/multi_process_lock_win.cc +++ b/chrome/common/multi_process_lock_win.cc @@ -24,9 +24,9 @@ class MultiProcessLockWin : public MultiProcessLock { return true; } - if (name_.length() > MULTI_PROCESS_LOCK_NAME_MAX_LEN) { + if (name_.length() >= MAX_PATH) { LOG(ERROR) << "Socket name too long (" << name_.length() - << " > " << MULTI_PROCESS_LOCK_NAME_MAX_LEN << ") - " << name_; + << " >= " << MAX_PATH << ") - " << name_; return false; } diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc index 6092537..1a742ba 100644 --- a/chrome/common/url_constants.cc +++ b/chrome/common/url_constants.cc @@ -189,7 +189,7 @@ const char kChromeUIWorkersHost[] = "workers"; const char kChromeUIScreenshotPath[] = "screenshots"; const char kChromeUIThemePath[] = "theme"; -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) const char kChromeUILinuxProxyConfigHost[] = "linux-proxy-config"; const char kChromeUISandboxHost[] = "sandbox"; #endif diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h index 0e896d5..3dc7163 100644 --- a/chrome/common/url_constants.h +++ b/chrome/common/url_constants.h @@ -181,7 +181,7 @@ extern const char kChromeUIWorkersHost[]; extern const char kChromeUIScreenshotPath[]; extern const char kChromeUIThemePath[]; -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) extern const char kChromeUILinuxProxyConfigHost[]; extern const char kChromeUISandboxHost[]; #endif diff --git a/chrome/renderer/chrome_ppb_pdf_impl.cc b/chrome/renderer/chrome_ppb_pdf_impl.cc index 123d6fd..6a2b31b 100644 --- a/chrome/renderer/chrome_ppb_pdf_impl.cc +++ b/chrome/renderer/chrome_ppb_pdf_impl.cc @@ -43,7 +43,7 @@ using content::RenderThread; namespace chrome { -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) class PrivateFontFile : public ppapi::Resource { public: PrivateFontFile(PP_Instance instance, int fd) : Resource(instance), fd_(fd) { @@ -187,7 +187,7 @@ PP_Resource GetFontFileWithFallback( PP_Instance instance_id, const PP_FontDescription_Dev* description, PP_PrivateFontCharset charset) { -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) // Validate the instance before using it below. if (!HostGlobals::Get()->GetInstance(instance_id)) return 0; @@ -219,7 +219,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file, uint32_t table, void* output, uint32_t* output_length) { -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) ppapi::Resource* resource = PpapiGlobals::Get()->GetResourceTracker()->GetResource(font_file); if (!resource) diff --git a/chrome/renderer/nacl_desc_wrapper_chrome.cc b/chrome/renderer/nacl_desc_wrapper_chrome.cc index eb142993..c29ae1d 100644 --- a/chrome/renderer/nacl_desc_wrapper_chrome.cc +++ b/chrome/renderer/nacl_desc_wrapper_chrome.cc @@ -14,7 +14,7 @@ namespace nacl { DescWrapper* DescWrapperFactory::ImportPepperSharedMemory(intptr_t shm_int, size_t size) { base::SharedMemory* shm = reinterpret_cast<base::SharedMemory*>(shm_int); -#if defined(OS_LINUX) || defined(OS_MACOSX) +#if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_OPENBSD) return ImportShmHandle(shm->handle().fd, size); #elif defined(OS_WIN) return ImportShmHandle(shm->handle(), size); @@ -25,7 +25,7 @@ DescWrapper* DescWrapperFactory::ImportPepperSharedMemory(intptr_t shm_int, DescWrapper* DescWrapperFactory::ImportPepper2DSharedMemory(intptr_t shm_int) { TransportDIB* dib = reinterpret_cast<TransportDIB*>(shm_int); -#if defined(OS_LINUX) +#if defined(OS_LINUX) || defined(OS_OPENBSD) // TransportDIBs use SysV (X) shared memory on Linux. return ImportSysvShm(dib->handle(), dib->size()); #elif defined(OS_MACOSX) diff --git a/chrome/test/automation/proxy_launcher.cc b/chrome/test/automation/proxy_launcher.cc index a47e119..e815b82 100644 --- a/chrome/test/automation/proxy_launcher.cc +++ b/chrome/test/automation/proxy_launcher.cc @@ -29,6 +29,10 @@ #include "ipc/ipc_descriptors.h" #include "sql/connection.h" +#if defined(OS_POSIX) +#include <signal.h> +#endif + namespace { // Passed as value of kTestType. diff --git a/chrome/test/ui/ui_layout_test.cc b/chrome/test/ui/ui_layout_test.cc index c60c313..9db47f0 100644 --- a/chrome/test/ui/ui_layout_test.cc +++ b/chrome/test/ui/ui_layout_test.cc @@ -22,6 +22,8 @@ static const char kPlatformName[] = "chromium-win"; static const char kPlatformName[] = "chromium-mac"; #elif defined(OS_LINUX) static const char kPlatformName[] = "chromium-linux"; +#elif defined(OS_OPENBSD) +static const char kPlatformName[] = "chromium-openbsd"; #else #error No known OS defined #endif |