7cc1fe
diff -up firefox-78.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-78.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
7cc1fe
--- firefox-78.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2020-06-17 04:18:58.000000000 +0200
7cc1fe
+++ firefox-78.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2020-06-25 13:45:28.816999491 +0200
7cc1fe
@@ -244,8 +244,20 @@ nsresult nsReadConfig::openAndEvaluateJS
f9adc4
     if (NS_FAILED(rv)) return rv;
f9adc4
 
f9adc4
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
f9adc4
-    if (NS_FAILED(rv)) return rv;
f9adc4
+    if (NS_FAILED(rv)) {
f9adc4
+      // Look for cfg file in /etc/<application>/pref
f9adc4
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
f9adc4
+                                  getter_AddRefs(jsFile));
f9adc4
+      NS_ENSURE_SUCCESS(rv, rv);
f9adc4
+
f9adc4
+      rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
f9adc4
+      NS_ENSURE_SUCCESS(rv, rv);
f9adc4
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
f9adc4
+      NS_ENSURE_SUCCESS(rv, rv);
f9adc4
 
f9adc4
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
f9adc4
+      NS_ENSURE_SUCCESS(rv, rv);
f9adc4
+    }
f9adc4
   } else {
f9adc4
     nsAutoCString location("resource://gre/defaults/autoconfig/");
f9adc4
     location += aFileName;
7cc1fe
diff -up firefox-78.0/modules/libpref/Preferences.cpp.1170092 firefox-78.0/modules/libpref/Preferences.cpp
7cc1fe
--- firefox-78.0/modules/libpref/Preferences.cpp.1170092	2020-06-25 13:45:28.818999498 +0200
7cc1fe
+++ firefox-78.0/modules/libpref/Preferences.cpp	2020-06-25 13:48:45.996708102 +0200
7cc1fe
@@ -4499,6 +4499,8 @@ nsresult Preferences::InitInitialObjects
f9adc4
   //
f9adc4
   // Thus, in the omni.jar case, we always load app-specific default
f9adc4
   // preferences from omni.jar, whether or not `$app == $gre`.
f9adc4
+  // At very end load configuration from system config location:
f9adc4
+  // - /etc/firefox/pref/*.js
f9adc4
 
f9adc4
   nsresult rv = NS_ERROR_FAILURE;
7cc1fe
   UniquePtr<nsZipFind> find;
7cc1fe
diff -up firefox-78.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-78.0/toolkit/xre/nsXREDirProvider.cpp
7cc1fe
--- firefox-78.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2020-06-17 04:20:11.000000000 +0200
7cc1fe
+++ firefox-78.0/toolkit/xre/nsXREDirProvider.cpp	2020-06-25 13:48:28.613645633 +0200
7cc1fe
@@ -60,6 +60,7 @@
f9adc4
 #endif
f9adc4
 #ifdef XP_UNIX
f9adc4
 #  include <ctype.h>
f9adc4
+#  include "nsIXULAppInfo.h"
f9adc4
 #endif
f9adc4
 #ifdef XP_IOS
f9adc4
 #  include "UIKitDirProvider.h"
7cc1fe
@@ -533,6 +534,21 @@ nsXREDirProvider::GetFile(const char* aP
f9adc4
       }
f9adc4
     }
f9adc4
   }
f9adc4
+
f9adc4
+#if defined(XP_UNIX)
f9adc4
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
f9adc4
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
f9adc4
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
f9adc4
+    if (!appInfo)
f9adc4
+      return NS_ERROR_NOT_AVAILABLE;
f9adc4
+    nsCString appName;
f9adc4
+    appInfo->GetName(appName);
f9adc4
+    ToLowerCase(appName);
f9adc4
+    sysConfigDir.Append(appName);
f9adc4
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
f9adc4
+  }
f9adc4
+#endif
f9adc4
+
f9adc4
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
f9adc4
 
f9adc4
   if (ensureFilePermissions) {
7cc1fe
@@ -845,6 +861,17 @@ nsresult nsXREDirProvider::GetFilesInter
f9adc4
 
f9adc4
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
f9adc4
 
f9adc4
+    // Add /etc/<application>/pref/ directory if it exists
f9adc4
+    nsCOMPtr<nsIFile> systemPrefDir;
f9adc4
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
f9adc4
+                                getter_AddRefs(systemPrefDir));
f9adc4
+    if (NS_SUCCEEDED(rv)) {
f9adc4
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
7cc1fe
+      if (NS_SUCCEEDED(rv)) {
f9adc4
+        directories.AppendObject(systemPrefDir);
7cc1fe
+      }
f9adc4
+    }
f9adc4
+
f9adc4
     rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
f9adc4
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
f9adc4
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
7cc1fe
diff -up firefox-78.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-78.0/xpcom/io/nsAppDirectoryServiceDefs.h
7cc1fe
--- firefox-78.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2020-06-17 04:20:17.000000000 +0200
7cc1fe
+++ firefox-78.0/xpcom/io/nsAppDirectoryServiceDefs.h	2020-06-25 13:45:28.819999502 +0200
f9adc4
@@ -60,6 +60,7 @@
f9adc4
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
f9adc4
 #define NS_APP_PREFS_OVERRIDE_DIR \
f9adc4
   "PrefDOverride"  // Directory for per-profile defaults
f9adc4
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
f9adc4
 
f9adc4
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
f9adc4
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"