cd486f
diff -up firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
cd486f
--- firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2019-01-22 10:48:38.187383614 +0100
cd486f
+++ firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2019-01-22 11:26:11.027108692 +0100
cd486f
@@ -225,8 +225,20 @@ nsresult nsReadConfig::openAndEvaluateJS
cd486f
     if (NS_FAILED(rv)) return rv;
cd486f
 
cd486f
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
cd486f
-    if (NS_FAILED(rv)) return rv;
cd486f
+    if (NS_FAILED(rv)) {
cd486f
+      // Look for cfg file in /etc/<application>/pref
cd486f
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
cd486f
+                                  getter_AddRefs(jsFile));
cd486f
+      NS_ENSURE_SUCCESS(rv, rv);
cd486f
+
cd486f
+      rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
cd486f
+      NS_ENSURE_SUCCESS(rv, rv);
cd486f
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
cd486f
+      NS_ENSURE_SUCCESS(rv, rv);
cd486f
 
cd486f
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
cd486f
+      NS_ENSURE_SUCCESS(rv, rv);
cd486f
+    }
cd486f
   } else {
cd486f
     nsAutoCString location("resource://gre/defaults/autoconfig/");
cd486f
     location += aFileName;
cd486f
diff -up firefox-60.5.0/modules/libpref/Preferences.cpp.1170092 firefox-60.5.0/modules/libpref/Preferences.cpp
cd486f
--- firefox-60.5.0/modules/libpref/Preferences.cpp.1170092	2019-01-21 17:38:16.000000000 +0100
cd486f
+++ firefox-60.5.0/modules/libpref/Preferences.cpp	2019-01-22 10:48:38.187383614 +0100
cd486f
@@ -3459,6 +3459,8 @@ static nsresult pref_ReadPrefFromJar(nsZ
cd486f
   //
cd486f
   // Thus, in the omni.jar case, we always load app-specific default
cd486f
   // preferences from omni.jar, whether or not `$app == $gre`.
cd486f
+  // At very end load configuration from system config location:
cd486f
+  // - /etc/firefox/pref/*.js
cd486f
 
cd486f
   nsresult rv;
cd486f
   nsZipFind* findPtr;
cd486f
diff -up firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp
cd486f
--- firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2019-01-21 17:38:51.000000000 +0100
cd486f
+++ firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp	2019-01-22 11:37:01.868896974 +0100
cd486f
@@ -58,6 +58,7 @@
cd486f
 #endif
cd486f
 #ifdef XP_UNIX
cd486f
 #include <ctype.h>
cd486f
+#include "nsIXULAppInfo.h"
cd486f
 #endif
cd486f
 #ifdef XP_IOS
cd486f
 #include "UIKitDirProvider.h"
cd486f
@@ -491,6 +492,21 @@ nsXREDirProvider::GetFile(const char* aP
cd486f
       }
cd486f
     }
cd486f
   }
cd486f
+
cd486f
+#if defined(XP_UNIX)
cd486f
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
cd486f
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
cd486f
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
cd486f
+    if (!appInfo)
cd486f
+      return NS_ERROR_NOT_AVAILABLE;
cd486f
+    nsCString appName;
cd486f
+    appInfo->GetName(appName);
cd486f
+    ToLowerCase(appName);
cd486f
+    sysConfigDir.Append(appName);
cd486f
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
cd486f
+  }
cd486f
+#endif
cd486f
+
cd486f
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
cd486f
 
cd486f
   if (ensureFilePermissions) {
cd486f
@@ -796,6 +812,16 @@ nsresult nsXREDirProvider::GetFilesInter
cd486f
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
cd486f
     LoadDirsIntoArray(mAppBundleDirectories, kAppendPrefDir, directories);
cd486f
 
cd486f
+    // Add /etc/<application>/pref/ directory if it exists
cd486f
+    nsCOMPtr<nsIFile> systemPrefDir;
cd486f
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
cd486f
+                                getter_AddRefs(systemPrefDir));
cd486f
+    if (NS_SUCCEEDED(rv)) {
cd486f
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
cd486f
+      if (NS_SUCCEEDED(rv))
cd486f
+        directories.AppendObject(systemPrefDir);
cd486f
+    }
cd486f
+
cd486f
     rv = NS_NewArrayEnumerator(aResult, directories);
cd486f
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
cd486f
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
cd486f
diff -up firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h
cd486f
--- firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2019-01-22 10:48:38.188383609 +0100
cd486f
+++ firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h	2019-01-22 11:08:12.068459480 +0100
cd486f
@@ -62,6 +62,7 @@
cd486f
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
cd486f
 #define NS_APP_PREFS_OVERRIDE_DIR \
cd486f
   "PrefDOverride"  // Directory for per-profile defaults
cd486f
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
cd486f
 
cd486f
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
cd486f
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"