Bug 709598 - If no registry keys exist for the install dir, don't try to use the maintenance service for updates. r=rstrong.
--- a/toolkit/components/maintenanceservice/Makefile.in
+++ b/toolkit/components/maintenanceservice/Makefile.in
@@ -44,17 +44,16 @@ include $(DEPTH)/config/autoconf.mk
CPPSRCS = \
maintenanceservice.cpp \
serviceinstall.cpp \
workmonitor.cpp \
certificatecheck.cpp \
servicebase.cpp \
registrycertificates.cpp \
- pathhash.cpp \
$(NULL)
# For debugging purposes only
#DEFINES += -DDISABLE_UPDATER_AUTHENTICODE_CHECK
PROGRAM = maintenanceservice$(BIN_SUFFIX)
DIST_PROGRAM = maintenanceservice$(BIN_SUFFIX)
--- a/toolkit/mozapps/update/common/Makefile.in
+++ b/toolkit/mozapps/update/common/Makefile.in
@@ -56,17 +56,19 @@ CPPSRCS = \
EXPORTS = updatelogging.h \
updatedefines.h \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
CPPSRCS += updatehelper.cpp \
uachelper.cpp \
+ pathhash.cpp \
$(NULL)
EXPORTS = updatehelper.h \
uachelper.h \
+ pathhash.h \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk
rename from toolkit/components/maintenanceservice/pathhash.cpp
rename to toolkit/mozapps/update/common/pathhash.cpp
rename from toolkit/components/maintenanceservice/pathhash.h
rename to toolkit/mozapps/update/common/pathhash.h
--- a/toolkit/mozapps/update/updater/updater.cpp
+++ b/toolkit/mozapps/update/updater/updater.cpp
@@ -1378,16 +1378,17 @@ PatchIfFile::Finish(int status)
PatchFile::Finish(status);
}
//-----------------------------------------------------------------------------
#ifdef XP_WIN
#include "nsWindowsRestart.cpp"
#include "uachelper.h"
+#include "pathhash.h"
#endif
static void
LaunchCallbackApp(const NS_tchar *workingDir, int argc, NS_tchar **argv)
{
putenv(const_cast<char*>("NO_EM_RESTART="));
putenv(const_cast<char*>("MOZ_LAUNCHED_CHILD=1"));
@@ -1710,16 +1711,42 @@ int NS_main(int argc, NS_tchar **argv)
}
PRUnichar *cmdLine = MakeCommandLine(argc - 1, argv + 1);
if (!cmdLine) {
CloseHandle(elevatedFileHandle);
return 1;
}
+ // Make sure the service registry entries for the instsallation path
+ // are available. If not don't use the service.
+ if (useService) {
+ WCHAR maintenanceServiceKey[MAX_PATH + 1];
+ if (CalculateRegistryPathFromFilePath(argv[2], maintenanceServiceKey)) {
+ HKEY baseKey;
+ LSTATUS retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ maintenanceServiceKey, 0,
+ KEY_READ | KEY_WOW64_64KEY,
+ &baseKey);
+ if (retCode != ERROR_SUCCESS) {
+ // Our tests run with a different apply directory for each test.
+ // We use this registry key on our test slaves to store the
+ // allowed name/issuers.
+ retCode = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
+ L"SOFTWARE\\Mozilla\\MaintenanceService"
+ L"\\3932ecacee736d366d6436db0f55bce4", 0,
+ KEY_READ | KEY_WOW64_64KEY, &baseKey);
+ }
+ useService = retCode == ERROR_SUCCESS;
+ RegCloseKey(baseKey);
+ } else {
+ useService = FALSE;
+ }
+ }
+
HANDLE serviceInUseEvent = NULL;
if (useService) {
// Make sure the service isn't already busy processing another work item.
// This event will also be used by the service who will signal it when
// it is done with the udpate.
serviceInUseEvent = CreateEventW(NULL, TRUE,
FALSE, SERVICE_EVENT_NAME);