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