Bug 1457999: Backed out changeset 5d72ee6c1126 due to Linux preprocessor errors; r=backout CLOSED TREE
authorAaron Klotz <aklotz@mozilla.com>
Mon, 07 May 2018 11:00:22 -0600
changeset 417126 82cc108f33b8fb0af5f068a46c0d21cd81e908ed
parent 417125 5d72ee6c1126c4c7d7d372ac2adca609e4dfa545
child 417127 5486a5777bbdecd3da01cbc5c6beee86192fa7aa
push id33961
push userrgurzau@mozilla.com
push dateMon, 07 May 2018 22:08:28 +0000
treeherdermozilla-central@59005ba3cd3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1457999
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457999: Backed out changeset 5d72ee6c1126 due to Linux preprocessor errors; r=backout CLOSED TREE
toolkit/components/maintenanceservice/workmonitor.cpp
toolkit/mozapps/update/updater/updater.cpp
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -9,17 +9,16 @@
 #include <shellapi.h>
 
 #pragma comment(lib, "wtsapi32.lib")
 #pragma comment(lib, "userenv.lib")
 #pragma comment(lib, "shlwapi.lib")
 #pragma comment(lib, "ole32.lib")
 #pragma comment(lib, "rpcrt4.lib")
 
-#include "mozilla/CmdLineAndEnvUtils.h"
 #include "nsWindowsHelpers.h"
 
 #include "workmonitor.h"
 #include "serviceinstall.h"
 #include "servicebase.h"
 #include "registrycertificates.h"
 #include "uachelper.h"
 #include "updatehelper.h"
@@ -27,16 +26,17 @@
 #include "errors.h"
 
 #define PATCH_DIR_PATH L"\\updates\\0"
 
 // Wait 15 minutes for an update operation to run at most.
 // Updates usually take less than a minute so this seems like a
 // significantly large and safe amount of time to wait.
 static const int TIME_TO_WAIT_ON_UPDATER = 15 * 60 * 1000;
+wchar_t* MakeCommandLine(int argc, wchar_t** argv);
 BOOL WriteStatusFailure(LPCWSTR updateDirPath, int errorCode);
 BOOL PathGetSiblingFilePath(LPWSTR destinationBuffer,  LPCWSTR siblingFilePath,
                             LPCWSTR newFileName);
 BOOL DoesFallbackKeyExist();
 
 /*
  * Read the update.status file and sets isApplying to true if
  * the status is set to applying.
@@ -185,17 +185,17 @@ StartUpdateProcess(int argc,
   LOG(("Starting update process as the service in session 0."));
   STARTUPINFO si = {0};
   si.cb = sizeof(STARTUPINFO);
   si.lpDesktop = L"winsta0\\Default";
   PROCESS_INFORMATION pi = {0};
 
   // The updater command line is of the form:
   // updater.exe update-dir apply [wait-pid [callback-dir callback-path args]]
-  auto cmdLine = mozilla::MakeCommandLine(argc, argv);
+  LPWSTR cmdLine = MakeCommandLine(argc, argv);
 
   int index = 3;
   if (IsOldCommandline(argc, argv)) {
     index = 2;
   }
 
   // If we're about to start the update process from session 0,
   // then we should not show a GUI.  This only really needs to be done
@@ -207,18 +207,18 @@ StartUpdateProcess(int argc,
     si.dwFlags |= STARTF_USESHOWWINDOW;
     si.wShowWindow = SW_HIDE;
   }
 
   // Add an env var for MOZ_USING_SERVICE so the updater.exe can
   // do anything special that it needs to do for service updates.
   // Search in updater.cpp for more info on MOZ_USING_SERVICE.
   putenv(const_cast<char*>("MOZ_USING_SERVICE=1"));
-  LOG(("Starting service with cmdline: %ls", cmdLine.get()));
-  processStarted = CreateProcessW(argv[0], cmdLine.get(),
+  LOG(("Starting service with cmdline: %ls", cmdLine));
+  processStarted = CreateProcessW(argv[0], cmdLine,
                                   nullptr, nullptr, FALSE,
                                   CREATE_DEFAULT_ERROR_MODE,
                                   nullptr,
                                   nullptr, &si, &pi);
 
   BOOL updateWasSuccessful = FALSE;
   if (processStarted) {
     BOOL processTerminated = FALSE;
@@ -274,22 +274,23 @@ StartUpdateProcess(int argc,
                     "failure error."));
         }
       }
     }
   } else {
     DWORD lastError = GetLastError();
     LOG_WARN(("Could not create process as current user, "
               "updaterPath: %ls; cmdLine: %ls.  (%d)",
-              argv[0], cmdLine.get(), lastError));
+              argv[0], cmdLine, lastError));
   }
 
   // Empty value on putenv is how you remove an env variable in Windows
   putenv(const_cast<char*>("MOZ_USING_SERVICE="));
 
+  free(cmdLine);
   return updateWasSuccessful;
 }
 
 /**
  * Validates a file as an official updater.
  *
  * @param updater     Path to the updater to validate
  * @param installDir  Path to the application installation
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -3099,17 +3099,17 @@ int NS_main(int argc, NS_tchar **argv)
                                        FILE_FLAG_DELETE_ON_CLOSE,
                                        nullptr);
 
       if (elevatedFileHandle == INVALID_HANDLE_VALUE) {
         LOG(("Unable to create elevated lock file! Exiting"));
         return 1;
       }
 
-      auto cmdLine = mozilla::MakeCommandLine(argc - 1, argv + 1);
+      wchar_t *cmdLine = MakeCommandLine(argc - 1, argv + 1);
       if (!cmdLine) {
         CloseHandle(elevatedFileHandle);
         return 1;
       }
 
       // Make sure the path to the updater to use for the update is on local.
       // We do this check to make sure that file locking is available for
       // race condition security checks.
@@ -3245,21 +3245,22 @@ int NS_main(int argc, NS_tchar **argv)
         SHELLEXECUTEINFO sinfo;
         memset(&sinfo, 0, sizeof(SHELLEXECUTEINFO));
         sinfo.cbSize       = sizeof(SHELLEXECUTEINFO);
         sinfo.fMask        = SEE_MASK_FLAG_NO_UI |
                              SEE_MASK_FLAG_DDEWAIT |
                              SEE_MASK_NOCLOSEPROCESS;
         sinfo.hwnd         = nullptr;
         sinfo.lpFile       = argv[0];
-        sinfo.lpParameters = cmdLine.get();
+        sinfo.lpParameters = cmdLine;
         sinfo.lpVerb       = L"runas";
         sinfo.nShow        = SW_SHOWNORMAL;
 
         bool result = ShellExecuteEx(&sinfo);
+        free(cmdLine);
 
         if (result) {
           WaitForSingleObject(sinfo.hProcess, INFINITE);
           CloseHandle(sinfo.hProcess);
         } else {
           WriteStatusFile(ELEVATION_CANCELED);
         }
       }