From 54c479af3a81f09be57465185d56ab1217a8b47f Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 19 Apr 2018 14:21:10 +0200 Subject: Bug 1122124: Fix default profile setting after reset, keep profile name Native in moebius https://github.com/MoonchildProductions/moebius/pull/184 --- toolkit/xre/nsAppRunner.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 530e4a353..9fb20e5e2 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1886,17 +1886,20 @@ ShowProfileManager(nsIToolkitProfileService* aProfileSvc, } /** - * Set the currently running profile as the default/selected one. + * Get the currently running profile using its root directory. * + * @param aProfileSvc The profile service * @param aCurrentProfileRoot The root directory of the current profile. - * @return an error if aCurrentProfileRoot is not found or the profile could not - * be set as the default. + * @param aProfile Out-param that returns the profile object. + * @return an error if aCurrentProfileRoot is not found */ static nsresult -SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc, - nsIFile* aCurrentProfileRoot) +GetCurrentProfile(nsIToolkitProfileService* aProfileSvc, + nsIFile* aCurrentProfileRoot, + nsIToolkitProfile** aProfile) { NS_ENSURE_ARG_POINTER(aProfileSvc); + NS_ENSURE_ARG_POINTER(aProfile); nsCOMPtr profiles; nsresult rv = aProfileSvc->GetProfiles(getter_AddRefs(profiles)); @@ -1912,7 +1915,8 @@ SetCurrentProfileAsDefault(nsIToolkitProfileService* aProfileSvc, profile->GetRootDir(getter_AddRefs(profileRoot)); profileRoot->Equals(aCurrentProfileRoot, &foundMatchingProfile); if (foundMatchingProfile) { - return aProfileSvc->SetSelectedProfile(profile); + profile.forget(aProfile); + return NS_OK; } rv = profiles->GetNext(getter_AddRefs(supports)); } @@ -3749,15 +3753,22 @@ XREMain::XRE_mainRun() nsresult backupCreated = ProfileResetCleanup(profileBeingReset); if (NS_FAILED(backupCreated)) NS_WARNING("Could not cleanup the profile that was reset"); - // Set the new profile as the default after we're done cleaning up the old profile, - // iff that profile was already the default - if (profileWasSelected) { - // this is actually "broken" - see bug 1122124 - rv = SetCurrentProfileAsDefault(mProfileSvc, mProfD); - if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default"); + nsCOMPtr newProfile; + rv = GetCurrentProfile(mProfileSvc, mProfD, getter_AddRefs(newProfile)); + if (NS_SUCCEEDED(rv)) { + newProfile->SetName(gResetOldProfileName); + // Set the new profile as the default after we're done cleaning up the old profile, + // iff that profile was already the default + if (profileWasSelected) { + rv = mProfileSvc->SetDefaultProfile(newProfile); + if (NS_FAILED(rv)) NS_WARNING("Could not set current profile as the default"); + } + } else { + NS_WARNING("Could not find current profile to set as default / change name."); } - // Need to write out the fact that the profile has been removed and potentially - // that the selected/default profile changed. + + // Need to write out the fact that the profile has been removed, the new profile + // renamed, and potentially that the selected/default profile changed. mProfileSvc->Flush(); } } -- cgit v1.2.3 From 1a1d8ddc8cbba1cb405ca62f2be7402e39bb5a68 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 19 Apr 2018 14:29:05 +0200 Subject: moebius#84: Fix: The profile - resetting https://github.com/MoonchildProductions/moebius/pull/184 --- toolkit/xre/nsAppRunner.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 9fb20e5e2..a7b2b5146 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -3743,7 +3743,12 @@ XREMain::XRE_mainRun() if (gDoProfileReset) { // Automatically migrate from the current application if we just // reset the profile. - aKey = MOZ_APP_NAME; + // For Basilisk and Pale Moon: + // Hard-code MOZ_APP_NAME to firefox because of hard-coded type in migrator. + aKey = (((MOZ_APP_NAME == "basilisk") + || (MOZ_APP_NAME == "palemoon")) + ? "firefox" : MOZ_APP_NAME); + } pm->Migrate(&mDirProvider, aKey, gResetOldProfileName); } @@ -3757,6 +3762,7 @@ XREMain::XRE_mainRun() rv = GetCurrentProfile(mProfileSvc, mProfD, getter_AddRefs(newProfile)); if (NS_SUCCEEDED(rv)) { newProfile->SetName(gResetOldProfileName); + mProfileName.Assign(gResetOldProfileName); // Set the new profile as the default after we're done cleaning up the old profile, // iff that profile was already the default if (profileWasSelected) { -- cgit v1.2.3 From 8b960b23ac31d4dd0763f91ab5f494251467eeb1 Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Thu, 19 Apr 2018 19:49:01 +0200 Subject: moebius#205: Fix: The profile - resetting (the custom profile name) https://github.com/MoonchildProductions/moebius/pull/205 --- toolkit/xre/ProfileReset.cpp | 12 +++++++--- toolkit/xre/ProfileReset.h | 1 + toolkit/xre/nsAppRunner.cpp | 52 +++++++++++++++++++++++--------------------- 3 files changed, 37 insertions(+), 28 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/ProfileReset.cpp b/toolkit/xre/ProfileReset.cpp index aef2d7746..c9e2ef8d4 100644 --- a/toolkit/xre/ProfileReset.cpp +++ b/toolkit/xre/ProfileReset.cpp @@ -31,13 +31,19 @@ static const char kProfileProperties[] = * Creates a new profile with a timestamp in the name to use for profile reset. */ nsresult -CreateResetProfile(nsIToolkitProfileService* aProfileSvc, nsIToolkitProfile* *aNewProfile) +CreateResetProfile(nsIToolkitProfileService* aProfileSvc, const nsACString& aOldProfileName, nsIToolkitProfile* *aNewProfile) { MOZ_ASSERT(aProfileSvc, "NULL profile service"); nsCOMPtr newProfile; - // Make the new profile "default-" + the time in seconds since epoch for uniqueness. - nsAutoCString newProfileName("default-"); + // Make the new profile the old profile (or "default-") + the time in seconds since epoch for uniqueness. + nsAutoCString newProfileName; + if (!aOldProfileName.IsEmpty()) { + newProfileName.Assign(aOldProfileName); + newProfileName.Append("-"); + } else { + newProfileName.Assign("default-"); + } newProfileName.Append(nsPrintfCString("%lld", PR_Now() / 1000)); nsresult rv = aProfileSvc->CreateProfile(nullptr, // choose a default dir for us newProfileName, diff --git a/toolkit/xre/ProfileReset.h b/toolkit/xre/ProfileReset.h index 7b5efbc4e..a164fe075 100644 --- a/toolkit/xre/ProfileReset.h +++ b/toolkit/xre/ProfileReset.h @@ -11,6 +11,7 @@ static bool gProfileResetCleanupCompleted = false; static const char kResetProgressURL[] = "chrome://global/content/resetProfileProgress.xul"; nsresult CreateResetProfile(nsIToolkitProfileService* aProfileSvc, + const nsACString& aOldProfileName, nsIToolkitProfile* *aNewProfile); nsresult ProfileResetCleanup(nsIToolkitProfile* aOldProfile); diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index a7b2b5146..cf6797599 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -2004,7 +2004,7 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n if (gDoProfileReset) { // If we're resetting a profile, create a new one and use it to startup. nsCOMPtr newProfile; - rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile)); + rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile)); if (NS_SUCCEEDED(rv)) { rv = newProfile->GetRootDir(getter_AddRefs(lf)); NS_ENSURE_SUCCESS(rv, rv); @@ -2150,20 +2150,20 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n return ProfileLockedDialog(profile, unlocker, aNative, &tempProfileLock); } - nsCOMPtr newProfile; - rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile)); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to create a profile to reset to."); - gDoProfileReset = false; - } else { - nsresult gotName = profile->GetName(gResetOldProfileName); - if (NS_SUCCEEDED(gotName)) { - profile = newProfile; - } else { - NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset."); - gResetOldProfileName.Truncate(0); + nsresult gotName = profile->GetName(gResetOldProfileName); + if (NS_SUCCEEDED(gotName)) { + nsCOMPtr newProfile; + rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile)); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to create a profile to reset to."); gDoProfileReset = false; + } else { + profile = newProfile; } + } else { + NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset."); + gResetOldProfileName.Truncate(0); + gDoProfileReset = false; } } @@ -2258,20 +2258,22 @@ SelectProfile(nsIProfileLock* *aResult, nsIToolkitProfileService* aProfileSvc, n return ProfileLockedDialog(profile, unlocker, aNative, &tempProfileLock); } - nsCOMPtr newProfile; - rv = CreateResetProfile(aProfileSvc, getter_AddRefs(newProfile)); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to create a profile to reset to."); - gDoProfileReset = false; - } else { - nsresult gotName = profile->GetName(gResetOldProfileName); - if (NS_SUCCEEDED(gotName)) { - profile = newProfile; - } else { - NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset."); - gResetOldProfileName.Truncate(0); + nsresult gotName = profile->GetName(gResetOldProfileName); + if (NS_SUCCEEDED(gotName)) { + nsCOMPtr newProfile; + rv = CreateResetProfile(aProfileSvc, gResetOldProfileName, getter_AddRefs(newProfile)); + if (NS_FAILED(rv)) { + NS_WARNING("Failed to create a profile to reset to."); gDoProfileReset = false; } + else { + profile = newProfile; + } + } + else { + NS_WARNING("Failed to get the name of the profile we're resetting, so aborting reset."); + gResetOldProfileName.Truncate(0); + gDoProfileReset = false; } } -- cgit v1.2.3 From 2b3b701187e144dad54d00927232ad2949b71b3c Mon Sep 17 00:00:00 2001 From: janekptacijarabaci Date: Fri, 20 Apr 2018 08:30:19 +0200 Subject: [PALEMOON] Fix: The profile resseting - partially (no the cmd "-migration") https://github.com/MoonchildProductions/UXP/commit/aaf3409c46a5e472bc539a6ad5902f886c980e1f --- toolkit/xre/nsAppRunner.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index cf6797599..776044d72 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -1357,7 +1357,9 @@ DumpHelp() " -v or --version Print %s version.\n" " -P Start with .\n" " --profile Start with profile at .\n" +#ifdef MC_BASILISK " --migration Start with migration wizard.\n" +#endif " --ProfileManager Start with ProfileManager.\n" " --no-remote Do not accept or send remote commands;\n" " implies --new-instance.\n" -- cgit v1.2.3 From 21f5ffe826a1c776d25354c01697ff1bff9b04e9 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 21 Apr 2018 15:05:05 +0200 Subject: Disallow E10S to run. --- toolkit/xre/nsAppRunner.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 776044d72..3493cd837 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4306,7 +4306,6 @@ MultiprocessBlockPolicy() { if (addonsCanDisable && disabledByAddons) { gMultiprocessBlockPolicy = kE10sDisabledForAddons; - return gMultiprocessBlockPolicy; } #if defined(XP_WIN) @@ -4340,16 +4339,13 @@ MultiprocessBlockPolicy() { if (disabledForA11y) { gMultiprocessBlockPolicy = kE10sDisabledForAccessibility; - return gMultiprocessBlockPolicy; } #endif + + // We do not support E10S, block by policy. + gMultiprocessBlockPolicy = kE10sForceDisabled; - /* - * None of the blocking policies matched, so e10s is allowed to run. - * Cache the information and return 0, indicating success. - */ - gMultiprocessBlockPolicy = 0; - return 0; + return gMultiprocessBlockPolicy; } bool -- cgit v1.2.3 From 0a744b1cfeecdd2487d9166792ac5234edc9ee6a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 21 Apr 2018 17:33:10 +0200 Subject: Remove unused header file for MeeGo Touch --- toolkit/xre/MozMeegoAppService.h | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 toolkit/xre/MozMeegoAppService.h (limited to 'toolkit/xre') diff --git a/toolkit/xre/MozMeegoAppService.h b/toolkit/xre/MozMeegoAppService.h deleted file mode 100644 index 063d03e02..000000000 --- a/toolkit/xre/MozMeegoAppService.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef MOZMEEGOAPPSERVICE_H -#define MOZMEEGOAPPSERVICE_H - -#include - -/** - * App service class, which prevents registration to d-bus - * and allows multiple instances of application. This is - * required for Mozillas remote service to work, because - * it is initialized after MApplication. - */ -class MozMeegoAppService: public MApplicationService -{ - Q_OBJECT -public: - MozMeegoAppService(): MApplicationService(QString()) {} -public Q_SLOTS: - virtual QString registeredName() { return QString(); } - virtual bool isRegistered() { return false; } - virtual bool registerService() { return true; } -}; -#endif // MOZMEEGOAPPSERVICE_H -- cgit v1.2.3 From 755e1020782fb42863e97d58a3e44d2eca760bb0 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 2 May 2018 21:58:04 +0200 Subject: Remove content process sandbox code. --- toolkit/xre/nsAppRunner.cpp | 11 --- toolkit/xre/nsEmbedFunctions.cpp | 22 ----- toolkit/xre/nsXREDirProvider.cpp | 205 --------------------------------------- toolkit/xre/nsXREDirProvider.h | 9 -- 4 files changed, 247 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 3493cd837..ddba0de61 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -106,10 +106,6 @@ #endif #endif -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) -#include "nsIUUIDGenerator.h" -#endif - #ifdef ACCESSIBILITY #include "nsAccessibilityService.h" #if defined(XP_WIN) @@ -2958,13 +2954,6 @@ XREMain::XRE_mainInit(bool* aExitFlag) Telemetry::Accumulate(Telemetry::SANDBOX_BROKER_INITIALIZED, true); } else { Telemetry::Accumulate(Telemetry::SANDBOX_BROKER_INITIALIZED, false); -#if defined(MOZ_CONTENT_SANDBOX) - // If we're sandboxing content and we fail to initialize, then crashing here - // seems like the sensible option. - if (BrowserTabsRemoteAutostart()) { - MOZ_CRASH("Failed to initialize broker services, can't continue."); - } -#endif // Otherwise just warn for the moment, as most things will work. NS_WARNING("Failed to initialize broker services, sandboxed processes will " "fail to start."); diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 4a612e495..5f5dda939 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -80,10 +80,6 @@ #include "mozilla/sandboxing/loggingCallbacks.h" #endif -#if defined(MOZ_CONTENT_SANDBOX) && !defined(MOZ_WIDGET_GONK) -#include "mozilla/Preferences.h" -#endif - #ifdef MOZ_IPDL_TESTS #include "mozilla/_ipdltest/IPDLUnitTests.h" #include "mozilla/_ipdltest/IPDLUnitTestProcessChild.h" @@ -519,11 +515,6 @@ XRE_InitChildProcess(int aArgc, // If passed in grab the application path for xpcom init bool foundAppdir = false; -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - // If passed in grab the profile path for sandboxing - bool foundProfile = false; -#endif - for (int idx = aArgc; idx > 0; idx--) { if (aArgv[idx] && !strcmp(aArgv[idx], "-appdir")) { MOZ_ASSERT(!foundAppdir); @@ -539,19 +530,6 @@ XRE_InitChildProcess(int aArgc, if (aArgv[idx] && !strcmp(aArgv[idx], "-safeMode")) { gSafeMode = true; } - -#if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX) - if (aArgv[idx] && !strcmp(aArgv[idx], "-profile")) { - MOZ_ASSERT(!foundProfile); - if (foundProfile) { - continue; - } - nsCString profile; - profile.Assign(nsDependentCString(aArgv[idx+1])); - static_cast(process.get())->SetProfile(profile); - foundProfile = true; - } -#endif /* XP_MACOSX && MOZ_CONTENT_SANDBOX */ } } break; diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 09168319f..04e2e1ebf 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -62,11 +62,6 @@ #include "UIKitDirProvider.h" #endif -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) -#include "nsIUUIDGenerator.h" -#include "mozilla/Unused.h" -#endif - #if defined(XP_MACOSX) #define APP_REGISTRY_NAME "Application Registry" #elif defined(XP_WIN) @@ -77,14 +72,6 @@ #define PREF_OVERRIDE_DIRNAME "preferences" -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) -static already_AddRefed GetContentProcessSandboxTempDir(); -static nsresult DeleteDirIfExists(nsIFile *dir); -static bool IsContentSandboxDisabled(); -static const char* GetContentProcessTempBaseDirKey(); -static already_AddRefed CreateContentProcessSandboxTempDir(); -#endif - static already_AddRefed CloneAndAppend(nsIFile* aFile, const char* name) { @@ -495,14 +482,6 @@ nsXREDirProvider::GetFile(const char* aProperty, bool* aPersistent, bool unused; rv = dirsvc->GetFile("XCurProcD", &unused, getter_AddRefs(file)); } -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - else if (!strcmp(aProperty, NS_APP_CONTENT_PROCESS_TEMP_DIR)) { - if (!mContentTempDir && NS_FAILED((rv = LoadContentProcessTempDir()))) { - return rv; - } - rv = mContentTempDir->Clone(getter_AddRefs(file)); - } -#endif // defined(XP_WIN) && defined(MOZ_CONTENT_SANDBOX) else if (NS_SUCCEEDED(GetProfileStartupDir(getter_AddRefs(file)))) { // We need to allow component, xpt, and chrome registration to // occur prior to the profile-after-change notification. @@ -729,176 +708,6 @@ LoadExtensionDirectories(nsINIParser &parser, while (true); } -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - -static const char* -GetContentProcessTempBaseDirKey() -{ -#if defined(XP_WIN) - return NS_WIN_LOW_INTEGRITY_TEMP_BASE; -#else - return NS_OS_TEMP_DIR; -#endif -} - -// -// Sets mContentTempDir so that it refers to the appropriate temp dir. -// If the sandbox is enabled, NS_APP_CONTENT_PROCESS_TEMP_DIR, otherwise -// NS_OS_TEMP_DIR is used. -// -nsresult -nsXREDirProvider::LoadContentProcessTempDir() -{ - mContentTempDir = GetContentProcessSandboxTempDir(); - if (mContentTempDir) { - return NS_OK; - } else { - return NS_GetSpecialDirectory(NS_OS_TEMP_DIR, - getter_AddRefs(mContentTempDir)); - } -} - -static bool -IsContentSandboxDisabled() -{ - bool isSandboxDisabled = false; - if (!BrowserTabsRemoteAutostart()) { - return false; - } -#if defined(XP_WIN) || defined(XP_MACOSX) - isSandboxDisabled = Preferences::GetInt("security.sandbox.content.level") < 1; -#endif - return isSandboxDisabled; -} - -// -// If a content process sandbox temp dir is to be used, returns an nsIFile -// for the directory. Returns null if the content sandbox is disabled or -// an error occurs. -// -static already_AddRefed -GetContentProcessSandboxTempDir() -{ - if (IsContentSandboxDisabled()) { - return nullptr; - } - - nsCOMPtr localFile; - - nsresult rv = NS_GetSpecialDirectory(GetContentProcessTempBaseDirKey(), - getter_AddRefs(localFile)); - if (NS_WARN_IF(NS_FAILED(rv))) { - return nullptr; - } - - nsAutoString tempDirSuffix; - rv = Preferences::GetString("security.sandbox.content.tempDirSuffix", - &tempDirSuffix); - if (NS_WARN_IF(NS_FAILED(rv)) || tempDirSuffix.IsEmpty()) { - return nullptr; - } - - rv = localFile->Append(NS_LITERAL_STRING("Temp-") + tempDirSuffix); - if (NS_WARN_IF(NS_FAILED(rv))) { - return nullptr; - } - - return localFile.forget(); -} - -// -// Create a temporary directory for use from sandboxed content processes. -// Only called in the parent. The path is derived from a UUID stored in a -// pref which is available to content processes. Returns null if the -// content sandbox is disabled or if an error occurs. -// -static already_AddRefed -CreateContentProcessSandboxTempDir() -{ - if (IsContentSandboxDisabled()) { - return nullptr; - } - - // Get (and create if blank) temp directory suffix pref. - nsresult rv; - nsAdoptingString tempDirSuffix = - Preferences::GetString("security.sandbox.content.tempDirSuffix"); - if (tempDirSuffix.IsEmpty()) { - nsCOMPtr uuidgen = - do_GetService("@mozilla.org/uuid-generator;1", &rv); - if (NS_WARN_IF(NS_FAILED(rv))) { - return nullptr; - } - - nsID uuid; - rv = uuidgen->GenerateUUIDInPlace(&uuid); - if (NS_WARN_IF(NS_FAILED(rv))) { - return nullptr; - } - - char uuidChars[NSID_LENGTH]; - uuid.ToProvidedString(uuidChars); - tempDirSuffix.AssignASCII(uuidChars); - - // Save the pref - rv = Preferences::SetCString("security.sandbox.content.tempDirSuffix", - uuidChars); - if (NS_WARN_IF(NS_FAILED(rv))) { - // If we fail to save the pref we don't want to create the temp dir, - // because we won't be able to clean it up later. - return nullptr; - } - - nsCOMPtr prefsvc = Preferences::GetService(); - if (!prefsvc || NS_FAILED((rv = prefsvc->SavePrefFile(nullptr)))) { - // Again, if we fail to save the pref file we might not be able to clean - // up the temp directory, so don't create one. - NS_WARNING("Failed to save pref file, cannot create temp dir."); - return nullptr; - } - } - - nsCOMPtr sandboxTempDir = GetContentProcessSandboxTempDir(); - if (!sandboxTempDir) { - NS_WARNING("Failed to determine sandbox temp dir path."); - return nullptr; - } - - // Remove the directory. It may exist due to a previous crash. - if (NS_FAILED(DeleteDirIfExists(sandboxTempDir))) { - NS_WARNING("Failed to reset sandbox temp dir."); - return nullptr; - } - - // Create the directory - rv = sandboxTempDir->Create(nsIFile::DIRECTORY_TYPE, 0700); - if (NS_FAILED(rv)) { - NS_WARNING("Failed to create sandbox temp dir."); - return nullptr; - } - - return sandboxTempDir.forget(); -} - -static nsresult -DeleteDirIfExists(nsIFile* dir) -{ - if (dir) { - // Don't return an error if the directory doesn't exist. - // Windows Remove() returns NS_ERROR_FILE_NOT_FOUND while - // OS X returns NS_ERROR_FILE_TARGET_DOES_NOT_EXIST. - nsresult rv = dir->Remove(/* aRecursive */ true); - if (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND && - rv != NS_ERROR_FILE_TARGET_DOES_NOT_EXIST) { - return rv; - } - } - return NS_OK; -} - -#endif // (defined(XP_WIN) || defined(XP_MACOSX)) && - // defined(MOZ_CONTENT_SANDBOX) - void nsXREDirProvider::LoadExtensionBundleDirectories() { @@ -1203,14 +1012,6 @@ nsXREDirProvider::DoStartup() } obsSvc->NotifyObservers(nullptr, "profile-initial-state", nullptr); - -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - // The parent is responsible for creating the sandbox temp dir - if (XRE_IsParentProcess()) { - mContentProcessSandboxTempDir = CreateContentProcessSandboxTempDir(); - mContentTempDir = mContentProcessSandboxTempDir; - } -#endif } return NS_OK; } @@ -1221,12 +1022,6 @@ nsXREDirProvider::DoShutdown() PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER); if (mProfileNotified) { -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - if (XRE_IsParentProcess()) { - Unused << DeleteDirIfExists(mContentProcessSandboxTempDir); - } -#endif - nsCOMPtr obsSvc = mozilla::services::GetObserverService(); NS_ASSERTION(obsSvc, "No observer service?"); diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h index 7ec64da78..1190cc708 100644 --- a/toolkit/xre/nsXREDirProvider.h +++ b/toolkit/xre/nsXREDirProvider.h @@ -121,11 +121,6 @@ protected: // delimiters. static inline nsresult AppendProfileString(nsIFile* aFile, const char* aPath); -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - // Load the temp directory for sandboxed content processes - nsresult LoadContentProcessTempDir(); -#endif - // Calculate and register extension and theme bundle directories. void LoadExtensionBundleDirectories(); @@ -146,10 +141,6 @@ protected: nsCOMPtr mProfileDir; nsCOMPtr mProfileLocalDir; bool mProfileNotified; -#if (defined(XP_WIN) || defined(XP_MACOSX)) && defined(MOZ_CONTENT_SANDBOX) - nsCOMPtr mContentTempDir; - nsCOMPtr mContentProcessSandboxTempDir; -#endif nsCOMArray mAppBundleDirectories; nsCOMArray mExtensionDirectories; nsCOMArray mThemeDirectories; -- cgit v1.2.3 From 4613b91ecac2745252c40be64e73de5ff920b02b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 3 May 2018 01:24:31 +0200 Subject: Remove sandbox ductwork conditional code. --- toolkit/xre/moz.build | 6 ------ toolkit/xre/nsAppRunner.cpp | 42 ---------------------------------------- toolkit/xre/nsEmbedFunctions.cpp | 16 --------------- 3 files changed, 64 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/moz.build b/toolkit/xre/moz.build index 7ada19d41..55b59ca83 100644 --- a/toolkit/xre/moz.build +++ b/toolkit/xre/moz.build @@ -149,12 +149,6 @@ LOCAL_INCLUDES += [ '/xpcom/build', ] -if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT': - LOCAL_INCLUDES += [ - '/security/sandbox/chromium', - '/security/sandbox/chromium-shim', - ] - if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': LOCAL_INCLUDES += [ '/widget', diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index ddba0de61..2050b9671 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -193,14 +193,6 @@ #include "GeneratedJNIWrappers.h" #endif -#if defined(MOZ_SANDBOX) -#if defined(XP_LINUX) && !defined(ANDROID) -#include "mozilla/SandboxInfo.h" -#elif defined(XP_WIN) -#include "SandboxBroker.h" -#endif -#endif - extern uint32_t gRestartMode; extern void InstallSignalHandlers(const char *ProgramName); @@ -2948,18 +2940,6 @@ XREMain::XRE_mainInit(bool* aExitFlag) if (NS_FAILED(rv)) return 1; -#if defined(MOZ_SANDBOX) && defined(XP_WIN) - if (mAppData->sandboxBrokerServices) { - SandboxBroker::Initialize(mAppData->sandboxBrokerServices); - Telemetry::Accumulate(Telemetry::SANDBOX_BROKER_INITIALIZED, true); - } else { - Telemetry::Accumulate(Telemetry::SANDBOX_BROKER_INITIALIZED, false); - // Otherwise just warn for the moment, as most things will work. - NS_WARNING("Failed to initialize broker services, sandboxed processes will " - "fail to start."); - } -#endif - #ifdef XP_MACOSX // Set up ability to respond to system (Apple) events. This must occur before // ProcessUpdates to ensure that links clicked in external applications aren't @@ -3902,24 +3882,6 @@ XREMain::XRE_mainRun() } #endif /* MOZ_INSTRUMENT_EVENT_LOOP */ -#if defined(MOZ_SANDBOX) && defined(XP_LINUX) && !defined(MOZ_WIDGET_GONK) - // If we're on Linux, we now have information about the OS capabilities - // available to us. - SandboxInfo sandboxInfo = SandboxInfo::Get(); - Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_BPF, - sandboxInfo.Test(SandboxInfo::kHasSeccompBPF)); - Telemetry::Accumulate(Telemetry::SANDBOX_HAS_SECCOMP_TSYNC, - sandboxInfo.Test(SandboxInfo::kHasSeccompTSync)); - Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES_PRIVILEGED, - sandboxInfo.Test(SandboxInfo::kHasPrivilegedUserNamespaces)); - Telemetry::Accumulate(Telemetry::SANDBOX_HAS_USER_NAMESPACES, - sandboxInfo.Test(SandboxInfo::kHasUserNamespaces)); - Telemetry::Accumulate(Telemetry::SANDBOX_CONTENT_ENABLED, - sandboxInfo.Test(SandboxInfo::kEnabledForContent)); - Telemetry::Accumulate(Telemetry::SANDBOX_MEDIA_ENABLED, - sandboxInfo.Test(SandboxInfo::kEnabledForMedia)); -#endif /* MOZ_SANDBOX && XP_LINUX && !MOZ_WIDGET_GONK */ - { rv = appStartup->Run(); if (NS_FAILED(rv)) { @@ -3985,10 +3947,6 @@ XREMain::XRE_main(int argc, char* argv[], const nsXREAppData* aAppData) // See bug 1279614. XRE_CreateStatsObject(); -#if defined(MOZ_SANDBOX) && defined(XP_LINUX) && !defined(ANDROID) - SandboxInfo::ThreadingCheck(); -#endif - char aLocal; GeckoProfilerInitRAII profilerGuard(&aLocal); diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 5f5dda939..a59299c8b 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -75,11 +75,6 @@ #include "mozilla/Telemetry.h" -#if defined(MOZ_SANDBOX) && defined(XP_WIN) -#include "mozilla/sandboxTarget.h" -#include "mozilla/sandboxing/loggingCallbacks.h" -#endif - #ifdef MOZ_IPDL_TESTS #include "mozilla/_ipdltest/IPDLUnitTests.h" #include "mozilla/_ipdltest/IPDLUnitTestProcessChild.h" @@ -295,11 +290,6 @@ XRE_InitChildProcess(int aArgc, freopen("CONIN$", "r", stdin); } -#if defined(MOZ_SANDBOX) - if (aChildData->sandboxTargetServices) { - SandboxTarget::Instance()->SetTargetServices(aChildData->sandboxTargetServices); - } -#endif #endif // NB: This must be called before profiler_init @@ -565,12 +555,6 @@ XRE_InitChildProcess(int aArgc, ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY); #endif -#if defined(MOZ_SANDBOX) && defined(XP_WIN) - // We need to do this after the process has been initialised, as - // InitLoggingIfRequired may need access to prefs. - mozilla::sandboxing::InitLoggingIfRequired(aChildData->ProvideLogFunction); -#endif - OverrideDefaultLocaleIfNeeded(); // Run the UI event loop on the main thread. -- cgit v1.2.3 From b7d9dad58e5a3f87a6c767412941700bc8010044 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 12 May 2018 14:32:03 +0200 Subject: Remove MOZ_B2G leftovers and some dead B2G-only components. --- toolkit/xre/nsXREDirProvider.cpp | 36 ------------------------------------ toolkit/xre/nsXREDirProvider.h | 5 ----- 2 files changed, 41 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index 04e2e1ebf..f2d0b1b0f 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -126,10 +126,6 @@ nsXREDirProvider::Initialize(nsIFile *aXULAppDir, } } -#ifdef MOZ_B2G - LoadAppBundleDirs(); -#endif - return NS_OK; } @@ -761,38 +757,6 @@ nsXREDirProvider::LoadExtensionBundleDirectories() } } -#ifdef MOZ_B2G -void -nsXREDirProvider::LoadAppBundleDirs() -{ - nsCOMPtr dir; - bool persistent = false; - nsresult rv = GetFile(XRE_APP_DISTRIBUTION_DIR, &persistent, getter_AddRefs(dir)); - if (NS_FAILED(rv)) - return; - - dir->AppendNative(NS_LITERAL_CSTRING("bundles")); - - nsCOMPtr e; - rv = dir->GetDirectoryEntries(getter_AddRefs(e)); - if (NS_FAILED(rv)) - return; - - nsCOMPtr files = do_QueryInterface(e); - if (!files) - return; - - nsCOMPtr subdir; - while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(subdir))) && subdir) { - mAppBundleDirectories.AppendObject(subdir); - - nsCOMPtr manifest = - CloneAndAppend(subdir, "chrome.manifest"); - XRE_AddManifestLocation(NS_APP_LOCATION, manifest); - } -} -#endif - static const char *const kAppendPrefDir[] = { "defaults", "preferences", nullptr }; #ifdef DEBUG_bsmedberg diff --git a/toolkit/xre/nsXREDirProvider.h b/toolkit/xre/nsXREDirProvider.h index 1190cc708..655f664e6 100644 --- a/toolkit/xre/nsXREDirProvider.h +++ b/toolkit/xre/nsXREDirProvider.h @@ -124,11 +124,6 @@ protected: // Calculate and register extension and theme bundle directories. void LoadExtensionBundleDirectories(); -#ifdef MOZ_B2G - // Calculate and register app-bundled extension directories. - void LoadAppBundleDirs(); -#endif - void Append(nsIFile* aDirectory); nsCOMPtr mAppProvider; -- cgit v1.2.3 From e16bcd08aae85a7d9c2de5a4b1c733280cb81112 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 13 May 2018 00:08:52 +0200 Subject: Remove MOZ_WIDGET_GONK [2/2] Tag #288 --- toolkit/xre/EventTracer.cpp | 35 ---------- toolkit/xre/nsEmbedFunctions.cpp | 2 +- toolkit/xre/nsUpdateDriver.cpp | 144 ++------------------------------------- toolkit/xre/nsXREDirProvider.cpp | 12 ---- 4 files changed, 5 insertions(+), 188 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/EventTracer.cpp b/toolkit/xre/EventTracer.cpp index cb0d88524..f1118f1b2 100644 --- a/toolkit/xre/EventTracer.cpp +++ b/toolkit/xre/EventTracer.cpp @@ -65,12 +65,6 @@ #include #include -#ifdef MOZ_WIDGET_GONK -#include "nsThreadUtils.h" -#include "nsIObserverService.h" -#include "mozilla/Services.h" -#endif - using mozilla::TimeDuration; using mozilla::TimeStamp; using mozilla::FireAndWaitForTracerEvent; @@ -85,31 +79,6 @@ struct TracerStartClosure { int32_t mThresholdInterval; }; -#ifdef MOZ_WIDGET_GONK -class EventLoopLagDispatcher : public Runnable -{ - public: - explicit EventLoopLagDispatcher(int aLag) - : mLag(aLag) {} - - NS_IMETHOD Run() override - { - nsCOMPtr obsService = - mozilla::services::GetObserverService(); - if (!obsService) { - return NS_ERROR_FAILURE; - } - - nsAutoString value; - value.AppendInt(mLag); - return obsService->NotifyObservers(nullptr, "event-loop-lag", value.get()); - } - - private: - int mLag; -}; -#endif - /* * The tracer thread fires events at the native event loop roughly * every kMeasureInterval. It will sleep to attempt not to send them @@ -180,10 +149,6 @@ void TracerThread(void *arg) fprintf(log, "MOZ_EVENT_TRACE sample %llu %lf\n", now, duration.ToMilliseconds()); -#ifdef MOZ_WIDGET_GONK - NS_DispatchToMainThread( - new EventLoopLagDispatcher(int(duration.ToSecondsSigDigits() * 1000))); -#endif } if (next_sleep > duration.ToMilliseconds()) { diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index a59299c8b..f62dbdd6d 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -255,7 +255,7 @@ XRE_InitChildProcess(int aArgc, setupProfilingStuff(); #endif -#if !defined(MOZ_WIDGET_ANDROID) && !defined(MOZ_WIDGET_GONK) +#if !defined(MOZ_WIDGET_ANDROID) // On non-Fennec Gecko, the GMPLoader code resides in plugin-container, // and we must forward it through to the GMP code here. GMPProcessChild::SetGMPLoader(aChildData->gmpLoader.get()); diff --git a/toolkit/xre/nsUpdateDriver.cpp b/toolkit/xre/nsUpdateDriver.cpp index 54a711000..ab0bdf005 100644 --- a/toolkit/xre/nsUpdateDriver.cpp +++ b/toolkit/xre/nsUpdateDriver.cpp @@ -74,23 +74,6 @@ GetUpdateLog() #define UPDATER_PNG "updater.png" #endif -#if defined(MOZ_WIDGET_GONK) -#include - -static const int kB2GServiceArgc = 2; -static const char *kB2GServiceArgv[] = { "/system/bin/start", "b2g" }; - -static const char kAppUpdaterPrio[] = "app.update.updater.prio"; -static const char kAppUpdaterOomScoreAdj[] = "app.update.updater.oom_score_adj"; -static const char kAppUpdaterIOPrioClass[] = "app.update.updater.ioprio.class"; -static const char kAppUpdaterIOPrioLevel[] = "app.update.updater.ioprio.level"; - -static const int kAppUpdaterPrioDefault = 19; // -20..19 where 19 = lowest priority -static const int kAppUpdaterOomScoreAdjDefault = -1000; // -1000 = Never kill -static const int kAppUpdaterIOPrioClassDefault = IOPRIO_CLASS_IDLE; -static const int kAppUpdaterIOPrioLevelDefault = 0; // Doesn't matter for CLASS IDLE -#endif - static nsresult GetCurrentWorkingDir(char *buf, size_t size) { @@ -387,7 +370,7 @@ CopyUpdaterIntoUpdateDir(nsIFile *greDir, nsIFile *appDir, nsIFile *updateDir, * @param pathToAppend A new library path to prepend to LD_LIBRARY_PATH */ #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \ - !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) + !defined(XP_MACOSX) #include "prprf.h" #define PATH_SEPARATOR ":" #define LD_LIBRARY_PATH_ENVVAR_NAME "LD_LIBRARY_PATH" @@ -503,15 +486,9 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir, #else nsAutoCString appFilePath; -#if defined(MOZ_WIDGET_GONK) - appFilePath.Assign(kB2GServiceArgv[0]); - appArgc = kB2GServiceArgc; - appArgv = const_cast(kB2GServiceArgv); -#else rv = appFile->GetNativePath(appFilePath); if (NS_FAILED(rv)) return; -#endif nsAutoCString updaterPath; rv = updater->GetNativePath(updaterPath); @@ -617,19 +594,13 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir, PR_SetEnv("MOZ_SAFE_MODE_RESTART=1"); } #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \ - !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) + !defined(XP_MACOSX) AppendToLibPath(installDirPath.get()); #endif LOG(("spawning updater process for replacing [%s]\n", updaterPath.get())); #if defined(XP_UNIX) & !defined(XP_MACOSX) -# if defined(MOZ_WIDGET_GONK) - // In Gonk, we preload libmozglue, which the updater process doesn't need. - // Since the updater will move and delete libmozglue.so, this can actually - // stop the /system mount from correctly being remounted as read-only. - unsetenv("LD_PRELOAD"); -# endif exit(execv(updaterPath.get(), argv)); #elif defined(XP_WIN) // Switch the application using updater.exe @@ -647,46 +618,6 @@ SwitchToUpdatedApp(nsIFile *greDir, nsIFile *updateDir, #endif } -#if defined(MOZ_WIDGET_GONK) -static nsresult -GetOSApplyToDir(nsACString& applyToDir) -{ - nsCOMPtr ds = - do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID); - NS_ASSERTION(ds, "Can't get directory service"); - - nsCOMPtr osApplyToDir; - nsresult rv = ds->Get(XRE_OS_UPDATE_APPLY_TO_DIR, NS_GET_IID(nsIFile), - getter_AddRefs(osApplyToDir)); - if (NS_FAILED(rv)) { - LOG(("Can't get the OS applyTo dir")); - return rv; - } - - return osApplyToDir->GetNativePath(applyToDir); -} - -static void -SetOSApplyToDir(nsIUpdate* update, const nsACString& osApplyToDir) -{ - nsresult rv; - nsCOMPtr updateProperties = - do_QueryInterface(update, &rv); - - if (NS_FAILED(rv)) { - return; - } - - RefPtr variant = new nsVariant(); - rv = variant->SetAsACString(osApplyToDir); - if (NS_FAILED(rv)) { - return; - } - - updateProperties->SetProperty(NS_LITERAL_STRING("osApplyToDir"), variant); -} -#endif - /** * Apply an update. This applies to both normal and staged updates. * @@ -780,13 +711,9 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile, if (NS_FAILED(rv)) return; - // Get the directory where the update was staged for replace and GONK OS - // Updates or where it will be applied. -#ifndef MOZ_WIDGET_GONK - // OS Updates are only supported on GONK so force it to false on everything + // OS Updates were only supported on GONK so force it to false on everything // but GONK to simplify the following logic. isOSUpdate = false; -#endif nsAutoCString applyToDir; nsCOMPtr updatedDir; if (restart && !isOSUpdate) { @@ -806,15 +733,6 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile, return; } applyToDir = NS_ConvertUTF16toUTF8(applyToDirW); -#elif MOZ_WIDGET_GONK - if (isOSUpdate) { - if (!osApplyToDir) { - return; - } - rv = osApplyToDir->GetNativePath(applyToDir); - } else { - rv = updatedDir->GetNativePath(applyToDir); - } #else rv = updatedDir->GetNativePath(applyToDir); #endif @@ -900,33 +818,13 @@ ApplyUpdate(nsIFile *greDir, nsIFile *updateDir, nsIFile *statusFile, PR_SetEnv("MOZ_SAFE_MODE_RESTART=1"); } #if defined(MOZ_VERIFY_MAR_SIGNATURE) && !defined(XP_WIN) && \ - !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GONK) + !defined(XP_MACOSX) AppendToLibPath(installDirPath.get()); #endif if (isOSUpdate) { PR_SetEnv("MOZ_OS_UPDATE=1"); } -#if defined(MOZ_WIDGET_GONK) - // We want the updater to be CPU friendly and not subject to being killed by - // the low memory killer, so we pass in some preferences to allow it to - // adjust its priority. - - int32_t prioVal = Preferences::GetInt(kAppUpdaterPrio, - kAppUpdaterPrioDefault); - int32_t oomScoreAdj = Preferences::GetInt(kAppUpdaterOomScoreAdj, - kAppUpdaterOomScoreAdjDefault); - int32_t ioprioClass = Preferences::GetInt(kAppUpdaterIOPrioClass, - kAppUpdaterIOPrioClassDefault); - int32_t ioprioLevel = Preferences::GetInt(kAppUpdaterIOPrioLevel, - kAppUpdaterIOPrioLevelDefault); - nsPrintfCString prioEnv("MOZ_UPDATER_PRIO=%d/%d/%d/%d", - prioVal, oomScoreAdj, ioprioClass, ioprioLevel); - // Note: we allocate a new string on heap and pass that to PR_SetEnv, since - // the string can be used after this function returns. This means that we - // will intentionally leak this buffer. - PR_SetEnv(ToNewCString(prioEnv)); -#endif LOG(("spawning updater process [%s]\n", updaterPath.get())); @@ -1122,12 +1020,6 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate) // Check for and process any available updates bool persistent; nsresult rv = NS_ERROR_FAILURE; // Take the NS_FAILED path when non-GONK -#ifdef MOZ_WIDGET_GONK - // Check in the sdcard for updates first, since that's our preferred - // download location. - rv = dirProvider->GetFile(XRE_UPDATE_ARCHIVE_DIR, &persistent, - getter_AddRefs(updRoot)); -#endif if (NS_FAILED(rv)) { rv = dirProvider->GetFile(XRE_UPDATE_ROOT_DIR, &persistent, getter_AddRefs(updRoot)); @@ -1217,34 +1109,6 @@ nsUpdateProcessor::ProcessUpdate(nsIUpdate* aUpdate) } mInfo.mAppVersion = appVersion; -#if defined(MOZ_WIDGET_GONK) - NS_ENSURE_ARG_POINTER(aUpdate); - - bool isOSUpdate; - if (NS_SUCCEEDED(aUpdate->GetIsOSUpdate(&isOSUpdate)) && - isOSUpdate) { - nsAutoCString osApplyToDir; - - // This needs to be done on the main thread, so we pass it along in - // BackgroundThreadInfo - nsresult rv = GetOSApplyToDir(osApplyToDir); - if (NS_FAILED(rv)) { - LOG(("Can't get the OS apply to dir")); - return rv; - } - - SetOSApplyToDir(aUpdate, osApplyToDir); - - mInfo.mIsOSUpdate = true; - rv = NS_NewNativeLocalFile(osApplyToDir, false, - getter_AddRefs(mInfo.mOSApplyToDir)); - if (NS_FAILED(rv)) { - LOG(("Can't create nsIFile for OS apply to dir")); - return rv; - } - } -#endif - MOZ_ASSERT(NS_IsMainThread(), "not main thread"); nsCOMPtr r = NewRunnableMethod(this, &nsUpdateProcessor::StartStagedUpdate); return NS_NewThread(getter_AddRefs(mProcessWatcher), r); diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp index f2d0b1b0f..d904cb83a 100644 --- a/toolkit/xre/nsXREDirProvider.cpp +++ b/toolkit/xre/nsXREDirProvider.cpp @@ -1122,14 +1122,6 @@ nsresult nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult) { nsCOMPtr updRoot; -#if defined(MOZ_WIDGET_GONK) - - nsresult rv = NS_NewNativeLocalFile(nsDependentCString("/data/local"), - true, - getter_AddRefs(updRoot)); - NS_ENSURE_SUCCESS(rv, rv); - -#else nsCOMPtr appFile; bool per = false; nsresult rv = GetFile(XRE_EXECUTABLE_FILE, &per, getter_AddRefs(appFile)); @@ -1261,7 +1253,6 @@ nsXREDirProvider::GetUpdateRootDir(nsIFile* *aResult) NS_ENSURE_SUCCESS(rv, rv); #endif // XP_WIN -#endif updRoot.forget(aResult); return NS_OK; } @@ -1365,9 +1356,6 @@ nsXREDirProvider::GetUserDataDirectoryHome(nsIFile** aFile, bool aLocal) NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewLocalFile(path, true, getter_AddRefs(localDir)); -#elif defined(MOZ_WIDGET_GONK) - rv = NS_NewNativeLocalFile(NS_LITERAL_CSTRING("/data/b2g"), true, - getter_AddRefs(localDir)); #elif defined(XP_UNIX) const char* homeDir = getenv("HOME"); if (!homeDir || !*homeDir) -- cgit v1.2.3 From 94988a2b4e6bd85ee8216c65cc8cd73d14cf1ad1 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 23 May 2018 20:16:00 +0200 Subject: Remove the jprof profiler. This resolves #377. --- toolkit/xre/nsAppRunner.cpp | 14 -------------- toolkit/xre/nsEmbedFunctions.cpp | 9 --------- 2 files changed, 23 deletions(-) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 2050b9671..e43aea926 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -182,10 +182,6 @@ #include "mozilla/Logging.h" #endif -#ifdef MOZ_JPROF -#include "jprof.h" -#endif - #include "base/command_line.h" #include "GTestRunner.h" @@ -1513,11 +1509,6 @@ static nsresult LaunchChild(nsINativeAppSupport* aNative, // Restart this process by exec'ing it into the current process // if supported by the platform. Otherwise, use NSPR. -#ifdef MOZ_JPROF - // make sure JPROF doesn't think we're E10s - unsetenv("JPROF_SLAVE"); -#endif - if (aBlankCommandLine) { gRestartArgc = 1; gRestartArgv[gRestartArgc] = nullptr; @@ -3393,11 +3384,6 @@ XREMain::XRE_mainStartup(bool* aExitFlag) XRE_InstallX11ErrorHandler(); #endif - // Call the code to install our handler -#ifdef MOZ_JPROF - setupProfilingStuff(); -#endif - rv = NS_CreateNativeAppSupport(getter_AddRefs(mNativeApp)); if (NS_FAILED(rv)) return 1; diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index f62dbdd6d..1498b0d17 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -82,10 +82,6 @@ using mozilla::_ipdltest::IPDLUnitTestProcessChild; #endif // ifdef MOZ_IPDL_TESTS -#ifdef MOZ_JPROF -#include "jprof.h" -#endif - using namespace mozilla; using mozilla::ipc::BrowserProcessSubThread; @@ -250,11 +246,6 @@ XRE_InitChildProcess(int aArgc, NS_ENSURE_ARG_POINTER(aArgv[0]); MOZ_ASSERT(aChildData); -#ifdef MOZ_JPROF - // Call the code to install our handler - setupProfilingStuff(); -#endif - #if !defined(MOZ_WIDGET_ANDROID) // On non-Fennec Gecko, the GMPLoader code resides in plugin-container, // and we must forward it through to the GMP code here. -- cgit v1.2.3 From fdc6f820ca5e4b2832a0208e2a183fb1d6f8b45f Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 30 Jun 2018 18:34:19 +0200 Subject: Bug 1413868. --- toolkit/xre/nsAppRunner.cpp | 5 +++++ toolkit/xre/nsEmbedFunctions.cpp | 4 ++++ 2 files changed, 9 insertions(+) (limited to 'toolkit/xre') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index e43aea926..40f9ead79 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -9,6 +9,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Attributes.h" +#include "mozilla/FilePreferences.h" #include "mozilla/ChaosMode.h" #include "mozilla/IOInterposer.h" #include "mozilla/Likely.h" @@ -3740,6 +3741,10 @@ XREMain::XRE_mainRun() mDirProvider.DoStartup(); + // As FilePreferences need the profile directory, we must initialize right here. + mozilla::FilePreferences::InitDirectoriesWhitelist(); + mozilla::FilePreferences::InitPrefs(); + OverrideDefaultLocaleIfNeeded(); appStartup->GetShuttingDown(&mShuttingDown); diff --git a/toolkit/xre/nsEmbedFunctions.cpp b/toolkit/xre/nsEmbedFunctions.cpp index 1498b0d17..3757dec2f 100644 --- a/toolkit/xre/nsEmbedFunctions.cpp +++ b/toolkit/xre/nsEmbedFunctions.cpp @@ -52,6 +52,7 @@ #include "base/process_util.h" #include "chrome/common/child_process.h" +#include "mozilla/FilePreferences.h" #include "mozilla/ipc/BrowserProcessSubThread.h" #include "mozilla/ipc/GeckoChildProcessHost.h" #include "mozilla/ipc/IOThreadChild.h" @@ -546,6 +547,9 @@ XRE_InitChildProcess(int aArgc, ::SetProcessShutdownParameters(0x280 - 1, SHUTDOWN_NORETRY); #endif + mozilla::FilePreferences::InitDirectoriesWhitelist(); + mozilla::FilePreferences::InitPrefs(); + OverrideDefaultLocaleIfNeeded(); // Run the UI event loop on the main thread. -- cgit v1.2.3