Blame SOURCES/mozilla-1170092.patch

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