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