From a07515e07547ba9b67d3018cea155753f8068338 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Mon, 30 Sep 2019 10:04:35 +0200 Subject: Updated rhbz#1754460/mzbz#1583466 - per user policy dir. --- firefox-redhat-default-prefs.js | 2 + firefox.spec | 9 ++- mozilla-1583466.patch | 156 ++++++++++++++++++++++++++++++++++++++++ rhbz-1754460.patch | 127 -------------------------------- 4 files changed, 164 insertions(+), 130 deletions(-) create mode 100644 mozilla-1583466.patch delete mode 100644 rhbz-1754460.patch diff --git a/firefox-redhat-default-prefs.js b/firefox-redhat-default-prefs.js index 8faf36c..5a93fde 100644 --- a/firefox-redhat-default-prefs.js +++ b/firefox-redhat-default-prefs.js @@ -32,3 +32,5 @@ pref("network.negotiate-auth.trusted-uris", "https://"); pref("spellchecker.dictionary_path","/usr/share/myspell"); /* Disable DoH by default */ pref("network.trr.mode", 5); +/* Enable per-user policy dir, see mozbz#1583466 */ +pref("browser.policies.perUserDir", true); \ No newline at end of file diff --git a/firefox.spec b/firefox.spec index b7d4337..0c7bb7f 100644 --- a/firefox.spec +++ b/firefox.spec @@ -94,7 +94,7 @@ ExcludeArch: ppc64le Summary: Mozilla Firefox Web browser Name: firefox Version: 69.0.1 -Release: 4%{?pre_tag}%{?dist} +Release: 5%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz @@ -141,7 +141,7 @@ Patch224: mozilla-1170092.patch #ARM run-time patch Patch226: rhbz-1354671.patch Patch227: firefox-locale-debug.patch -Patch228: rhbz-1754460.patch +Patch228: mozilla-1583466.patch # Upstream patches Patch402: mozilla-1196777.patch @@ -367,7 +367,7 @@ This package contains results of tests executed during build. %patch226 -p1 -b .1354671 %endif %patch227 -p1 -b .locale-debug -%patch228 -p1 -b .rhbz-1754460 +%patch228 -p1 -b .mozilla-1583466 %patch402 -p1 -b .1196777 #%patch413 -p1 -b .1353817 @@ -983,6 +983,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : #--------------------------------------------------------------------- %changelog +* Mon Sep 30 2019 Martin Stransky - 69.0.1-5 +- Updated rhbz#1754460/mzbz#1583466 - per user policy dir. + * Tue Sep 24 2019 Martin Stransky - 69.0.1-4 - Added fix for rhbz#1754460 diff --git a/mozilla-1583466.patch b/mozilla-1583466.patch new file mode 100644 index 0000000..a4c05a9 --- /dev/null +++ b/mozilla-1583466.patch @@ -0,0 +1,156 @@ +changeset: 496943:24592798daf4 +tag: tip +parent: 496931:ca257801d86f +user: Martin Stransky +date: Tue Sep 24 12:54:11 2019 +0200 +files: toolkit/components/enterprisepolicies/EnterprisePolicies.js toolkit/xre/nsXREDirProvider.cpp xpcom/build/nsXULAppAPI.h +description: +Bug 1583466 - [Linux] Allow to Load policies per user from system on Linux/Gtk, r=mkaply + +When browser.policies.perUserPath is set, load browser policy per user +from /run/user/$UID/appname/ directory instead of the default firefox/distribution +dir. + +Differential Revision: https://phabricator.services.mozilla.com/D46921 + + +diff --git a/toolkit/components/enterprisepolicies/EnterprisePolicies.js b/toolkit/components/enterprisepolicies/EnterprisePolicies.js +--- a/toolkit/components/enterprisepolicies/EnterprisePolicies.js ++++ b/toolkit/components/enterprisepolicies/EnterprisePolicies.js +@@ -18,16 +18,19 @@ XPCOMUtils.defineLazyModuleGetters(this, + JsonSchemaValidator: + "resource://gre/modules/components-utils/JsonSchemaValidator.jsm", + }); + + // This is the file that will be searched for in the + // ${InstallDir}/distribution folder. + const POLICIES_FILENAME = "policies.json"; + ++// When true browser policy is loaded per-user from ++// /run/usr/$UID/appname ++const PREF_PER_USER_DIR = "browser.policies.perUserDir"; + // For easy testing, modify the helpers/sample.json file, + // and set PREF_ALTERNATE_PATH in firefox.js as: + // /your/repo/browser/components/enterprisepolicies/helpers/sample.json + const PREF_ALTERNATE_PATH = "browser.policies.alternatePath"; + // For testing, we may want to set PREF_ALTERNATE_PATH to point to a file + // relative to the test root directory. In order to enable this, the string + // below may be placed at the beginning of that preference value and it will + // be replaced with the path to the test root directory. +@@ -450,17 +453,22 @@ class JSONPoliciesProvider { + + get failed() { + return this._failed; + } + + _getConfigurationFile() { + let configFile = null; + try { +- configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile); ++ let perUserPath = Services.prefs.getBoolPref(PREF_PER_USER_DIR, false); ++ if (perUserPath) { ++ configFile = Services.dirsvc.get("XREAppDistUser", Ci.nsIFile); ++ } else { ++ configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile); ++ } + configFile.append(POLICIES_FILENAME); + } catch (ex) { + // Getting the correct directory will fail in xpcshell tests. This should + // be handled the same way as if the configFile simply does not exist. + } + + let alternatePath = Services.prefs.getStringPref(PREF_ALTERNATE_PATH, ""); + +diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp +--- a/toolkit/xre/nsXREDirProvider.cpp ++++ b/toolkit/xre/nsXREDirProvider.cpp +@@ -40,16 +40,17 @@ + #include "mozilla/dom/ScriptSettings.h" + + #include "mozilla/AutoRestore.h" + #include "mozilla/Components.h" + #include "mozilla/Services.h" + #include "mozilla/Omnijar.h" + #include "mozilla/Preferences.h" + #include "mozilla/Telemetry.h" ++#include "nsPrintfCString.h" + + #include + + #ifdef XP_WIN + # include + # include + # include "WinUtils.h" + #endif +@@ -98,17 +99,17 @@ static already_AddRefed CreateP + nsXREDirProvider* gDirServiceProvider = nullptr; + nsIFile* gDataDirHomeLocal = nullptr; + nsIFile* gDataDirHome = nullptr; + nsCOMPtr gDataDirProfileLocal = nullptr; + nsCOMPtr gDataDirProfile = nullptr; + + // These are required to allow nsXREDirProvider to be usable in xpcshell tests. + // where gAppData is null. +-#if defined(XP_MACOSX) || defined(XP_WIN) ++#if defined(XP_MACOSX) || defined(XP_WIN) || defined(XP_UNIX) + static const char* GetAppName() { + if (gAppData) { + return gAppData->name; + } + return nullptr; + } + #endif + +@@ -456,16 +457,24 @@ nsXREDirProvider::GetFile(const char* aP + else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DIR)) { + #ifdef ENABLE_SYSTEM_EXTENSION_DIRS + return GetSysUserExtensionsDirectory(aFile); + #else + return NS_ERROR_FAILURE; + #endif + } else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DEV_DIR)) { + return GetSysUserExtensionsDevDirectory(aFile); ++ } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_USER_DIR)) { ++#ifdef MOZ_WIDGET_GTK ++ nsPrintfCString path("/run/user/%d/%s/", getuid(), GetAppName()); ++ ToLowerCase(path); ++ return NS_NewNativeLocalFile(path, false, aFile); ++#else ++ return NS_ERROR_FAILURE; ++#endif + } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) { + bool persistent = false; + rv = GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(file)); + if (NS_SUCCEEDED(rv)) + rv = file->AppendNative(NS_LITERAL_CSTRING("distribution")); + } else if (!strcmp(aProperty, XRE_APP_FEATURES_DIR)) { + rv = GetAppDir()->Clone(getter_AddRefs(file)); + if (NS_SUCCEEDED(rv)) +diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h +--- a/xpcom/build/nsXULAppAPI.h ++++ b/xpcom/build/nsXULAppAPI.h +@@ -137,16 +137,23 @@ + + /** + * A directory service key which specifies the location for app dir add-ons. + * Should be a synonym for XCurProcD everywhere except in tests. + */ + #define XRE_ADDON_APP_DIR "XREAddonAppDir" + + /** ++ * A directory service key which specifies the distribution specific files for ++ * the application unique for each user. ++ * It's located at /run/user/$PID// ++ */ ++#define XRE_APP_DISTRIBUTION_USER_DIR "XREAppDistUser" ++ ++/** + * A directory service key which provides the update directory. Callers should + * fall back to appDir. + * Windows: If vendor name exists: + * ProgramData\\updates\ + * + * + * If vendor name doesn't exist, but product name exists: + * ProgramData\\updates\ + diff --git a/rhbz-1754460.patch b/rhbz-1754460.patch deleted file mode 100644 index cdfc236..0000000 --- a/rhbz-1754460.patch +++ /dev/null @@ -1,127 +0,0 @@ -diff --git a/toolkit/components/enterprisepolicies/EnterprisePolicies.js b/toolkit/components/enterprisepolicies/EnterprisePolicies.js ---- a/toolkit/components/enterprisepolicies/EnterprisePolicies.js -+++ b/toolkit/components/enterprisepolicies/EnterprisePolicies.js -@@ -447,21 +447,28 @@ class JSONPoliciesProvider { - - get failed() { - return this._failed; - } - - _getConfigurationFile() { - let configFile = null; - try { -- configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile); -+ configFile = Services.dirsvc.get("XREAppDistUser", Ci.nsIFile); - configFile.append(POLICIES_FILENAME); -- } catch (ex) { -- // Getting the correct directory will fail in xpcshell tests. This should -- // be handled the same way as if the configFile simply does not exist. -+ } catch (ex) {} -+ -+ if (!configFile) { -+ try { -+ configFile = Services.dirsvc.get("XREAppDist", Ci.nsIFile); -+ configFile.append(POLICIES_FILENAME); -+ } catch (ex) { -+ // Getting the correct directory will fail in xpcshell tests. This should -+ // be handled the same way as if the configFile simply does not exist. -+ } - } - - let alternatePath = Services.prefs.getStringPref(PREF_ALTERNATE_PATH, ""); - - // Check if we are in automation *before* we use the synchronous - // nsIFile.exists() function or allow the config file to be overriden - // An alternate policy path can also be used in Nightly builds (for - // testing purposes), but the Background Update Agent will be unable to -diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp ---- a/toolkit/xre/nsXREDirProvider.cpp -+++ b/toolkit/xre/nsXREDirProvider.cpp -@@ -40,16 +40,17 @@ - #include "mozilla/dom/ScriptSettings.h" - - #include "mozilla/AutoRestore.h" - #include "mozilla/Components.h" - #include "mozilla/Services.h" - #include "mozilla/Omnijar.h" - #include "mozilla/Preferences.h" - #include "mozilla/Telemetry.h" -+#include "nsPrintfCString.h" - - #include - - #ifdef XP_WIN - # include - # include - # include "WinUtils.h" - #endif -@@ -98,17 +99,17 @@ static already_AddRefed CreateP - nsXREDirProvider* gDirServiceProvider = nullptr; - nsIFile* gDataDirHomeLocal = nullptr; - nsIFile* gDataDirHome = nullptr; - nsCOMPtr gDataDirProfileLocal = nullptr; - nsCOMPtr gDataDirProfile = nullptr; - - // These are required to allow nsXREDirProvider to be usable in xpcshell tests. - // where gAppData is null. --#if defined(XP_MACOSX) || defined(XP_WIN) -+#if defined(XP_MACOSX) || defined(XP_WIN) || defined(XP_UNIX) - static const char* GetAppName() { - if (gAppData) { - return gAppData->name; - } - return nullptr; - } - #endif - -@@ -456,16 +457,23 @@ nsXREDirProvider::GetFile(const char* aP - else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DIR)) { - #ifdef ENABLE_SYSTEM_EXTENSION_DIRS - return GetSysUserExtensionsDirectory(aFile); - #else - return NS_ERROR_FAILURE; - #endif - } else if (!strcmp(aProperty, XRE_USER_SYS_EXTENSION_DEV_DIR)) { - return GetSysUserExtensionsDevDirectory(aFile); -+ } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_USER_DIR)) { -+# ifndef MOZ_WIDGET_GTK -+ return NS_ERROR_FAILURE; -+# endif -+ return NS_NewNativeLocalFile( -+ nsPrintfCString("/run/user/%d/%s/", getuid(), GetAppName()), -+ false, aFile); - } else if (!strcmp(aProperty, XRE_APP_DISTRIBUTION_DIR)) { - bool persistent = false; - rv = GetFile(NS_GRE_DIR, &persistent, getter_AddRefs(file)); - if (NS_SUCCEEDED(rv)) - rv = file->AppendNative(NS_LITERAL_CSTRING("distribution")); - } else if (!strcmp(aProperty, XRE_APP_FEATURES_DIR)) { - rv = GetAppDir()->Clone(getter_AddRefs(file)); - if (NS_SUCCEEDED(rv)) -diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h ---- a/xpcom/build/nsXULAppAPI.h -+++ b/xpcom/build/nsXULAppAPI.h -@@ -137,16 +137,23 @@ - - /** - * A directory service key which specifies the location for app dir add-ons. - * Should be a synonym for XCurProcD everywhere except in tests. - */ - #define XRE_ADDON_APP_DIR "XREAddonAppDir" - - /** -+ * A directory service key which specifies the distribution specific files for -+ * the application unique for each user. -+ * It's located at /run/user/$PID// -+ */ -+#define XRE_APP_DISTRIBUTION_USER_DIR "XREAppDistUser" -+ -+/** - * A directory service key which provides the update directory. Callers should - * fall back to appDir. - * Windows: If vendor name exists: - * ProgramData\\updates\ - * - * - * If vendor name doesn't exist, but product name exists: - * ProgramData\\updates\ -- cgit