Bug 758998 - Use the correct installation directory when attempting to upgrade the maintenance service; r=bbondy
authorEhsan Akhgari <ehsan@mozilla.com>
Tue, 29 May 2012 17:31:04 -0400
changeset 95263 3aa566994890824e57e9bcf5d0cd69eb75d9beae
parent 95262 fccdf5c4feda44c01d6d7aa40411571856d1eeff
child 95264 e08f1d2788232a221fdc94764c215d348878a46f
child 95338 7edd4b899696ddf12a2a14aa56269501aa7e5f65
push id22797
push usereakhgari@mozilla.com
push dateThu, 31 May 2012 02:36:21 +0000
treeherdermozilla-central@3aa566994890 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs758998
milestone15.0a1
first release with
nightly linux32
3aa566994890 / 15.0a1 / 20120531030517 / files
nightly linux64
3aa566994890 / 15.0a1 / 20120531030517 / files
nightly mac
3aa566994890 / 15.0a1 / 20120531030517 / files
nightly win32
3aa566994890 / 15.0a1 / 20120531030517 / files
nightly win64
3aa566994890 / 15.0a1 / 20120531030517 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758998 - Use the correct installation directory when attempting to upgrade the maintenance service; r=bbondy
toolkit/components/maintenanceservice/workmonitor.cpp
toolkit/mozapps/update/common/updatehelper.cpp
toolkit/mozapps/update/common/updatehelper.h
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -404,17 +404,17 @@ ProcessSoftwareUpdateCommand(DWORD argc,
     BOOL updateProcessWasStarted = FALSE;
     if (StartUpdateProcess(argc, argv,
                            updateProcessWasStarted)) {
       LOG(("updater.exe was launched and run successfully!\n"));
       LogFlush();
 
       // We might not execute code after StartServiceUpdate because
       // the service installer will stop the service if it is running.
-      StartServiceUpdate(argc, argv);
+      StartServiceUpdate(installDir);
     } else {
       result = FALSE;
       LOG(("Error running update process. Updating update.status"
            " Last error: %d\n", GetLastError()));
       LogFlush();
 
       // If the update process was started, then updater.exe is responsible for
       // setting the failure code.  If it could not be started then we do the 
--- a/toolkit/mozapps/update/common/updatehelper.cpp
+++ b/toolkit/mozapps/update/common/updatehelper.cpp
@@ -179,27 +179,23 @@ LaunchWinPostProcess(const WCHAR *instal
   }
   return ok;
 }
 
 /**
  * Starts the upgrade process for update of the service if it is
  * already installed.
  *
- * @param  argc The argc value normally sent to updater.exe
- * @param  argv The argv value normally sent to updater.exe
+ * @param  installDir the installation directory where
+ *         maintenanceservice_installer.exe is located.
  * @return TRUE if successful
  */
 BOOL
-StartServiceUpdate(int argc, LPWSTR *argv)
+StartServiceUpdate(LPCWSTR installDir)
 {
-  if (argc < 2) {
-    return FALSE;
-  }
-
   // Get a handle to the local computer SCM database
   SC_HANDLE manager = OpenSCManager(NULL, NULL, 
                                     SC_MANAGER_ALL_ACCESS);
   if (!manager) {
     return FALSE;
   }
 
   // Open the service
@@ -217,26 +213,26 @@ StartServiceUpdate(int argc, LPWSTR *arg
 
   STARTUPINFOW si = {0};
   si.cb = sizeof(STARTUPINFOW);
   // No particular desktop because no UI
   si.lpDesktop = L"";
   PROCESS_INFORMATION pi = {0};
 
   WCHAR maintserviceInstallerPath[MAX_PATH + 1];
-  wcscpy(maintserviceInstallerPath, argv[2]);
+  wcscpy(maintserviceInstallerPath, installDir);
   PathAppendSafe(maintserviceInstallerPath, 
                  L"maintenanceservice_installer.exe");
   WCHAR cmdLine[64];
   wcscpy(cmdLine, L"dummyparam.exe /Upgrade");
   BOOL svcUpdateProcessStarted = CreateProcessW(maintserviceInstallerPath, 
                                                 cmdLine, 
                                                 NULL, NULL, FALSE, 
                                                 0, 
-                                                NULL, argv[2], &si, &pi);
+                                                NULL, installDir, &si, &pi);
   if (svcUpdateProcessStarted) {
     CloseHandle(pi.hProcess);
     CloseHandle(pi.hThread);
   }
   return svcUpdateProcessStarted;
 }
 
 #endif 
--- a/toolkit/mozapps/update/common/updatehelper.h
+++ b/toolkit/mozapps/update/common/updatehelper.h
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 BOOL LaunchWinPostProcess(const WCHAR *installationDir,
                           const WCHAR *updateInfoDir, 
                           bool forceSync,
                           HANDLE userToken);
-BOOL StartServiceUpdate(int argc, LPWSTR *argv);
+BOOL StartServiceUpdate(LPCWSTR installDir);
 BOOL GetUpdateDirectoryPath(LPWSTR path);
 DWORD LaunchServiceSoftwareUpdateCommand(int argc, LPCWSTR *argv);
 BOOL WriteStatusFailure(LPCWSTR updateDirPath, int errorCode);
 BOOL WriteStatusPending(LPCWSTR updateDirPath);
 DWORD WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds);
 DWORD WaitForProcessExit(LPCWSTR filename, DWORD maxSeconds);
 BOOL DoesFallbackKeyExist();
 BOOL IsLocalFile(LPCWSTR file, BOOL &isLocal);
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -2749,17 +2749,21 @@ int NS_main(int argc, NS_tchar **argv)
       // because it's possible we are updating with updater.exe without the 
       // service if the service failed to apply the update. We want to update
       // the service to a newer version in that case. If we are not running
       // through the service, then MOZ_USING_SERVICE will not exist.
       if (!usingService) {
         if (!LaunchWinPostProcess(argv[callbackIndex], gSourcePath, false, NULL)) {
           LOG(("NS_main: The post update process could not be launched.\n"));
         }
-        StartServiceUpdate(argc, argv);
+
+        NS_tchar installDir[MAXPATHLEN];
+        if (GetInstallationDir(installDir)) {
+          StartServiceUpdate(installDir);
+        }
       }
     }
     EXIT_WHEN_ELEVATED(elevatedLockFilePath, updateLockFileHandle, 0);
 #endif /* XP_WIN */
 #ifdef XP_MACOSX
     if (gSucceeded) {
       LaunchMacPostProcess(argv[callbackIndex]);
     }