f838c9
diff -up firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
f838c9
--- firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2021-03-18 14:48:36.000000000 +0100
f838c9
+++ firefox-87.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2021-03-22 19:20:02.429310184 +0100
225ef2
@@ -249,8 +249,20 @@ nsresult nsReadConfig::openAndEvaluateJS
225ef2
     if (NS_FAILED(rv)) return rv;
225ef2
 
225ef2
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
225ef2
-    if (NS_FAILED(rv)) return rv;
225ef2
+    if (NS_FAILED(rv)) {
225ef2
+      // Look for cfg file in /etc/<application>/pref
225ef2
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
225ef2
+                                  getter_AddRefs(jsFile));
225ef2
+      NS_ENSURE_SUCCESS(rv, rv);
225ef2
+
225ef2
+      rv = jsFile->AppendNative(nsLiteralCString("pref"));
225ef2
+      NS_ENSURE_SUCCESS(rv, rv);
225ef2
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
225ef2
+      NS_ENSURE_SUCCESS(rv, rv);
225ef2
 
225ef2
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
225ef2
+      NS_ENSURE_SUCCESS(rv, rv);
225ef2
+    }
225ef2
   } else {
225ef2
     nsAutoCString location("resource://gre/defaults/autoconfig/");
225ef2
     location += aFileName;
f838c9
diff -up firefox-87.0/modules/libpref/Preferences.cpp.1170092 firefox-87.0/modules/libpref/Preferences.cpp
f838c9
--- firefox-87.0/modules/libpref/Preferences.cpp.1170092	2021-03-18 14:48:54.000000000 +0100
f838c9
+++ firefox-87.0/modules/libpref/Preferences.cpp	2021-03-22 19:20:02.429310184 +0100
f838c9
@@ -4499,6 +4499,9 @@ nsresult Preferences::InitInitialObjects
225ef2
   //
225ef2
   // Thus, in the omni.jar case, we always load app-specific default
225ef2
   // preferences from omni.jar, whether or not `$app == $gre`.
f838c9
+  //
225ef2
+  // At very end load configuration from system config location:
225ef2
+  // - /etc/firefox/pref/*.js
225ef2
 
225ef2
   nsresult rv = NS_ERROR_FAILURE;
225ef2
   UniquePtr<nsZipFind> find;
f838c9
diff -up firefox-87.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-87.0/toolkit/xre/nsXREDirProvider.cpp
f838c9
--- firefox-87.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2021-03-18 14:52:00.000000000 +0100
f838c9
+++ firefox-87.0/toolkit/xre/nsXREDirProvider.cpp	2021-03-22 19:37:56.574480347 +0100
f838c9
@@ -65,6 +65,7 @@
225ef2
 #endif
225ef2
 #ifdef XP_UNIX
225ef2
 #  include <ctype.h>
225ef2
+#  include "nsIXULAppInfo.h"
225ef2
 #endif
225ef2
 #ifdef XP_IOS
225ef2
 #  include "UIKitDirProvider.h"
f838c9
@@ -552,6 +553,21 @@ nsXREDirProvider::GetFile(const char* aP
225ef2
       }
225ef2
     }
225ef2
   }
225ef2
+
225ef2
+#if defined(XP_UNIX)
225ef2
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
225ef2
+    nsCString sysConfigDir = nsLiteralCString("/etc/");
225ef2
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
225ef2
+    if (!appInfo)
225ef2
+      return NS_ERROR_NOT_AVAILABLE;
225ef2
+    nsCString appName;
225ef2
+    appInfo->GetName(appName);
225ef2
+    ToLowerCase(appName);
225ef2
+    sysConfigDir.Append(appName);
225ef2
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
225ef2
+  }
225ef2
+#endif
225ef2
+
225ef2
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
225ef2
 
225ef2
   if (ensureFilePermissions) {
f838c9
@@ -874,6 +890,16 @@ nsresult nsXREDirProvider::GetFilesInter
225ef2
     }
225ef2
 #endif
f838c9
 
225ef2
+    // Add /etc/<application>/pref/ directory if it exists
225ef2
+    nsCOMPtr<nsIFile> systemPrefDir;
225ef2
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
225ef2
+                                getter_AddRefs(systemPrefDir));
225ef2
+    if (NS_SUCCEEDED(rv)) {
225ef2
+      rv = systemPrefDir->AppendNative(nsLiteralCString("pref"));
f838c9
+      if (NS_SUCCEEDED(rv))
225ef2
+        directories.AppendObject(systemPrefDir);
225ef2
+      }
f838c9
+
225ef2
     rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
225ef2
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
f838c9
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
f838c9
diff -up firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h
f838c9
--- firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2021-03-18 14:51:58.000000000 +0100
f838c9
+++ firefox-87.0/xpcom/io/nsAppDirectoryServiceDefs.h	2021-03-22 19:20:02.430310213 +0100
225ef2
@@ -59,6 +59,7 @@
225ef2
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
225ef2
 #define NS_APP_PREFS_OVERRIDE_DIR \
225ef2
   "PrefDOverride"  // Directory for per-profile defaults
225ef2
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
225ef2
 
225ef2
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
225ef2
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"