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