e23d9e
diff -up firefox-71.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-71.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
e23d9e
--- firefox-71.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2019-11-26 01:02:21.000000000 +0100
e23d9e
+++ firefox-71.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2019-11-26 10:47:04.316154398 +0100
3fe7b7
@@ -246,8 +246,20 @@ nsresult nsReadConfig::openAndEvaluateJS
10afcc
     if (NS_FAILED(rv)) return rv;
10afcc
 
10afcc
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
10afcc
-    if (NS_FAILED(rv)) return rv;
10afcc
+    if (NS_FAILED(rv)) {
10afcc
+      // Look for cfg file in /etc/<application>/pref
10afcc
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
10afcc
+                                  getter_AddRefs(jsFile));
10afcc
+      NS_ENSURE_SUCCESS(rv, rv);
10afcc
+
10afcc
+      rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
10afcc
+      NS_ENSURE_SUCCESS(rv, rv);
10afcc
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
10afcc
+      NS_ENSURE_SUCCESS(rv, rv);
10afcc
 
10afcc
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
10afcc
+      NS_ENSURE_SUCCESS(rv, rv);
10afcc
+    }
10afcc
   } else {
10afcc
     nsAutoCString location("resource://gre/defaults/autoconfig/");
10afcc
     location += aFileName;
e23d9e
diff -up firefox-71.0/modules/libpref/Preferences.cpp.1170092 firefox-71.0/modules/libpref/Preferences.cpp
e23d9e
--- firefox-71.0/modules/libpref/Preferences.cpp.1170092	2019-11-26 01:02:25.000000000 +0100
e23d9e
+++ firefox-71.0/modules/libpref/Preferences.cpp	2019-11-26 10:47:04.316154398 +0100
e23d9e
@@ -4472,6 +4472,9 @@ nsresult Preferences::InitInitialObjects
10afcc
   //
10afcc
   // Thus, in the omni.jar case, we always load app-specific default
10afcc
   // preferences from omni.jar, whether or not `$app == $gre`.
e23d9e
+  //
10afcc
+  // At very end load configuration from system config location:
10afcc
+  // - /etc/firefox/pref/*.js
10afcc
 
3fe7b7
   nsresult rv = NS_ERROR_FAILURE;
10afcc
   nsZipFind* findPtr;
e23d9e
diff -up firefox-71.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-71.0/toolkit/xre/nsXREDirProvider.cpp
e23d9e
--- firefox-71.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2019-11-26 01:02:29.000000000 +0100
e23d9e
+++ firefox-71.0/toolkit/xre/nsXREDirProvider.cpp	2019-11-26 10:49:40.076095714 +0100
e23d9e
@@ -61,6 +61,7 @@
e23d9e
 #endif
e23d9e
 #ifdef XP_UNIX
e23d9e
 #  include <ctype.h>
e23d9e
+#  include "nsIXULAppInfo.h"
e23d9e
 #endif
e23d9e
 #ifdef XP_IOS
e23d9e
 #  include "UIKitDirProvider.h"
e23d9e
@@ -526,6 +527,21 @@ nsXREDirProvider::GetFile(const char* aP
10afcc
       }
10afcc
     }
10afcc
   }
10afcc
+
10afcc
+#if defined(XP_UNIX)
10afcc
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
10afcc
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
10afcc
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
10afcc
+    if (!appInfo)
10afcc
+      return NS_ERROR_NOT_AVAILABLE;
10afcc
+    nsCString appName;
10afcc
+    appInfo->GetName(appName);
10afcc
+    ToLowerCase(appName);
10afcc
+    sysConfigDir.Append(appName);
10afcc
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
10afcc
+  }
10afcc
+#endif
10afcc
+
10afcc
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
10afcc
 
10afcc
   if (ensureFilePermissions) {
e23d9e
@@ -842,6 +858,16 @@ nsresult nsXREDirProvider::GetFilesInter
e23d9e
 
10afcc
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
10afcc
 
10afcc
+    // Add /etc/<application>/pref/ directory if it exists
10afcc
+    nsCOMPtr<nsIFile> systemPrefDir;
10afcc
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
10afcc
+                                getter_AddRefs(systemPrefDir));
10afcc
+    if (NS_SUCCEEDED(rv)) {
10afcc
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
10afcc
+      if (NS_SUCCEEDED(rv))
10afcc
+        directories.AppendObject(systemPrefDir);
10afcc
+    }
10afcc
+
3fe7b7
     rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
10afcc
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
10afcc
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
e23d9e
diff -up firefox-71.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-71.0/xpcom/io/nsAppDirectoryServiceDefs.h
e23d9e
--- firefox-71.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2019-11-26 01:02:30.000000000 +0100
e23d9e
+++ firefox-71.0/xpcom/io/nsAppDirectoryServiceDefs.h	2019-11-26 10:47:04.317154398 +0100
e23d9e
@@ -60,6 +60,7 @@
10afcc
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
10afcc
 #define NS_APP_PREFS_OVERRIDE_DIR \
10afcc
   "PrefDOverride"  // Directory for per-profile defaults
10afcc
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
10afcc
 
10afcc
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
10afcc
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"