d445b2
diff -up firefox-68.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-68.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
d445b2
--- firefox-68.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2020-02-07 01:27:03.000000000 +0100
d445b2
+++ firefox-68.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2020-02-24 11:30:32.058044651 +0100
d445b2
@@ -246,8 +246,20 @@ nsresult nsReadConfig::openAndEvaluateJS
71c2a1
     if (NS_FAILED(rv)) return rv;
71c2a1
 
71c2a1
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
71c2a1
-    if (NS_FAILED(rv)) return rv;
71c2a1
+    if (NS_FAILED(rv)) {
71c2a1
+      // Look for cfg file in /etc/<application>/pref
71c2a1
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
71c2a1
+                                  getter_AddRefs(jsFile));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+
71c2a1
+      rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
 
71c2a1
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+    }
71c2a1
   } else {
71c2a1
     nsAutoCString location("resource://gre/defaults/autoconfig/");
71c2a1
     location += aFileName;
d445b2
diff -up firefox-68.5.0/modules/libpref/Preferences.cpp.1170092 firefox-68.5.0/modules/libpref/Preferences.cpp
d445b2
--- firefox-68.5.0/modules/libpref/Preferences.cpp.1170092	2020-02-24 11:30:32.059044645 +0100
d445b2
+++ firefox-68.5.0/modules/libpref/Preferences.cpp	2020-02-24 11:35:14.613443673 +0100
d445b2
@@ -4436,6 +4436,8 @@ static nsresult pref_ReadDefaultPrefs(co
71c2a1
   //
71c2a1
   // Thus, in the omni.jar case, we always load app-specific default
71c2a1
   // preferences from omni.jar, whether or not `$app == $gre`.
71c2a1
+  // At very end load configuration from system config location:
71c2a1
+  // - /etc/firefox/pref/*.js
71c2a1
 
d445b2
   nsresult rv = NS_ERROR_FAILURE;
71c2a1
   nsZipFind* findPtr;
d445b2
diff -up firefox-68.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-68.5.0/toolkit/xre/nsXREDirProvider.cpp
d445b2
--- firefox-68.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2020-02-07 01:28:06.000000000 +0100
d445b2
+++ firefox-68.5.0/toolkit/xre/nsXREDirProvider.cpp	2020-02-24 11:34:27.284704700 +0100
d445b2
@@ -61,6 +61,7 @@
71c2a1
 #endif
71c2a1
 #ifdef XP_UNIX
d445b2
 #  include <ctype.h>
d445b2
+#  include "nsIXULAppInfo.h"
71c2a1
 #endif
71c2a1
 #ifdef XP_IOS
d445b2
 #  include "UIKitDirProvider.h"
d445b2
@@ -524,6 +525,21 @@ nsXREDirProvider::GetFile(const char* aP
71c2a1
       }
71c2a1
     }
71c2a1
   }
71c2a1
+
71c2a1
+#if defined(XP_UNIX)
71c2a1
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
71c2a1
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
71c2a1
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
71c2a1
+    if (!appInfo)
71c2a1
+      return NS_ERROR_NOT_AVAILABLE;
71c2a1
+    nsCString appName;
71c2a1
+    appInfo->GetName(appName);
71c2a1
+    ToLowerCase(appName);
71c2a1
+    sysConfigDir.Append(appName);
71c2a1
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
71c2a1
+  }
71c2a1
+#endif
71c2a1
+
71c2a1
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
71c2a1
 
71c2a1
   if (ensureFilePermissions) {
d445b2
@@ -880,6 +896,17 @@ nsresult nsXREDirProvider::GetFilesInter
71c2a1
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
71c2a1
     LoadDirsIntoArray(mAppBundleDirectories, kAppendPrefDir, directories);
71c2a1
 
71c2a1
+    // Add /etc/<application>/pref/ directory if it exists
71c2a1
+    nsCOMPtr<nsIFile> systemPrefDir;
71c2a1
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
71c2a1
+                                getter_AddRefs(systemPrefDir));
71c2a1
+    if (NS_SUCCEEDED(rv)) {
71c2a1
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
d445b2
+      if (NS_SUCCEEDED(rv)) {
71c2a1
+        directories.AppendObject(systemPrefDir);
d445b2
+      }
71c2a1
+    }
71c2a1
+
d445b2
     rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
71c2a1
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
71c2a1
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
d445b2
diff -up firefox-68.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-68.5.0/xpcom/io/nsAppDirectoryServiceDefs.h
d445b2
--- firefox-68.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2020-02-07 01:27:52.000000000 +0100
d445b2
+++ firefox-68.5.0/xpcom/io/nsAppDirectoryServiceDefs.h	2020-02-24 11:30:32.059044645 +0100
71c2a1
@@ -62,6 +62,7 @@
71c2a1
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
71c2a1
 #define NS_APP_PREFS_OVERRIDE_DIR \
71c2a1
   "PrefDOverride"  // Directory for per-profile defaults
71c2a1
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
71c2a1
 
71c2a1
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
71c2a1
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"