Skip to content

Commit 4ca2f73

Browse files
author
Butkovits Atila
committed
Backed out 5 changesets (bug 1732435) for causing bustages at nsXREDirProvider.cpp. CLOSED TREE
Backed out changeset db0701b309ad (bug 1732435) Backed out changeset 22a583f191e2 (bug 1732435) Backed out changeset b37ed631436f (bug 1732435) Backed out changeset 8a734e8a313b (bug 1732435) Backed out changeset 9cb78a88ffde (bug 1732435)
1 parent 7e5dc9c commit 4ca2f73

File tree

16 files changed

+1951
-575
lines changed

16 files changed

+1951
-575
lines changed

browser/installer/windows/nsis/installer.nsi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,12 @@ Section "-Application" APP_IDX
410410
StrCpy $AddDesktopSC "1"
411411
${EndIf}
412412

413+
${CreateUpdateDir} "Mozilla"
414+
${If} ${Errors}
415+
Pop $0
416+
${LogMsg} "** ERROR Failed to create update directory: $0"
417+
${EndIf}
418+
413419
${LogHeader} "Adding Registry Entries"
414420
SetShellVarContext current ; Set SHCTX to HKCU
415421
${RegCleanMain} "Software\Mozilla"

browser/installer/windows/nsis/uninstaller.nsi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,7 @@ Function un.OpenRefreshHelpURL
327327
ExecShell "open" "${URLProfileRefreshHelp}"
328328
FunctionEnd
329329

330-
; Returns the common directory (typically
331-
; "C:\ProgramData\Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38") on the stack.
330+
; Returns the common directory (typically "C:\ProgramData\Mozilla") on the stack.
332331
Function un.GetCommonDirectory
333332
Push $0 ; Save $0
334333

@@ -337,7 +336,7 @@ Function un.GetCommonDirectory
337336

338337
; Add our subdirectory, this is hardcoded as grandparent of the update directory in
339338
; several other places.
340-
StrCpy $0 "$0\Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38"
339+
StrCpy $0 "$0\Mozilla"
341340

342341
Exch $0 ; Restore original $0 and put our $0 on the stack.
343342
FunctionEnd

toolkit/components/maintenanceservice/workmonitor.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,25 @@ BOOL ExecuteServiceCommand(int argc, LPWSTR* argv) {
801801
// because the service self updates itself and the service
802802
// installer will stop the service.
803803
LOG(("Service command %ls complete.", argv[2]));
804+
} else if (!lstrcmpi(argv[2], L"fix-update-directory-perms")) {
805+
bool gotInstallDir = true;
806+
mozilla::UniquePtr<wchar_t[]> updateDir;
807+
if (argc <= 3) {
808+
LOG_WARN(("Didn't get an install dir for fix-update-directory-perms"));
809+
gotInstallDir = false;
810+
}
811+
HRESULT permResult =
812+
GetCommonUpdateDirectory(gotInstallDir ? argv[3] : nullptr,
813+
SetPermissionsOf::AllFilesAndDirs, updateDir);
814+
if (FAILED(permResult)) {
815+
LOG_WARN(
816+
("Unable to set the permissions on the update directory "
817+
"('%S'): %d",
818+
updateDir.get(), permResult));
819+
result = FALSE;
820+
} else {
821+
result = TRUE;
822+
}
804823
} else {
805824
LOG_WARN(("Service command not recognized: %ls.", argv[2]));
806825
// result is already set to FALSE

toolkit/mozapps/installer/windows/nsis/common.nsh

Lines changed: 85 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,11 +3567,11 @@
35673567
${If} $R2 != ""
35683568
; Backup the old update directory logs and delete the directory
35693569
${If} ${FileExists} "$R2\updates\last-update.log"
3570-
Rename "$R2\updates\last-update.log" "$TEMP\moz-update-old-1-last-update.log"
3570+
Rename "$R2\updates\last-update.log" "$TEMP\moz-update-oldest-last-update.log"
35713571
${EndIf}
35723572

35733573
${If} ${FileExists} "$R2\updates\backup-update.log"
3574-
Rename "$R2\updates\backup-update.log" "$TEMP\moz-update-old-1-backup-update.log"
3574+
Rename "$R2\updates\backup-update.log" "$TEMP\moz-update-oldest-backup-update.log"
35753575
${EndIf}
35763576

35773577
${If} ${FileExists} "$R2\updates"
@@ -3592,50 +3592,24 @@
35923592
StrCpy $R0 "$R9\$R8\$R1"
35933593

35943594
${If} ${FileExists} "$R0\updates\last-update.log"
3595-
Rename "$R0\updates\last-update.log" "$TEMP\moz-update-old-2-last-update.log"
3595+
Rename "$R0\updates\last-update.log" "$TEMP\moz-update-older-last-update.log"
35963596
${EndIf}
35973597

35983598
${If} ${FileExists} "$R0\updates\backup-update.log"
3599-
Rename "$R0\updates\backup-update.log" "$TEMP\moz-update-old-2-backup-update.log"
3599+
Rename "$R0\updates\backup-update.log" "$TEMP\moz-update-older-backup-update.log"
36003600
${EndIf}
36013601

36023602
; Remove the old updates directory, located in the user's Windows profile directory
36033603
${If} ${FileExists} "$R0\updates"
36043604
RmDir /r "$R0"
36053605
${EndIf}
36063606

3607+
; Get the new updates directory so we can remove that too
3608+
; The new update directory is in the Program Data directory
3609+
; (currently C:\ProgramData).
36073610
${GetCommonAppDataFolder} $R0
36083611
StrCpy $R0 "$R0\$R8\$R1"
36093612

3610-
${If} ${FileExists} "$R0\updates\last-update.log"
3611-
Rename "$R0\updates\last-update.log" "$TEMP\moz-update-old-3-last-update.log"
3612-
${EndIf}
3613-
3614-
${If} ${FileExists} "$R0\updates\backup-update.log"
3615-
Rename "$R0\updates\backup-update.log" "$TEMP\moz-update-old-3-backup-update.log"
3616-
${EndIf}
3617-
3618-
; Even though this is an old update directory, completely clear it out
3619-
; on uninstall only, not on installation. If this is an installation,
3620-
; it may be a paveover install and there may be un-migrated settings
3621-
; in the update directory that we don't want to lose.
3622-
; On install though, we should still remove pending updates and update
3623-
; metadata since migrating that data could potentially confuse Firefox
3624-
; into thinking that it failed to apply an update.
3625-
!if "${_MOZFUNC_UN}" == "un."
3626-
${If} ${FileExists} "$R0"
3627-
RmDir /r "$R0"
3628-
${EndIf}
3629-
!else
3630-
${If} ${FileExists} "$R0\updates"
3631-
RmDir /r "$R0\updates"
3632-
${EndIf}
3633-
Delete "$R0\active-update.xml"
3634-
!endif
3635-
3636-
${GetCommonAppDataFolder} $R0
3637-
StrCpy $R0 "$R0\Mozilla-1de4eec8-1241-4177-a864-e594e8d1fb38\updates\$R1"
3638-
36393613
${If} ${FileExists} "$R0\updates\last-update.log"
36403614
Rename "$R0\updates\last-update.log" "$TEMP\moz-update-newest-last-update.log"
36413615
${EndIf}
@@ -3732,6 +3706,84 @@
37323706
!endif
37333707
!macroend
37343708

3709+
/**
3710+
* Create the update directory and sets the permissions correctly
3711+
*
3712+
* @param ROOT_DIR_NAME
3713+
* The name of the update directory to be created in the common
3714+
* application directory. For example, if ROOT_DIR_NAME is "Mozilla",
3715+
* the created directory will be "C:\ProgramData\Mozilla".
3716+
*
3717+
* $R0 = Used for checking errors
3718+
* $R1 = The common application directory path
3719+
* $R9 = An error message to be returned on the stack
3720+
*/
3721+
!macro CreateUpdateDir ROOT_DIR_NAME
3722+
Push $R9
3723+
Push $R0
3724+
Push $R1
3725+
3726+
; The update directory is in the Program Data directory
3727+
; (currently C:\ProgramData).
3728+
${GetCommonAppDataFolder} $R1
3729+
StrCpy $R1 "$R1\${ROOT_DIR_NAME}"
3730+
3731+
ClearErrors
3732+
${IfNot} ${FileExists} "$R1"
3733+
CreateDirectory "$R1"
3734+
${If} ${Errors}
3735+
StrCpy $R9 "Unable to create directory: $R1"
3736+
GoTo end
3737+
${EndIf}
3738+
${EndIf}
3739+
3740+
; Grant Full Access to the Builtin User group
3741+
AccessControl::SetOnFile "$R1" "(BU)" "FullAccess"
3742+
Pop $R0
3743+
${If} $R0 == error
3744+
Pop $R9 ; Get AccessControl's Error Message
3745+
SetErrors
3746+
GoTo end
3747+
${EndIf}
3748+
3749+
; Grant Full Access to the Builtin Administrator group
3750+
AccessControl::SetOnFile "$R1" "(BA)" "FullAccess"
3751+
Pop $R0
3752+
${If} $R0 == error
3753+
Pop $R9 ; Get AccessControl's Error Message
3754+
SetErrors
3755+
GoTo end
3756+
${EndIf}
3757+
3758+
; Grant Full Access to the SYSTEM user
3759+
AccessControl::SetOnFile "$R1" "(SY)" "FullAccess"
3760+
Pop $R0
3761+
${If} $R0 == error
3762+
Pop $R9 ; Get AccessControl's Error Message
3763+
SetErrors
3764+
GoTo end
3765+
${EndIf}
3766+
3767+
; Remove inherited permissions
3768+
AccessControl::DisableFileInheritance "$R1"
3769+
Pop $R0
3770+
${If} $R0 == error
3771+
Pop $R9 ; Get AccessControl's Error Message
3772+
SetErrors
3773+
GoTo end
3774+
${EndIf}
3775+
3776+
end:
3777+
Pop $R1
3778+
Pop $R0
3779+
${If} ${Errors}
3780+
Exch $R9
3781+
${Else}
3782+
Pop $R9
3783+
${EndIf}
3784+
!macroend
3785+
!define CreateUpdateDir "!insertmacro CreateUpdateDir"
3786+
37353787
/**
37363788
* Deletes shortcuts and Start Menu directories under Programs as specified by
37373789
* the shortcuts log ini file and on Windows 7 unpins TaskBar and Start Menu

toolkit/mozapps/update/BackgroundUpdate.jsm

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Cu.importGlobalProperties(["Glean"]);
5555
// by storing the installed version number of the task to a pref and comparing
5656
// that version number to the current version. If they aren't equal, we know
5757
// that we have to re-register the task.
58-
const TASK_DEF_CURRENT_VERSION = 3;
58+
const TASK_DEF_CURRENT_VERSION = 2;
5959
const TASK_INSTALLED_VERSION_PREF =
6060
"app.update.background.lastInstalledTaskVersion";
6161

@@ -508,41 +508,6 @@ var BackgroundUpdate = {
508508
} catch (e) {
509509
log.error(`${SLUG}: Error removing old task: ${e}`);
510510
}
511-
try {
512-
// When the update directory was moved, we migrated the old contents
513-
// to the new location. This can potentially happen in a background
514-
// task. However, we also need to re-register the background task
515-
// with the task scheduler in order to update the MOZ_LOG_FILE value
516-
// to point to the new location. If the task runs before Firefox has
517-
// a chance to re-register the task, the log file may be recreated in
518-
// the old location. In practice, this would be unusual, because
519-
// MOZ_LOG_FILE will not create the parent directories necessary to
520-
// put a log file in the specified location. But just to be safe,
521-
// we'll do some cleanup when we re-register the task to make sure
522-
// that no log file is hanging around in the old location.
523-
let oldUpdateDir = FileUtils.getDir("OldUpdRootD", [], false);
524-
let oldLog = oldUpdateDir.clone();
525-
oldLog.append("backgroundupdate.moz_log");
526-
527-
if (oldLog.exists()) {
528-
oldLog.remove(false);
529-
// We may have created some directories in order to put this log
530-
// file in this location. Clean them up if they are empty.
531-
// (If we pass false for the recurse parameter, directories with
532-
// contents will not be removed)
533-
//
534-
// Potentially removes "C:\ProgramData\Mozilla\updates\<hash>"
535-
oldUpdateDir.remove(false);
536-
// Potentially removes "C:\ProgramData\Mozilla\updates"
537-
oldUpdateDir.parent.remove(false);
538-
// Potentially removes "C:\ProgramData\Mozilla"
539-
oldUpdateDir.parent.parent.remove(false);
540-
}
541-
} catch (ex) {
542-
log.warn(
543-
`${SLUG}: Ignoring error encountered attempting to remove stale log file: ${ex}`
544-
);
545-
}
546511
}
547512

548513
log.info(

0 commit comments

Comments
 (0)