Bug 1616355: attribution postSigningData should be per installation r=nalexander

about:newtab#asrouter actually depends on the ability to be able to write to postSigningData at the moment, so this will break that in any circumstance where the running Firefox cannot write to the installation directory. This code is only used for dev & qa testing though, and I've been told this is OK (and we may change how it works to avoid writing the file at all).

Differential Revision: https://phabricator.services.mozilla.com/D144167
This commit is contained in:
Ben Hearsum 2022-05-03 20:04:28 +00:00
Родитель ce93990c8d
Коммит 1e2cdbc725
5 изменённых файлов: 21 добавлений и 7 удалений

Просмотреть файл

@ -78,10 +78,7 @@ var AttributionCode = {
*/
get attributionFile() {
if (AppConstants.platform == "win") {
let file = Services.dirsvc.get("LocalAppData", Ci.nsIFile);
// appinfo does not exist in xpcshell, so we need defaults.
file.append(Services.appinfo.vendor || "mozilla");
file.append(AppConstants.MOZ_APP_NAME);
let file = Services.dirsvc.get("GreD", Ci.nsIFile);
file.append("postSigningData");
return file;
} else if (AppConstants.platform == "macosx") {

Просмотреть файл

@ -22,6 +22,8 @@ At the end of an application update cycle, after the new files are in place, the
It's important to remember that PostUpdate is, indeed, post-update. It doesn't run until after its own code has already been updated. This makes it really the only phase of the update process where changes can go into affect immediately in the first build that contains a patch, instead of having to wait for the next update after that. This makes it a good place to put anything that needs to be done before the new version of the application can run; this includes things like registering DLL's, which the installer also handles, but that PostUpdate has to take care of for existing installations.
PostUpdate actually runs two times after each update: once in an elevated context, and once as a regular user who performed the update. Both runs do similar work - the main difference being that we update HKLM registry entries are updated by the elevated instance, while HKCU ones are updated by the non-elevated instance.
It's also important to remember that PostUpdate, being part of the installer code, only exists on Windows, so it can't be used to fix things up on other platforms the same way.
Default Browser and Shortcut Handling

Просмотреть файл

@ -85,6 +85,20 @@
; Fix the distribution.ini file if applicable
${FixDistributionsINI}
; https://bugzilla.mozilla.org/show_bug.cgi?id=1616355
; Migrate postSigningData file if present, and if it doesn't already exist.
${GetLocalAppDataFolder} $0
${If} ${FileExists} "$INSTDIR\postSigningData"
; If it already exists, just delete the appdata one.
; It's possible this was for a different install, but it's impossible to
; know for sure, so we may as well just get rid of it.
Delete /REBOOTOK "$0\Mozilla\Firefox\postSigningData"
${Else}
${If} ${FileExists} "$0\Mozilla\Firefox\postSigningData"
Rename "$0\Mozilla\Firefox\postSigningData" "$INSTDIR\postSigningData"
${EndIf}
${EndIf}
RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
; Register AccessibleHandler.dll with COM (this requires write access to HKLM)

Просмотреть файл

@ -636,6 +636,9 @@ Section "Uninstall"
${If} ${FileExists} "$INSTDIR\installation_telemetry.json"
Delete /REBOOTOK "$INSTDIR\installation_telemetry.json"
${EndIf}
${If} ${FileExists} "$INSTDIR\postSigningData.json"
Delete /REBOOTOK "$INSTDIR\postSigningData.json"
${EndIf}
; Explicitly remove empty webapprt dir in case it exists (bug 757978).
RmDir "$INSTDIR\webapprt\components"

Просмотреть файл

@ -7993,9 +7993,7 @@
ClearErrors
StrCpy $0 "0"
${Else}
${GetLocalAppDataFolder} $1
CreateDirectory "$1\Mozilla\Firefox"
CopyFiles /SILENT "$EXEDIR\postSigningData" "$1\Mozilla\Firefox"
CopyFiles /SILENT "$EXEDIR\postSigningData" "$INSTDIR"
${Endif}
Pop $1 ; Stack: old $0