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