Bug 789743 - Ensure bgupdates executes PostUpdate successfully. r=ehsan
authorBrian R. Bondy <netzen@gmail.com>
Thu, 20 Sep 2012 15:40:45 -0400
changeset 107780 abada9261f82f56e527fe658f7472dd3973b4b8c
parent 107779 48c4938eaf578127f2e68a4bfc51873dbe8e516d
child 107781 568593839470a107667b954bc3e6eb447c8662f2
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersehsan
bugs789743
milestone18.0a1
Bug 789743 - Ensure bgupdates executes PostUpdate successfully. r=ehsan
toolkit/components/maintenanceservice/workmonitor.cpp
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -128,16 +128,17 @@ GetInstallationDir(int argcTmp, LPWSTR *
  * @param  argv           The arguments normally passed to updater.exe
  *                        argv[0] must be the path to updater.exe
  * @param  processStarted Set to TRUE if the process was started.
  * @return TRUE if the update process was run had a return code of 0.
  */
 BOOL
 StartUpdateProcess(int argc,
                    LPWSTR *argv,
+                   LPCWSTR installDir,
                    BOOL &processStarted)
 {
   LOG(("Starting update process as the service in session 0.\n"));
   STARTUPINFO si = {0};
   si.cb = sizeof(STARTUPINFO);
   si.lpDesktop = L"winsta0\\Default";
   PROCESS_INFORMATION pi = {0};
 
@@ -243,34 +244,35 @@ StartUpdateProcess(int argc,
   // Now that we're done with the update, restore back the updater.ini file
   // We use it ourselves, and also we want it back in case we had any type 
   // of error so that the normal update process can use it.
   if (selfHandlePostUpdate) {
     MoveFileExW(updaterINITemp, updaterINI, MOVEFILE_REPLACE_EXISTING);
 
     // Only run the PostUpdate if the update was successful
     if (updateWasSuccessful && argc > 2) {
-      LPCWSTR installationDir = argv[2];
       LPCWSTR updateInfoDir = argv[1];
       bool backgroundUpdate = IsUpdateBeingStaged(argc, argv);
 
       // Launch the PostProcess with admin access in session 0.  This is
       // actually launching the post update process but it takes in the 
       // callback app path to figure out where to apply to.
       // The PostUpdate process with user only access will be done inside
       // the unelevated updater.exe after the update process is complete
       // from the service.  We don't know here which session to start
       // the user PostUpdate process from.
       // Note that we don't need to do this if we're just staging the
       // update in the background, as the PostUpdate step runs when
       // performing the replacing in that case.
       if (!backgroundUpdate) {
         LOG(("Launching post update process as the service in session 0.\n"));
-        if (!LaunchWinPostProcess(installationDir, updateInfoDir, true, NULL)) {
-          LOG(("The post update process could not be launched.\n"));
+        if (!LaunchWinPostProcess(installDir, updateInfoDir, true, NULL)) {
+          LOG(("The post update process could not be launched."
+               " installDir: %ls, updateInfoDir: %ls\n",
+               installDir, updateInfoDir));
         }
       }
     }
   }
 
   free(cmdLine);
   return updateWasSuccessful;
 }
@@ -414,17 +416,17 @@ ProcessSoftwareUpdateCommand(DWORD argc,
 #ifndef DISABLE_UPDATER_AUTHENTICODE_CHECK
   updaterSignProblem = !DoesBinaryMatchAllowedCertificates(installDir,
                                                            argv[0]);
 #endif
 
   // Only proceed with the update if we have no signing problems
   if (!updaterSignProblem) {
     BOOL updateProcessWasStarted = FALSE;
-    if (StartUpdateProcess(argc, argv,
+    if (StartUpdateProcess(argc, argv, installDir,
                            updateProcessWasStarted)) {
       LOG(("updater.exe was launched and run successfully!\n"));
       LogFlush();
 
       // Don't attempt to update the service when the update is being staged.
       if (!IsUpdateBeingStaged(argc, argv)) {
         // We might not execute code after StartServiceUpdate because
         // the service installer will stop the service if it is running.