Provide /etc/thunderbird/pref (bug #1525709)

This commit is contained in:
Jan Horak 2021-01-20 15:39:04 +01:00
parent 661d8e5a44
commit 17b401b78f
2 changed files with 110 additions and 1 deletions

99
mozilla-1170092.patch Normal file
View File

@ -0,0 +1,99 @@
diff -up firefox-75.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 firefox-75.0/extensions/pref/autoconfig/src/nsReadConfig.cpp
--- firefox-75.0/extensions/pref/autoconfig/src/nsReadConfig.cpp.1170092 2020-04-03 21:34:41.000000000 +0200
+++ firefox-75.0/extensions/pref/autoconfig/src/nsReadConfig.cpp 2020-04-06 22:40:02.760674871 +0200
@@ -244,8 +244,20 @@ nsresult nsReadConfig::openAndEvaluateJS
if (NS_FAILED(rv)) 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(nsLiteralCString("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-75.0/modules/libpref/Preferences.cpp.1170092 firefox-75.0/modules/libpref/Preferences.cpp
--- firefox-75.0/modules/libpref/Preferences.cpp.1170092 2020-04-06 22:40:02.761674865 +0200
+++ firefox-75.0/modules/libpref/Preferences.cpp 2020-04-06 22:40:57.675325227 +0200
@@ -4468,6 +4468,9 @@ nsresult Preferences::InitInitialObjects
//
// 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 = NS_ERROR_FAILURE;
UniquePtr<nsZipFind> find;
diff -up firefox-75.0/toolkit/xre/nsXREDirProvider.cpp.1170092 firefox-75.0/toolkit/xre/nsXREDirProvider.cpp
--- firefox-75.0/toolkit/xre/nsXREDirProvider.cpp.1170092 2020-04-03 21:35:39.000000000 +0200
+++ firefox-75.0/toolkit/xre/nsXREDirProvider.cpp 2020-04-06 22:40:02.761674865 +0200
@@ -60,6 +60,7 @@
#endif
#ifdef XP_UNIX
# include <ctype.h>
+# include "nsIXULAppInfo.h"
#endif
#ifdef XP_IOS
# include "UIKitDirProvider.h"
@@ -533,6 +534,21 @@ nsXREDirProvider::GetFile(const char* aP
}
}
}
+
+#if defined(XP_UNIX)
+ if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) {
+ nsCString sysConfigDir = nsLiteralCString("/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;
if (ensureFilePermissions) {
@@ -845,6 +861,16 @@ nsresult nsXREDirProvider::GetFilesInter
LoadDirIntoArray(mXULAppDir, 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(nsLiteralCString("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)) {
// NS_APP_CHROME_DIR_LIST is only used to get default (native) icons
diff -up firefox-75.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 firefox-75.0/xpcom/io/nsAppDirectoryServiceDefs.h
--- firefox-75.0/xpcom/io/nsAppDirectoryServiceDefs.h.1170092 2020-04-03 21:35:39.000000000 +0200
+++ firefox-75.0/xpcom/io/nsAppDirectoryServiceDefs.h 2020-04-06 22:40:02.761674865 +0200
@@ -60,6 +60,7 @@
#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"

View File

@ -81,7 +81,7 @@ ExcludeArch: armv7hl
Summary: Mozilla Thunderbird mail/newsgroup client
Name: thunderbird
Version: 78.6.1
Release: 1%{?dist}
Release: 2%{?dist}
URL: http://www.mozilla.org/projects/thunderbird/
License: MPLv1.1 or GPLv2+ or LGPLv2+
Source0: ftp://ftp.mozilla.org/pub/thunderbird/releases/%{version}%{?pre_version}/source/thunderbird-%{version}%{?pre_version}.source.tar.xz
@ -120,6 +120,7 @@ Patch307: build-disable-elfhack.patch
# Upstream patches
Patch402: mozilla-526293.patch
Patch405: mozilla-1556931-s390x-hidden-syms.patch
Patch406: mozilla-1170092.patch
%if %{official_branding}
# Required by Mozilla Corporation
@ -262,6 +263,7 @@ debug %{name}, you want to install %{name}-debuginfo instead.
%patch402 -p1 -b .526293
%patch405 -p1 -b .1556931-s390x-hidden-syms
%patch406 -p1 -b .1170092-etc-conf
%if %{official_branding}
# Required by Mozilla Corporation
@ -568,6 +570,9 @@ rm -f $RPM_BUILD_ROOT/%{_bindir}/thunderbird
%{__mkdir_p} $RPM_BUILD_ROOT%{_datadir}/mozilla/extensions/%{thunderbird_app_id}
%{__mkdir_p} $RPM_BUILD_ROOT%{_libdir}/mozilla/extensions/%{thunderbird_app_id}
# System config dir (#1525709)
%{__mkdir_p} %{buildroot}%{_sysconfdir}/%{name}/pref
# Install langpacks
%{__rm} -f %{name}.lang # Delete for --short-circuit option
touch %{name}.lang
@ -685,6 +690,8 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%attr(755,root,root) %{_bindir}/thunderbird
%{_datadir}/appdata/*.appdata.xml
%attr(644,root,root) %{_datadir}/applications/mozilla-thunderbird.desktop
%dir %{_sysconfdir}/%{name}
%dir %{_sysconfdir}/%{name}/*
%dir %{_datadir}/mozilla/extensions/%{thunderbird_app_id}
%dir %{_libdir}/mozilla/extensions/%{thunderbird_app_id}
%dir %{mozappdir}
@ -735,6 +742,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
#===============================================================================
%changelog
* Wed Jan 20 2021 Orion Poplawski <orion@nwra.com> - 78.6.1-2
- Provide /etc/thunderbird/pref (bug #1525709)
* Thu Jan 14 2021 Jan Horak <jhorak@redhat.com> - 78.6.1-1
- Update to 78.6.1 build1