From 4bed479594585999191504498433e2af7d058f41 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Mon, 21 Mar 2016 14:40:15 +0100 Subject: WIP - more debian/upstream patches --- ...reference-files-to-set-locked-prefs-with-.patch | 120 +++++++++++++++ firefox.spec | 7 +- mozilla-1170092.patch | 161 +++++++++++++++++++++ 3 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 Allow-.js-preference-files-to-set-locked-prefs-with-.patch create mode 100644 mozilla-1170092.patch diff --git a/Allow-.js-preference-files-to-set-locked-prefs-with-.patch b/Allow-.js-preference-files-to-set-locked-prefs-with-.patch new file mode 100644 index 0000000..5fd4ed1 --- /dev/null +++ b/Allow-.js-preference-files-to-set-locked-prefs-with-.patch @@ -0,0 +1,120 @@ +From: Mike Hommey +Date: Sat, 21 Jun 2008 02:48:46 +0200 +Subject: Allow .js preference files to set locked prefs with lockPref() + +--- + modules/libpref/prefapi.cpp | 5 ++++- + modules/libpref/prefapi.h | 3 ++- + modules/libpref/prefread.cpp | 12 +++++++++--- + modules/libpref/prefread.h | 4 +++- + 4 files changed, 18 insertions(+), 6 deletions(-) + +diff --git a/modules/libpref/prefapi.cpp b/modules/libpref/prefapi.cpp +index dd27769..bd3f8ea 100644 +--- a/modules/libpref/prefapi.cpp ++++ b/modules/libpref/prefapi.cpp +@@ -967,11 +967,14 @@ void PREF_ReaderCallback(void *closure, + PrefValue value, + PrefType type, + bool isDefault, +- bool isStickyDefault) ++ bool isStickyDefault, ++ bool isLocked) + { + uint32_t flags = isDefault ? kPrefSetDefault : kPrefForceSet; + if (isDefault && isStickyDefault) { + flags |= kPrefStickyDefault; + } + pref_HashPref(pref, value, type, flags); ++ if (isLocked) ++ PREF_LockPref(pref, true); + } +diff --git a/modules/libpref/prefapi.h b/modules/libpref/prefapi.h +index 5bd8c43..0ab0d7c 100644 +--- a/modules/libpref/prefapi.h ++++ b/modules/libpref/prefapi.h +@@ -186,7 +186,8 @@ void PREF_ReaderCallback( void *closure, + PrefValue value, + PrefType type, + bool isDefault, +- bool isStickyDefault); ++ bool isStickyDefault, ++ bool isLocked); + + #ifdef __cplusplus + } +diff --git a/modules/libpref/prefread.cpp b/modules/libpref/prefread.cpp +index 6c4d339..16c5057 100644 +--- a/modules/libpref/prefread.cpp ++++ b/modules/libpref/prefread.cpp +@@ -43,6 +43,7 @@ enum { + #define BITS_PER_HEX_DIGIT 4 + + static const char kUserPref[] = "user_pref"; ++static const char kLockPref[] = "lockPref"; + static const char kPref[] = "pref"; + static const char kPrefSticky[] = "sticky_pref"; + static const char kTrue[] = "true"; +@@ -131,7 +132,7 @@ pref_DoCallback(PrefParseState *ps) + break; + } + (*ps->reader)(ps->closure, ps->lb, value, ps->vtype, ps->fdefault, +- ps->fstickydefault); ++ ps->fstickydefault, ps->flock); + return true; + } + +@@ -191,6 +192,7 @@ PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen) + ps->vtype = PREF_INVALID; + ps->fdefault = false; + ps->fstickydefault = false; ++ ps->flock = false; + } + switch (c) { + case '/': /* begin comment block or line? */ +@@ -202,8 +204,10 @@ PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen) + case 'u': /* indicating user_pref */ + case 'p': /* indicating pref */ + case 's': /* indicating sticky_pref */ ++ case 'l': /* indicating lockPref */ + ps->smatch = (c == 'u' ? kUserPref : +- (c == 's' ? kPrefSticky : kPref)); ++ (c == 's' ? kPrefSticky : ++ (c == 'p' ? kPref : kLockPref))); + ps->sindex = 1; + ps->nextstate = PREF_PARSE_UNTIL_OPEN_PAREN; + state = PREF_PARSE_MATCH_STRING; +@@ -247,8 +251,10 @@ PREF_ParseBuf(PrefParseState *ps, const char *buf, int bufLen) + /* name parsing */ + case PREF_PARSE_UNTIL_NAME: + if (c == '\"' || c == '\'') { +- ps->fdefault = (ps->smatch == kPref || ps->smatch == kPrefSticky); ++ ps->fdefault = (ps->smatch == kPref || ps->smatch == kPrefSticky ++ || ps->smatch == kLockPref); + ps->fstickydefault = (ps->smatch == kPrefSticky); ++ ps->flock = (ps->smatch == kLockPref); + ps->quotechar = c; + ps->nextstate = PREF_PARSE_UNTIL_COMMA; /* return here when done */ + state = PREF_PARSE_QUOTED_STRING; +diff --git a/modules/libpref/prefread.h b/modules/libpref/prefread.h +index 3c317ff..0c13057 100644 +--- a/modules/libpref/prefread.h ++++ b/modules/libpref/prefread.h +@@ -34,7 +34,8 @@ typedef void (*PrefReader)(void *closure, + PrefValue val, + PrefType type, + bool defPref, +- bool stickyPref); ++ bool stickyPref, ++ bool lockPref); + + /* structure fields are private */ + typedef struct PrefParseState { +@@ -56,6 +57,7 @@ typedef struct PrefParseState { + PrefType vtype; /* PREF_STRING,INT,BOOL */ + bool fdefault; /* true if (default) pref */ + bool fstickydefault; /* true if (sticky) pref */ ++ bool flock; /* true if pref to be locked */ + } PrefParseState; + + /** diff --git a/firefox.spec b/firefox.spec index 8607f10..7b70e01 100644 --- a/firefox.spec +++ b/firefox.spec @@ -124,6 +124,7 @@ Patch219: rhbz-1173156.patch Patch221: firefox-fedora-ua.patch Patch222: firefox-gtk3-20.patch Patch223: rhbz-1291190-appchooser-crash.patch +Patch224: mozilla-1170092.patch # Upstream patches Patch301: mozilla-1205199.patch @@ -131,8 +132,9 @@ Patch302: mozilla-1228540.patch Patch303: mozilla-1228540-1.patch Patch304: mozilla-1253216.patch -# Debian extension patch +# Debian patches Patch400: Allow-unsigned-addons-in-usr-lib-share-mozilla-exten.patch +Patch401: Allow-.js-preference-files-to-set-locked-prefs-with-.patch # Fix Skia Neon stuff on AArch64 # Update https://bugzilla.mozilla.org/show_bug.cgi?id=1142056 @@ -278,6 +280,8 @@ cd %{tarballdir} %patch301 -p1 -b .1205199 %patch302 -p1 -b .1228540 %patch303 -p1 -b .1228540-1 +#%patch224 -p1 -b .1170092 + %if 0%{?fedora} > 23 %patch304 -p2 -b .1253216 %patch222 -p1 -b .gtk3-20 @@ -285,6 +289,7 @@ cd %{tarballdir} # Debian extension patch %patch400 -p1 -b .debian-addon +#%patch401 -p1 -b .js-pref-lock %patch500 -p1 diff --git a/mozilla-1170092.patch b/mozilla-1170092.patch new file mode 100644 index 0000000..ed4d3ce --- /dev/null +++ b/mozilla-1170092.patch @@ -0,0 +1,161 @@ +# HG changeset patch +# User Jan Horak +# Parent f986e55c4e0b41c6b50bd74d287614b564d7895f +# Bug 1170092 - Read default prefs also from /etc/firefox/defaults/pref + +diff --git a/extensions/pref/autoconfig/src/nsReadConfig.cpp b/extensions/pref/autoconfig/src/nsReadConfig.cpp +--- a/extensions/pref/autoconfig/src/nsReadConfig.cpp ++++ b/extensions/pref/autoconfig/src/nsReadConfig.cpp +@@ -240,18 +240,30 @@ nsresult nsReadConfig::openAndEvaluateJS + if (NS_FAILED(rv)) + return rv; + + rv = jsFile->AppendNative(nsDependentCString(aFileName)); + 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//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; + + nsCOMPtr uri; + rv = NS_NewURI(getter_AddRefs(uri), location); + NS_ENSURE_SUCCESS(rv, rv); +diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp +--- a/modules/libpref/Preferences.cpp ++++ b/modules/libpref/Preferences.cpp +@@ -1228,16 +1228,18 @@ static nsresult pref_InitInitialObjects( + // - jar:$app/omni.jar!/defaults/preferences/*.js + // - $app/defaults/preferences/*.js + // and in non omni.jar case: + // - $app/defaults/preferences/*.js + // When $app == $gre, we additionally load, in omni.jar case: + // - jar:$gre/omni.jar!/defaults/preferences/*.js + // Thus, in 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 + + nsZipFind *findPtr; + nsAutoPtr find; + nsTArray prefEntries; + const char *entryName; + uint16_t entryNameLen; + + nsRefPtr jarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); +diff --git a/toolkit/xre/nsXREDirProvider.cpp b/toolkit/xre/nsXREDirProvider.cpp +--- a/toolkit/xre/nsXREDirProvider.cpp ++++ b/toolkit/xre/nsXREDirProvider.cpp +@@ -47,16 +47,17 @@ + #ifdef XP_MACOSX + #include "nsILocalFileMac.h" + // for chflags() + #include + #include + #endif + #ifdef XP_UNIX + #include ++#include "nsIXULAppInfo.h" + #endif + + #if defined(XP_MACOSX) + #define APP_REGISTRY_NAME "Application Registry" + #elif defined(XP_WIN) + #define APP_REGISTRY_NAME "registry.dat" + #else + #define APP_REGISTRY_NAME "appreg" +@@ -438,16 +439,30 @@ nsXREDirProvider::GetFile(const char* aP + rv = tmp; + } + tmp = EnsureDirectoryExists(file); + if (NS_FAILED(tmp)) { + rv = tmp; + } + } + } ++#if defined(XP_UNIX) ++ if (!strcmp(aProperty, NS_APP_PREFS_SYSTEM_CONFIG_DIR)) { ++ nsCString sysConfigDir = NS_LITERAL_CSTRING("/etc/"); ++ nsCOMPtr 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) { + bool fileToEnsureExists; + bool isWritable; + if (NS_SUCCEEDED(file->Exists(&fileToEnsureExists)) && fileToEnsureExists + && NS_SUCCEEDED(file->IsWritable(&isWritable)) && !isWritable) { +@@ -713,16 +728,24 @@ nsXREDirProvider::GetFilesInternal(const + rv = NS_NewArrayEnumerator(aResult, directories); + } + else if (!strcmp(aProperty, NS_APP_PREFS_DEFAULTS_DIR_LIST)) { + nsCOMArray directories; + + LoadDirIntoArray(mXULAppDir, kAppendPrefDir, directories); + LoadDirsIntoArray(mAppBundleDirectories, + kAppendPrefDir, directories); ++ // Add /etc//pref/ directory if it exists ++ nsCOMPtr 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); + } + else if (!strcmp(aProperty, NS_EXT_PREFS_DEFAULTS_DIR_LIST)) { + nsCOMArray directories; + + LoadDirsIntoArray(mExtensionDirectories, + kAppendPrefDir, directories); +diff --git a/xpcom/io/nsAppDirectoryServiceDefs.h b/xpcom/io/nsAppDirectoryServiceDefs.h +--- a/xpcom/io/nsAppDirectoryServiceDefs.h ++++ b/xpcom/io/nsAppDirectoryServiceDefs.h +@@ -61,16 +61,17 @@ + + #define NS_SHARED "SHARED" + + #define NS_APP_PREFS_50_DIR "PrefD" // Directory which contains user prefs + #define NS_APP_PREFS_50_FILE "PrefF" + #define NS_APP_PREFS_DEFAULTS_DIR_LIST "PrefDL" + #define NS_EXT_PREFS_DEFAULTS_DIR_LIST "ExtPrefDL" + #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" + + #define NS_APP_USER_CHROME_DIR "UChrm" + #define NS_APP_USER_SEARCH_DIR "UsrSrchPlugns" + + #define NS_APP_LOCALSTORE_50_FILE "LclSt" -- cgit