diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
commit | e9dd029f5d00590e1a53e63b0ab805110a10b54c (patch) | |
tree | 1126ca5dda925a62be3dc12c99c90e953d08afcf /dom/ipc | |
parent | 9d6a7ae25d7f5da855a8f8df884de483b4e2a538 (diff) | |
parent | 36b8fd734f590eb726ca2e50f8d1ff9cc968b8e1 (diff) | |
download | UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.gz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.lz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.xz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.zip |
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'dom/ipc')
-rw-r--r-- | dom/ipc/ContentChild.cpp | 248 | ||||
-rw-r--r-- | dom/ipc/ContentChild.h | 21 | ||||
-rw-r--r-- | dom/ipc/ContentParent.cpp | 199 | ||||
-rw-r--r-- | dom/ipc/ContentParent.h | 11 | ||||
-rw-r--r-- | dom/ipc/ContentProcess.cpp | 113 | ||||
-rw-r--r-- | dom/ipc/ContentProcess.h | 8 | ||||
-rw-r--r-- | dom/ipc/TabContext.cpp | 7 | ||||
-rw-r--r-- | dom/ipc/moz.build | 13 | ||||
-rw-r--r-- | dom/ipc/tests/test_cpow_cookies.html | 3 |
9 files changed, 9 insertions, 614 deletions
diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 75678ca96..9e1c7e8cb 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -65,21 +65,6 @@ #include "imgLoader.h" #include "GMPServiceChild.h" -#if defined(MOZ_CONTENT_SANDBOX) -#if defined(XP_WIN) -#define TARGET_SANDBOX_EXPORTS -#include "mozilla/sandboxTarget.h" -#elif defined(XP_LINUX) -#include "mozilla/Sandbox.h" -#include "mozilla/SandboxInfo.h" - -// Remove this include with Bug 1104619 -#include "CubebUtils.h" -#elif defined(XP_MACOSX) -#include "mozilla/Sandbox.h" -#endif -#endif - #include "mozilla/Unused.h" #include "mozInlineSpellChecker.h" @@ -152,12 +137,6 @@ #include "APKOpen.h" #endif -#if defined(MOZ_WIDGET_GONK) -#include "nsVolume.h" -#include "nsVolumeService.h" -#include "SpeakerManagerService.h" -#endif - #ifdef XP_WIN #include <process.h> #define getpid _getpid @@ -211,9 +190,6 @@ using namespace mozilla::net; using namespace mozilla::jsipc; using namespace mozilla::psm; using namespace mozilla::widget; -#if defined(MOZ_WIDGET_GONK) -using namespace mozilla::system; -#endif using namespace mozilla::widget; namespace mozilla { @@ -600,15 +576,7 @@ ContentChild::Init(MessageLoop* aIOLoop, void ContentChild::InitProcessAttributes() { -#ifdef MOZ_WIDGET_GONK - if (mIsForApp && !mIsForBrowser) { - SetProcessName(NS_LITERAL_STRING("(Preallocated app)"), false); - } else { - SetProcessName(NS_LITERAL_STRING("Browser"), false); - } -#else SetProcessName(NS_LITERAL_STRING("Web Content"), true); -#endif } void @@ -1250,192 +1218,11 @@ ContentChild::AllocPProcessHangMonitorChild(Transport* aTransport, return CreateHangMonitorChild(aTransport, aOtherProcess); } -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - -#include <stdlib.h> - -static bool -GetAppPaths(nsCString &aAppPath, nsCString &aAppBinaryPath, nsCString &aAppDir) -{ - nsAutoCString appPath; - nsAutoCString appBinaryPath( - (CommandLine::ForCurrentProcess()->argv()[0]).c_str()); - - nsAutoCString::const_iterator start, end; - appBinaryPath.BeginReading(start); - appBinaryPath.EndReading(end); - if (RFindInReadable(NS_LITERAL_CSTRING(".app/Contents/MacOS/"), start, end)) { - end = start; - ++end; ++end; ++end; ++end; - appBinaryPath.BeginReading(start); - appPath.Assign(Substring(start, end)); - } else { - return false; - } - - nsCOMPtr<nsIFile> app, appBinary; - nsresult rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appPath), - true, getter_AddRefs(app)); - if (NS_FAILED(rv)) { - return false; - } - rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(appBinaryPath), - true, getter_AddRefs(appBinary)); - if (NS_FAILED(rv)) { - return false; - } - - nsCOMPtr<nsIFile> appDir; - nsCOMPtr<nsIProperties> dirSvc = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); - if (!dirSvc) { - return false; - } - rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR, - NS_GET_IID(nsIFile), getter_AddRefs(appDir)); - if (NS_FAILED(rv)) { - return false; - } - bool exists; - rv = appDir->Exists(&exists); - if (NS_FAILED(rv) || !exists) { - return false; - } - - bool isLink; - app->IsSymlink(&isLink); - if (isLink) { - app->GetNativeTarget(aAppPath); - } else { - app->GetNativePath(aAppPath); - } - appBinary->IsSymlink(&isLink); - if (isLink) { - appBinary->GetNativeTarget(aAppBinaryPath); - } else { - appBinary->GetNativePath(aAppBinaryPath); - } - appDir->IsSymlink(&isLink); - if (isLink) { - appDir->GetNativeTarget(aAppDir); - } else { - appDir->GetNativePath(aAppDir); - } - - return true; -} - -static bool -StartMacOSContentSandbox() -{ - int sandboxLevel = Preferences::GetInt("security.sandbox.content.level"); - if (sandboxLevel < 1) { - return false; - } - - nsAutoCString appPath, appBinaryPath, appDir; - if (!GetAppPaths(appPath, appBinaryPath, appDir)) { - MOZ_CRASH("Error resolving child process path"); - } - - // During sandboxed content process startup, before reaching - // this point, NS_OS_TEMP_DIR is modified to refer to a sandbox- - // writable temporary directory - nsCOMPtr<nsIFile> tempDir; - nsresult rv = nsDirectoryService::gService->Get(NS_OS_TEMP_DIR, - NS_GET_IID(nsIFile), getter_AddRefs(tempDir)); - if (NS_FAILED(rv)) { - MOZ_CRASH("Failed to get NS_OS_TEMP_DIR"); - } - - nsAutoCString tempDirPath; - tempDir->Normalize(); - rv = tempDir->GetNativePath(tempDirPath); - if (NS_FAILED(rv)) { - MOZ_CRASH("Failed to get NS_OS_TEMP_DIR path"); - } - - nsCOMPtr<nsIFile> profileDir; - ContentChild::GetSingleton()->GetProfileDir(getter_AddRefs(profileDir)); - nsCString profileDirPath; - if (profileDir) { - rv = profileDir->GetNativePath(profileDirPath); - if (NS_FAILED(rv) || profileDirPath.IsEmpty()) { - MOZ_CRASH("Failed to get profile path"); - } - } - - MacSandboxInfo info; - info.type = MacSandboxType_Content; - info.level = info.level = sandboxLevel; - info.appPath.assign(appPath.get()); - info.appBinaryPath.assign(appBinaryPath.get()); - info.appDir.assign(appDir.get()); - info.appTempDir.assign(tempDirPath.get()); - - if (profileDir) { - info.hasSandboxedProfile = true; - info.profileDir.assign(profileDirPath.get()); - } else { - info.hasSandboxedProfile = false; - } - - std::string err; - if (!mozilla::StartMacSandbox(info, err)) { - NS_WARNING(err.c_str()); - MOZ_CRASH("sandbox_init() failed"); - } - - return true; -} -#endif - bool ContentChild::RecvSetProcessSandbox(const MaybeFileDesc& aBroker) { // We may want to move the sandbox initialization somewhere else // at some point; see bug 880808. -#if defined(MOZ_CONTENT_SANDBOX) - bool sandboxEnabled = true; -#if defined(XP_LINUX) -#if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19 - // For B2G >= KitKat, sandboxing is mandatory; this has already - // been enforced by ContentParent::StartUp(). - MOZ_ASSERT(SandboxInfo::Get().CanSandboxContent()); -#else - // Otherwise, sandboxing is best-effort. - if (!SandboxInfo::Get().CanSandboxContent()) { - sandboxEnabled = false; - } else { - // This triggers the initialization of cubeb, which needs to happen - // before seccomp is enabled (Bug 1259508). It also increases the startup - // time of the content process, because cubeb is usually initialized - // when it is actually needed. This call here is no longer required - // once Bug 1104619 (remoting audio) is resolved. - Unused << CubebUtils::GetCubebContext(); - } - -#endif /* MOZ_WIDGET_GONK && ANDROID_VERSION >= 19 */ - if (sandboxEnabled) { - int brokerFd = -1; - if (aBroker.type() == MaybeFileDesc::TFileDescriptor) { - auto fd = aBroker.get_FileDescriptor().ClonePlatformHandle(); - brokerFd = fd.release(); - // brokerFd < 0 means to allow direct filesystem access, so - // make absolutely sure that doesn't happen if the parent - // didn't intend it. - MOZ_RELEASE_ASSERT(brokerFd >= 0); - } - sandboxEnabled = SetContentProcessSandbox(brokerFd); - } -#elif defined(XP_WIN) - mozilla::SandboxTarget::Instance()->StartSandbox(); -#elif defined(XP_MACOSX) - sandboxEnabled = StartMacOSContentSandbox(); -#endif - -#endif /* MOZ_CONTENT_SANDBOX */ - return true; } @@ -1453,15 +1240,6 @@ ContentChild::RecvNotifyLayerAllocated(const dom::TabId& aTabId, const uint64_t& bool ContentChild::RecvSpeakerManagerNotify() { -#ifdef MOZ_WIDGET_GONK - // Only notify the process which has the SpeakerManager instance. - RefPtr<SpeakerManagerService> service = - SpeakerManagerService::GetSpeakerManagerService(); - if (service) { - service->Notify(); - } - return true; -#endif return false; } @@ -2480,12 +2258,6 @@ ContentChild::RecvLastPrivateDocShellDestroyed() bool ContentChild::RecvVolumes(nsTArray<VolumeInfo>&& aVolumes) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->RecvVolumesFromParent(aVolumes); - } -#endif return true; } @@ -2502,17 +2274,6 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, const bool& aIsRemovable, const bool& aIsHotSwappable) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolume> volume = new nsVolume(aFsName, aVolumeName, aState, - aMountGeneration, aIsMediaPresent, - aIsSharing, aIsFormatting, aIsFake, - aIsUnmounting, aIsRemovable, aIsHotSwappable); - - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->UpdateVolume(volume); - } -#else // Remove warnings about unused arguments Unused << aFsName; Unused << aVolumeName; @@ -2525,22 +2286,15 @@ ContentChild::RecvFileSystemUpdate(const nsString& aFsName, Unused << aIsUnmounting; Unused << aIsRemovable; Unused << aIsHotSwappable; -#endif + return true; } bool ContentChild::RecvVolumeRemoved(const nsString& aFsName) { -#ifdef MOZ_WIDGET_GONK - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->RemoveVolumeByName(aFsName); - } -#else // Remove warnings about unused arguments Unused << aFsName; -#endif return true; } diff --git a/dom/ipc/ContentChild.h b/dom/ipc/ContentChild.h index cb718aff9..c78f951f0 100644 --- a/dom/ipc/ContentChild.h +++ b/dom/ipc/ContentChild.h @@ -21,10 +21,6 @@ #include "nsWeakPtr.h" #include "nsIWindowProvider.h" -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) -#include "nsIFile.h" -#endif - struct ChromePackage; class nsIObserver; struct SubstitutionMapping; @@ -118,19 +114,6 @@ public: void GetProcessName(nsACString& aName) const; -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - void GetProfileDir(nsIFile** aProfileDir) const - { - *aProfileDir = mProfileDir; - NS_IF_ADDREF(*aProfileDir); - } - - void SetProfileDir(nsIFile* aProfileDir) - { - mProfileDir = aProfileDir; - } -#endif - bool IsAlive() const; bool IsShuttingDown() const; @@ -679,10 +662,6 @@ private: nsCOMPtr<nsIDomainPolicy> mPolicy; nsCOMPtr<nsITimer> mForceKillTimer; -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - nsCOMPtr<nsIFile> mProfileDir; -#endif - // Hashtable to keep track of the pending GetFilesHelper objects. // This GetFilesHelperChild objects are removed when RecvGetFilesResponse is // received. diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 286f1d851..8b9ab4442 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -16,11 +16,6 @@ # include <sys/resource.h> #endif -#ifdef MOZ_WIDGET_GONK -#include <sys/types.h> -#include <sys/wait.h> -#endif - #include "chrome/common/process_watcher.h" #include "mozilla/a11y/PDocAccessible.h" @@ -210,14 +205,6 @@ # include "AndroidBridge.h" #endif -#ifdef MOZ_WIDGET_GONK -#include "nsIVolume.h" -#include "nsVolumeService.h" -#include "nsIVolumeService.h" -#include "SpeakerManagerService.h" -using namespace mozilla::system; -#endif - #ifdef MOZ_WIDGET_GTK #include <gdk/gdk.h> #endif @@ -230,12 +217,6 @@ using namespace mozilla::system; #include "mozilla/dom/SpeechSynthesisParent.h" #endif -#if defined(MOZ_CONTENT_SANDBOX) && defined(XP_LINUX) -#include "mozilla/SandboxInfo.h" -#include "mozilla/SandboxBroker.h" -#include "mozilla/SandboxBrokerPolicyFactory.h" -#endif - #ifdef MOZ_TOOLKIT_SEARCH #include "nsIBrowserSearchService.h" #endif @@ -503,9 +484,6 @@ nsTArray<ContentParent*>* ContentParent::sNonAppContentParents; nsTArray<ContentParent*>* ContentParent::sLargeAllocationContentParents; nsTArray<ContentParent*>* ContentParent::sPrivateContent; StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents; -#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX) -UniquePtr<SandboxBrokerPolicyFactory> ContentParent::sSandboxBrokerPolicyFactory; -#endif // This is true when subprocess launching is enabled. This is the // case between StartUp() and ShutDown() or JoinAllSubprocesses(). @@ -535,11 +513,6 @@ static const char* sObserverTopics[] = { "child-mmu-request", "last-pb-context-exited", "file-watcher-update", -#ifdef MOZ_WIDGET_GONK - NS_VOLUME_STATE_CHANGED, - NS_VOLUME_REMOVED, - "phone-state-changed", -#endif #ifdef ACCESSIBILITY "a11y-init-or-shutdown", #endif @@ -637,18 +610,6 @@ ContentParent::StartUp() return; } -#if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19 - // Require sandboxing on B2G >= KitKat. This condition must stay - // in sync with ContentChild::RecvSetProcessSandbox. - if (!SandboxInfo::Get().CanSandboxContent()) { - // MOZ_CRASH strings are only for debug builds; make sure the - // message is clear on non-debug builds as well: - printf_stderr("Sandboxing support is required on this platform. " - "Recompile kernel with CONFIG_SECCOMP_FILTER=y\n"); - MOZ_CRASH("Sandboxing support is required on this platform."); - } -#endif - // Note: This reporter measures all ContentParents. RegisterStrongMemoryReporter(new ContentParentsMemoryReporter()); @@ -662,10 +623,6 @@ ContentParent::StartUp() PreallocatedProcessManager::AllocateAfterDelay(); sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS"); - -#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX) - sSandboxBrokerPolicyFactory = MakeUnique<SandboxBrokerPolicyFactory>(); -#endif } /*static*/ void @@ -674,10 +631,6 @@ ContentParent::ShutDown() // No-op for now. We rely on normal process shutdown and // ClearOnShutdown() to clean up our state. sCanLaunchSubprocesses = false; - -#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX) - sSandboxBrokerPolicyFactory = nullptr; -#endif } /*static*/ void @@ -1384,14 +1337,6 @@ ContentParent::ForwardKnownInfo() if (!mMetamorphosed) { return; } -#ifdef MOZ_WIDGET_GONK - InfallibleTArray<VolumeInfo> volumeInfo; - RefPtr<nsVolumeService> vs = nsVolumeService::GetSingleton(); - if (vs) { - vs->GetVolumesForIPC(&volumeInfo); - Unused << SendVolumes(volumeInfo); - } -#endif /* MOZ_WIDGET_GONK */ } namespace { @@ -1439,23 +1384,6 @@ bool ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority) { ProcessPriorityManager::SetProcessPriority(this, aPriority); - - // Now that we've set this process's priority, check whether the process is - // still alive. Hopefully we've set the priority to FOREGROUND*, so the - // process won't unexpectedly crash after this point! - // - // Bug 943174: use waitid() with WNOWAIT so that, if the process - // did exit, we won't consume its zombie and confuse the - // GeckoChildProcessHost dtor. -#ifdef MOZ_WIDGET_GONK - siginfo_t info; - info.si_pid = 0; - if (waitid(P_PID, Pid(), &info, WNOWAIT | WNOHANG | WEXITED) == 0 - && info.si_pid != 0) { - return false; - } -#endif - return true; } @@ -2106,7 +2034,7 @@ ContentParent::ContentParent(mozIApplication* aApp, // PID along with the warning. nsDebugImpl::SetMultiprocessMode("Parent"); -#if defined(XP_WIN) && !defined(MOZ_B2G) +#if defined(XP_WIN) // Request Windows message deferral behavior on our side of the PContent // channel. Generally only applies to the situation where we get caught in // a deadlock with the plugin process when sending CPOWs. @@ -2244,37 +2172,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority, } } -#ifdef MOZ_CONTENT_SANDBOX - bool shouldSandbox = true; - MaybeFileDesc brokerFd = void_t(); -#ifdef XP_LINUX - // XXX: Checking the pref here makes it possible to enable/disable sandboxing - // during an active session. Currently the pref is only used for testing - // purpose. If the decision is made to permanently rely on the pref, this - // should be changed so that it is required to restart firefox for the change - // of value to take effect. - shouldSandbox = (Preferences::GetInt("security.sandbox.content.level") > 0) && - !PR_GetEnv("MOZ_DISABLE_CONTENT_SANDBOX"); - - if (shouldSandbox) { - MOZ_ASSERT(!mSandboxBroker); - UniquePtr<SandboxBroker::Policy> policy = - sSandboxBrokerPolicyFactory->GetContentPolicy(Pid()); - if (policy) { - brokerFd = FileDescriptor(); - mSandboxBroker = SandboxBroker::Create(Move(policy), Pid(), brokerFd); - if (!mSandboxBroker) { - KillHard("SandboxBroker::Create failed"); - return; - } - MOZ_ASSERT(static_cast<const FileDescriptor&>(brokerFd).IsValid()); - } - } -#endif - if (shouldSandbox && !SendSetProcessSandbox(brokerFd)) { - KillHard("SandboxInitFailed"); - } -#endif #if defined(XP_WIN) // Send the info needed to join the browser process's audio session. nsID id; @@ -2746,50 +2643,6 @@ ContentParent::Observe(nsISupports* aSubject, else if (!strcmp(aTopic, "last-pb-context-exited")) { Unused << SendLastPrivateDocShellDestroyed(); } -#ifdef MOZ_WIDGET_GONK - else if(!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) { - nsCOMPtr<nsIVolume> vol = do_QueryInterface(aSubject); - if (!vol) { - return NS_ERROR_NOT_AVAILABLE; - } - - nsString volName; - nsString mountPoint; - int32_t state; - int32_t mountGeneration; - bool isMediaPresent; - bool isSharing; - bool isFormatting; - bool isFake; - bool isUnmounting; - bool isRemovable; - bool isHotSwappable; - - vol->GetName(volName); - vol->GetMountPoint(mountPoint); - vol->GetState(&state); - vol->GetMountGeneration(&mountGeneration); - vol->GetIsMediaPresent(&isMediaPresent); - vol->GetIsSharing(&isSharing); - vol->GetIsFormatting(&isFormatting); - vol->GetIsFake(&isFake); - vol->GetIsUnmounting(&isUnmounting); - vol->GetIsRemovable(&isRemovable); - vol->GetIsHotSwappable(&isHotSwappable); - - Unused << SendFileSystemUpdate(volName, mountPoint, state, - mountGeneration, isMediaPresent, - isSharing, isFormatting, isFake, - isUnmounting, isRemovable, isHotSwappable); - } else if (!strcmp(aTopic, "phone-state-changed")) { - nsString state(aData); - Unused << SendNotifyPhoneStateChange(state); - } - else if(!strcmp(aTopic, NS_VOLUME_REMOVED)) { - nsString volName(aData); - Unused << SendVolumeRemoved(volName); - } -#endif #ifdef ACCESSIBILITY else if (aData && !strcmp(aTopic, "a11y-init-or-shutdown")) { if (*aData == '1') { @@ -3458,29 +3311,12 @@ ContentParent::RecvPSpeechSynthesisConstructor(PSpeechSynthesisParent* aActor) bool ContentParent::RecvSpeakerManagerGetSpeakerStatus(bool* aValue) { -#ifdef MOZ_WIDGET_GONK - *aValue = false; - RefPtr<SpeakerManagerService> service = - SpeakerManagerService::GetOrCreateSpeakerManagerService(); - MOZ_ASSERT(service); - - *aValue = service->GetSpeakerStatus(); - return true; -#endif return false; } bool ContentParent::RecvSpeakerManagerForceSpeaker(const bool& aEnable) { -#ifdef MOZ_WIDGET_GONK - RefPtr<SpeakerManagerService> service = - SpeakerManagerService::GetOrCreateSpeakerManagerService(); - MOZ_ASSERT(service); - service->ForceSpeaker(aEnable, mChildID); - - return true; -#endif return false; } @@ -4036,49 +3872,22 @@ bool ContentParent::RecvCreateFakeVolume(const nsString& fsName, const nsString& mountPoint) { -#ifdef MOZ_WIDGET_GONK - nsresult rv; - nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv); - if (vs) { - vs->CreateFakeVolume(fsName, mountPoint); - } - return true; -#else - NS_WARNING("ContentParent::RecvCreateFakeVolume shouldn't be called when MOZ_WIDGET_GONK is not defined"); + NS_WARNING("ContentParent::RecvCreateFakeVolume shouldn't be called"); return false; -#endif } bool ContentParent::RecvSetFakeVolumeState(const nsString& fsName, const int32_t& fsState) { -#ifdef MOZ_WIDGET_GONK - nsresult rv; - nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv); - if (vs) { - vs->SetFakeVolumeState(fsName, fsState); - } - return true; -#else - NS_WARNING("ContentParent::RecvSetFakeVolumeState shouldn't be called when MOZ_WIDGET_GONK is not defined"); + NS_WARNING("ContentParent::RecvSetFakeVolumeState shouldn't be called"); return false; -#endif } bool ContentParent::RecvRemoveFakeVolume(const nsString& fsName) { -#ifdef MOZ_WIDGET_GONK - nsresult rv; - nsCOMPtr<nsIVolumeService> vs = do_GetService(NS_VOLUMESERVICE_CONTRACTID, &rv); - if (vs) { - vs->RemoveFakeVolume(fsName); - } - return true; -#else - NS_WARNING("ContentParent::RecvRemoveFakeVolume shouldn't be called when MOZ_WIDGET_GONK is not defined"); + NS_WARNING("ContentParent::RecvRemoveFakeVolume shouldn't be called"); return false; -#endif } bool diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index a3750de1a..3f74b10e1 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -46,11 +46,6 @@ class PRemoteSpellcheckEngineParent; class ProfileGatherer; #endif -#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX) -class SandboxBroker; -class SandboxBrokerPolicyFactory; -#endif - namespace embedding { class PrintingParent; } @@ -1152,12 +1147,6 @@ private: UniquePtr<gfx::DriverCrashGuard> mDriverCrashGuard; -#if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX) - mozilla::UniquePtr<SandboxBroker> mSandboxBroker; - static mozilla::UniquePtr<SandboxBrokerPolicyFactory> - sSandboxBrokerPolicyFactory; -#endif - #ifdef NS_PRINTING RefPtr<embedding::PrintingParent> mPrintingParent; #endif diff --git a/dom/ipc/ContentProcess.cpp b/dom/ipc/ContentProcess.cpp index 2413d8808..986617f55 100644 --- a/dom/ipc/ContentProcess.cpp +++ b/dom/ipc/ContentProcess.cpp @@ -8,122 +8,17 @@ #include "ContentProcess.h" -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) -#include <stdlib.h> -#endif - -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) -#include "mozilla/Preferences.h" -#include "nsAppDirectoryServiceDefs.h" -#include "nsDirectoryService.h" -#include "nsDirectoryServiceDefs.h" -#endif - using mozilla::ipc::IOThreadChild; namespace mozilla { namespace dom { -#if defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) -static bool -IsSandboxTempDirRequired() -{ - // On Windows, a sandbox-writable temp directory is only used - // when sandbox pref level >= 1. - return Preferences::GetInt("security.sandbox.content.level") >= 1; -} - -static void -SetTmpEnvironmentVariable(nsIFile* aValue) -{ - // Save the TMP environment variable so that is is picked up by GetTempPath(). - // Note that we specifically write to the TMP variable, as that is the first - // variable that is checked by GetTempPath() to determine its output. - nsAutoString fullTmpPath; - nsresult rv = aValue->GetPath(fullTmpPath); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - Unused << NS_WARN_IF(!SetEnvironmentVariableW(L"TMP", fullTmpPath.get())); - // We also set TEMP in case there is naughty third-party code that is - // referencing the environment variable directly. - Unused << NS_WARN_IF(!SetEnvironmentVariableW(L"TEMP", fullTmpPath.get())); -} -#endif - -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) -static bool -IsSandboxTempDirRequired() -{ - // On OSX, use the sandbox-writable temp when the pref level >= 1. - return (Preferences::GetInt("security.sandbox.content.level") >= 1); -} - -static void -SetTmpEnvironmentVariable(nsIFile* aValue) -{ - nsAutoCString fullTmpPath; - nsresult rv = aValue->GetNativePath(fullTmpPath); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - Unused << NS_WARN_IF(setenv("TMPDIR", fullTmpPath.get(), 1) != 0); -} -#endif - -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) -static void -SetUpSandboxEnvironment() -{ - MOZ_ASSERT(nsDirectoryService::gService, - "SetUpSandboxEnvironment relies on nsDirectoryService being initialized"); - - if (!IsSandboxTempDirRequired()) { - return; - } - - nsCOMPtr<nsIFile> sandboxedContentTemp; - nsresult rv = - nsDirectoryService::gService->Get(NS_APP_CONTENT_PROCESS_TEMP_DIR, - NS_GET_IID(nsIFile), - getter_AddRefs(sandboxedContentTemp)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - // Change the gecko defined temp directory to our sandbox-writable one. - // Undefine returns a failure if the property is not already set. - Unused << nsDirectoryService::gService->Undefine(NS_OS_TEMP_DIR); - rv = nsDirectoryService::gService->Set(NS_OS_TEMP_DIR, sandboxedContentTemp); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - SetTmpEnvironmentVariable(sandboxedContentTemp); -} -#endif - void ContentProcess::SetAppDir(const nsACString& aPath) { mXREEmbed.SetAppDir(aPath); } -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) -void -ContentProcess::SetProfile(const nsACString& aProfile) -{ - bool flag; - nsresult rv = - XRE_GetFileFromPath(aProfile.BeginReading(), getter_AddRefs(mProfileDir)); - if (NS_FAILED(rv) || - NS_FAILED(mProfileDir->Exists(&flag)) || !flag) { - NS_WARNING("Invalid profile directory passed to content process."); - mProfileDir = nullptr; - } -} -#endif - bool ContentProcess::Init() { @@ -134,14 +29,6 @@ ContentProcess::Init() mContent.InitXPCOM(); mContent.InitGraphicsDeviceData(); -#if (defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - mContent.SetProfileDir(mProfileDir); -#endif - -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - SetUpSandboxEnvironment(); -#endif - return true; } diff --git a/dom/ipc/ContentProcess.h b/dom/ipc/ContentProcess.h index bf9968f8c..3950368bd 100644 --- a/dom/ipc/ContentProcess.h +++ b/dom/ipc/ContentProcess.h @@ -39,18 +39,10 @@ public: void SetAppDir(const nsACString& aPath); -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - void SetProfile(const nsACString& aProfile); -#endif - private: ContentChild mContent; mozilla::ipc::ScopedXREEmbed mXREEmbed; -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - nsCOMPtr<nsIFile> mProfileDir; -#endif - #if defined(XP_WIN) // This object initializes and configures COM. mozilla::mscom::MainThreadRuntime mCOMRuntime; diff --git a/dom/ipc/TabContext.cpp b/dom/ipc/TabContext.cpp index b36dbc5eb..362bce3a4 100644 --- a/dom/ipc/TabContext.cpp +++ b/dom/ipc/TabContext.cpp @@ -358,12 +358,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams) case IPCTabContext::TUnsafeIPCTabContext: { // XXXcatalinb: This used *only* by ServiceWorkerClients::OpenWindow. // It is meant as a temporary solution until service workers can - // provide a TabChild equivalent. Don't allow this on b2g since - // it might be used to escalate privileges. -#ifdef MOZ_B2G - mInvalidReason = "ServiceWorkerClients::OpenWindow is not supported."; - return; -#endif + // provide a TabChild equivalent. if (!Preferences::GetBool("dom.serviceWorkers.enabled", false)) { mInvalidReason = "ServiceWorkers should be enabled."; return; diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index 71d193d44..c34ac5d48 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -112,11 +112,6 @@ if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_TARGET'] == 'Darwin': 'mozsandbox', ] -if CONFIG['MOZ_CONTENT_SANDBOX'] and CONFIG['OS_ARCH'] == 'Linux': - USE_LIBS += [ - 'mozsandbox', - ] - LOCAL_INCLUDES += [ '/caps', '/chrome', @@ -145,12 +140,6 @@ LOCAL_INCLUDES += [ '/xpcom/threads', ] -if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT': - LOCAL_INCLUDES += [ - '/security/sandbox/chromium', - '/security/sandbox/chromium-shim', - ] - if CONFIG['OS_ARCH'] != 'WINNT': LOCAL_INCLUDES += [ '/modules/libjar', @@ -158,7 +147,7 @@ if CONFIG['OS_ARCH'] != 'WINNT': DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX'] -if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk'): +if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2'): DEFINES['MOZ_ENABLE_FREETYPE'] = True if CONFIG['MOZ_TOOLKIT_SEARCH']: diff --git a/dom/ipc/tests/test_cpow_cookies.html b/dom/ipc/tests/test_cpow_cookies.html index 1e55d3878..d8f87cced 100644 --- a/dom/ipc/tests/test_cpow_cookies.html +++ b/dom/ipc/tests/test_cpow_cookies.html @@ -81,7 +81,8 @@ ["dom.ipc.browser_frames.oop_by_default", true], ["dom.mozBrowserFramesEnabled", true], ["network.disable.ipc.security", true], - ["browser.pagethumbnails.capturing_disabled", true] + ["browser.pagethumbnails.capturing_disabled", true], + ["security.data_uri.block_toplevel_data_uri_navigations", false], ] }, runTests); }); |