71c2a1
diff -up firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
71c2a1
--- firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2019-01-22 10:48:38.187383614 +0100
71c2a1
+++ firefox-60.5.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2019-01-22 11:26:11.027108692 +0100
71c2a1
@@ -225,8 +225,20 @@ nsresult nsReadConfig::openAndEvaluateJS
71c2a1
     if (NS_FAILED(rv)) return rv;
71c2a1
 
71c2a1
     rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
71c2a1
-    if (NS_FAILED(rv)) return rv;
71c2a1
+    if (NS_FAILED(rv)) {
71c2a1
+      // Look for cfg file in /etc/<application>/pref
71c2a1
+      rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
71c2a1
+                                  getter_AddRefs(jsFile));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+
71c2a1
+      rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+      rv = jsFile->AppendNative(nsDependentCString(aFileName));
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
 
71c2a1
+      rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
71c2a1
+      NS_ENSURE_SUCCESS(rv, rv);
71c2a1
+    }
71c2a1
   } else {
71c2a1
     nsAutoCString location("resource://gre/defaults/autoconfig/");
71c2a1
     location += aFileName;
71c2a1
diff -up firefox-60.5.0/modules/libpref/Preferences.cpp.1170092 firefox-60.5.0/modules/libpref/Preferences.cpp
71c2a1
--- firefox-60.5.0/modules/libpref/Preferences.cpp.1170092	2019-01-21 17:38:16.000000000 +0100
71c2a1
+++ firefox-60.5.0/modules/libpref/Preferences.cpp	2019-01-22 10:48:38.187383614 +0100
71c2a1
@@ -3459,6 +3459,8 @@ static nsresult pref_ReadPrefFromJar(nsZ
71c2a1
   //
71c2a1
   // Thus, in the omni.jar case, we always load app-specific default
71c2a1
   // preferences from omni.jar, whether or not `$app == $gre`.
71c2a1
+  // At very end load configuration from system config location:
71c2a1
+  // - /etc/firefox/pref/*.js
71c2a1
 
71c2a1
   nsresult rv;
71c2a1
   nsZipFind* findPtr;
71c2a1
diff -up firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp
71c2a1
--- firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2019-01-21 17:38:51.000000000 +0100
71c2a1
+++ firefox-60.5.0/toolkit/xre/nsXREDirProvider.cpp	2019-01-22 11:37:01.868896974 +0100
71c2a1
@@ -58,6 +58,7 @@
71c2a1
 #endif
71c2a1
 #ifdef XP_UNIX
71c2a1
 #include <ctype.h>
71c2a1
+#include "nsIXULAppInfo.h"
71c2a1
 #endif
71c2a1
 #ifdef XP_IOS
71c2a1
 #include "UIKitDirProvider.h"
71c2a1
@@ -491,6 +492,21 @@ nsXREDirProvider::GetFile(const char* aP
71c2a1
       }
71c2a1
     }
71c2a1
   }
71c2a1
+
71c2a1
+#if defined(XP_UNIX)
71c2a1
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
71c2a1
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
71c2a1
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
71c2a1
+    if (!appInfo)
71c2a1
+      return NS_ERROR_NOT_AVAILABLE;
71c2a1
+    nsCString appName;
71c2a1
+    appInfo->GetName(appName);
71c2a1
+    ToLowerCase(appName);
71c2a1
+    sysConfigDir.Append(appName);
71c2a1
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
71c2a1
+  }
71c2a1
+#endif
71c2a1
+
71c2a1
   if (NS_FAILED(rv) || !file) return NS_ERROR_FAILURE;
71c2a1
 
71c2a1
   if (ensureFilePermissions) {
71c2a1
@@ -796,6 +812,16 @@ nsresult nsXREDirProvider::GetFilesInter
71c2a1
     LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories);
71c2a1
     LoadDirsIntoArray(mAppBundleDirectories, kAppendPrefDir, directories);
71c2a1
 
71c2a1
+    // Add /etc/<application>/pref/ directory if it exists
71c2a1
+    nsCOMPtr<nsIFile> systemPrefDir;
71c2a1
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
71c2a1
+                                getter_AddRefs(systemPrefDir));
71c2a1
+    if (NS_SUCCEEDED(rv)) {
71c2a1
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
71c2a1
+      if (NS_SUCCEEDED(rv))
71c2a1
+        directories.AppendObject(systemPrefDir);
71c2a1
+    }
71c2a1
+
71c2a1
     rv = NS_NewArrayEnumerator(aResult, directories);
71c2a1
   } else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
71c2a1
     // NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
71c2a1
diff -up firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h
71c2a1
--- firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2019-01-22 10:48:38.188383609 +0100
71c2a1
+++ firefox-60.5.0/xpcom/io/nsAppDirectoryServiceDefs.h	2019-01-22 11:08:12.068459480 +0100
71c2a1
@@ -62,6 +62,7 @@
71c2a1
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL"
71c2a1
 #define NS_APP_PREFS_OVERRIDE_DIR \
71c2a1
   "PrefDOverride"  // Directory for per-profile defaults
71c2a1
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
71c2a1
 
71c2a1
 #define NS_APP_USER_PROFILE_50_DIR "ProfD"
71c2a1
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR "ProfLD"