diff -up firefox-45.0.1/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-45.0.1/extensions/pref/autoconfig/src/nsReadConfig.cpp --- firefox-45.0.1/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 2016-03-15 23:37:54.000000000 +0100 +++ firefox-45.0.1/extensions/pref/autoconfig/src/nsReadConfig.cpp 2016-03-21 16:10:42.540417899 +0100 @@ -245,8 +245,20 @@ nsresult nsReadConfig::openAndEvaluateJS return rv; rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile); - if (NS_FAILED(rv)) - return rv; + if (NS_FAILED(rv)) { + // Look for cfg file in /etc/<application>/pref + rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR, + getter_AddRefs(jsFile)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref")); + NS_ENSURE_SUCCESS(rv, rv); + rv = jsFile->AppendNative(nsDependentCString(aFileName)); + NS_ENSURE_SUCCESS(rv, rv); + + rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile); + NS_ENSURE_SUCCESS(rv, rv); + } } else { nsAutoCString location("resource://gre/defaults/autoconfig/"); diff -up firefox-45.0.1/modules/libpref/Preferences.cpp.1170092 firefox-45.0.1/modules/libpref/Preferences.cpp --- firefox-45.0.1/modules/libpref/Preferences.cpp.1170092 2016-03-21 16:10:42.540417899 +0100 +++ firefox-45.0.1/modules/libpref/Preferences.cpp 2016-03-21 16:13:29.145888710 +0100 @@ -1214,6 +1214,8 @@ static nsresult pref_InitInitialObjects( // - jar:$gre/omni.jar!/defaults/preferences/*.js // Thus, in omni.jar case, we always load app-specific default preferences // from omni.jar, whether or not $app == $gre. + // At very end load configuration from system config location: + // - /etc/firefox/pref/*.js nsZipFind *findPtr; nsAutoPtr<nsZipFind> find; diff -up firefox-45.0.1/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-45.0.1/toolkit/xre/nsXREDirProvider.cpp --- firefox-45.0.1/toolkit/xre/nsXREDirProvider.cpp.1170092 2016-03-15 23:37:46.000000000 +0100 +++ firefox-45.0.1/toolkit/xre/nsXREDirProvider.cpp 2016-03-21 16:12:06.498655156 +0100 @@ -51,6 +51,7 @@ #endif #ifdef XP_UNIX #include <ctype.h> +#include "nsIXULAppInfo.h" #endif #ifdef XP_IOS #include "UIKitDirProvider.h" @@ -457,6 +458,20 @@ nsXREDirProvider::GetFile(const char* aP } } } +#if defined(XP_UNIX) + if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) { + nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/"); + nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1"); + if (!appInfo) + return NS_ERROR_NOT_AVAILABLE; + nsCString appName; + appInfo->GetName(appName); + ToLowerCase(appName); + sysConfigDir.Append(appName); + return NS_NewNativeLocalFile(sysConfigDir, false, aFile); + } +#endif + if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE; @@ -753,6 +768,14 @@ nsXREDirProvider::GetFilesInternal(const LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories); LoadDirsIntoArray(mAppBundleDirectories, kAppendPrefDir, directories); + // Add /etc/<application>/pref/ directory if it exists + nsCOMPtr<nsIFile> systemPrefDir; + rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR, getter_AddRefs(systemPrefDir)); + if (NS_SUCCEEDED(rv)) { + rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref")); + if (NS_SUCCEEDED(rv)) + directories.AppendObject(systemPrefDir); + } rv = NS_NewArrayEnumerator(aResult, directories); } diff -up firefox-45.0.1/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-45.0.1/xpcom/io/nsAppDirectoryServiceDefs.h --- firefox-45.0.1/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 2016-03-15 23:37:47.000000000 +0100 +++ firefox-45.0.1/xpcom/io/nsAppDirectoryServiceDefs.h 2016-03-21 16:10:42.541417902 +0100 @@ -67,6 +67,7 @@ #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL" #define NS_EXT_PREFS_DEFAULTS_DIR_LIST "ExtPrefDL" #define NS_APP_PREFS_OVERRIDE_DIR "PrefDOverride" // Directory for per-profile defaults +#define NS_APP_PREFS_SYSTEM_CONFIG_DIR "PrefSysConf" // Directory with system-wide configuration #define NS_APP_USER_PROFILE_50_DIR "ProfD" #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"