summaryrefslogtreecommitdiff
path: root/mozilla-1170092.patch
blob: 8a9e86f1f7a57fa5c8a59af5250b68394466afd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
diff -up firefox-63.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-63.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
--- firefox-63.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092	2018-10-15 21:20:45.000000000 +0200
+++ firefox-63.0/extensions/pref/autoconfig/src/nsReadConfig.cpp	2018-10-18 13:37:55.993001292 +0200
@@ -265,9 +265,20 @@ nsresult nsReadConfig::openAndEvaluateJS
             return rv;
 
         rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
-        if (NS_FAILED(rv))
-            return rv;
+        if (NS_FAILED(rv)) {
+          // Look for cfg file in /etc/<application>/pref
+          rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR,
+                                      getter_AddRefs(jsFile));
+          NS_ENSURE_SUCCESS(rv, rv);
+
+          rv = jsFile->AppendNative(NS_LITERAL_CSTRING("pref"));
+          NS_ENSURE_SUCCESS(rv, rv);
+          rv = jsFile->AppendNative(nsDependentCString(aFileName));
+          NS_ENSURE_SUCCESS(rv, rv);
 
+          rv = NS_NewLocalFileInputStream(getter_AddRefs(inStr), jsFile);
+          NS_ENSURE_SUCCESS(rv, rv);
+        }
     } else {
         nsAutoCString location("resource://gre/defaults/autoconfig/");
         location += aFileName;
diff -up firefox-63.0/modules/libpref/Preferences.cpp.1170092 firefox-63.0/modules/libpref/Preferences.cpp
--- firefox-63.0/modules/libpref/Preferences.cpp.1170092	2018-10-15 21:20:49.000000000 +0200
+++ firefox-63.0/modules/libpref/Preferences.cpp	2018-10-18 13:37:55.994001285 +0200
@@ -4873,6 +4873,8 @@ Preferences::InitInitialObjects(bool aIs
   //
   // Thus, in the omni.jar case, we always load app-specific default
   // preferences from omni.jar, whether or not `$app == $gre`.
+  // At very end load configuration from system config location:
+  // - /etc/firefox/pref/*.js
 
   nsresult rv;
   nsZipFind* findPtr;
diff -up firefox-63.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-63.0/toolkit/xre/nsXREDirProvider.cpp
--- firefox-63.0/toolkit/xre/nsXREDirProvider.cpp.1170092	2018-10-15 21:20:52.000000000 +0200
+++ firefox-63.0/toolkit/xre/nsXREDirProvider.cpp	2018-10-18 13:41:06.969581700 +0200
@@ -57,6 +57,7 @@
 #endif
 #ifdef XP_UNIX
 #include <ctype.h>
+#include "nsIXULAppInfo.h"
 #endif
 #ifdef XP_IOS
 #include "UIKitDirProvider.h"
@@ -527,6 +528,20 @@ nsXREDirProvider::GetFile(const char* aP
       }
     }
   }
+#if defined(XP_UNIX)
+  if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
+    nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/");
+    nsCOMPtr<nsIXULAppInfo> appInfo = do_GetService("@mozilla.org/xre/app-info;1");
+    if (!appInfo)
+      return NS_ERROR_NOT_AVAILABLE;
+    nsCString appName;
+    appInfo->GetName(appName);
+    ToLowerCase(appName);
+    sysConfigDir.Append(appName);
+    return NS_NewNativeLocalFile(sysConfigDir, false, aFile);
+  }
+#endif
+
   if (NS_FAILED(rv) || !file)
     return NS_ERROR_FAILURE;
 
@@ -863,6 +878,15 @@ nsXREDirProvider::GetFilesInternal(const
     LoadDirsIntoArray(mAppBundleDirectories,
                       kAppendPrefDir, directories);
 
+    // Add /etc/<application>/pref/ directory if it exists
+    nsCOMPtr<nsIFile> systemPrefDir;
+    rv = NS_GetSpecialDirectory(NS_APP_PREFS_SYSTEM_CONFIG_DIR, getter_AddRefs(systemPrefDir));
+    if (NS_SUCCEEDED(rv)) {
+      rv = systemPrefDir->AppendNative(NS_LITERAL_CSTRING("pref"));
+      if (NS_SUCCEEDED(rv))
+        directories.AppendObject(systemPrefDir); 
+    }
+
     rv = NS_NewArrayEnumerator(aResult, directories, NS_GET_IID(nsIFile));
   }
   else if (!strcmp(aProperty, NS_APP_CHROME_DIR_LIST)) {
diff -up firefox-63.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-63.0/xpcom/io/nsAppDirectoryServiceDefs.h
--- firefox-63.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092	2018-10-15 21:20:52.000000000 +0200
+++ firefox-63.0/xpcom/io/nsAppDirectoryServiceDefs.h	2018-10-18 13:37:55.994001285 +0200
@@ -59,6 +59,7 @@
 #define NS_APP_PREFS_50_FILE                    "PrefF"
 #define NS_APP_PREFS_DEFAULTS_DIR_LIST          "PrefDL"
 #define NS_APP_PREFS_OVERRIDE_DIR               "PrefDOverride" // Directory for per-profile defaults
+#define NS_APP_PREFS_SYSTEM_CONFIG_DIR          "PrefSysConf"   // Directory with system-wide configuration
 
 #define NS_APP_USER_PROFILE_50_DIR              "ProfD"
 #define NS_APP_USER_PROFILE_LOCAL_50_DIR        "ProfLD"
bgstack15