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