diff --git a/toolkit/components/maintenanceservice/Makefile.in b/toolkit/components/maintenanceservice/Makefile.in
index 7b7c5d30dc9e..524e54542bb5 100644
--- a/toolkit/components/maintenanceservice/Makefile.in
+++ b/toolkit/components/maintenanceservice/Makefile.in
@@ -64,7 +64,6 @@ MOZ_GLUE_PROGRAM_LDFLAGS =
LIBS += \
../../mozapps/update/common/$(LIB_PREFIX)updatecommon.$(LIB_SUFFIX) \
- ../../mozapps/readstrings/$(LIB_PREFIX)readstrings.$(LIB_SUFFIX) \
$(NULL)
USE_STATIC_LIBS = 1
@@ -98,5 +97,4 @@ endif
# Pick up nsWindowsRestart.cpp
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre \
-I$(topsrcdir)/toolkit/mozapps/update/common \
- -I$(topsrcdir)/toolkit/mozapps/readstrings \
$(NULL)
diff --git a/toolkit/components/maintenanceservice/workmonitor.cpp b/toolkit/components/maintenanceservice/workmonitor.cpp
index f5efb257d1d5..3ad4dab16843 100644
--- a/toolkit/components/maintenanceservice/workmonitor.cpp
+++ b/toolkit/components/maintenanceservice/workmonitor.cpp
@@ -56,6 +56,7 @@
#include "registrycertificates.h"
#include "uachelper.h"
#include "updatehelper.h"
+#include "errors.h"
// Wait 15 minutes for an update operation to run at most.
// Updates usually take less than a minute so this seems like a
@@ -66,16 +67,6 @@ BOOL WriteStatusFailure(LPCWSTR updateDirPath, int errorCode);
BOOL PathGetSiblingFilePath(LPWSTR destinationBuffer, LPCWSTR siblingFilePath,
LPCWSTR newFileName);
-// The error codes start from 16000 since Windows system error
-// codes only go up to 15999
-const int SERVICE_UPDATER_COULD_NOT_BE_STARTED = 16000;
-const int SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS = 16001;
-const int SERVICE_UPDATER_SIGN_ERROR = 16002;
-const int SERVICE_UPDATER_COMPARE_ERROR = 16003;
-const int SERVICE_UPDATER_IDENTITY_ERROR = 16004;
-const int SERVICE_STILL_APPLYING_ON_SUCCESS = 16005;
-const int SERVICE_STILL_APPLYING_ON_FAILURE = 16006;
-
/*
* Read the update.status file and sets isApplying to true if
* the status is set to applying
diff --git a/toolkit/mozapps/readstrings/Makefile.in b/toolkit/mozapps/readstrings/Makefile.in
deleted file mode 100644
index 8a69fb33cd85..000000000000
--- a/toolkit/mozapps/readstrings/Makefile.in
+++ /dev/null
@@ -1,54 +0,0 @@
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is Mozilla readstrings
-#
-# The Initial Developer of the Original Code is The Mozilla Foundation.
-#
-# Portions created by the Initial Developer are Copyright (C) 2009
-# the Mozilla Foundation . All Rights Reserved.
-#
-# Contributor(s):
-# Brad Lassey (original author)
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either the GNU General Public License Version 2 or later (the "GPL"), or
-# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
-# in which case the provisions of the GPL or the LGPL are applicable instead
-# of those above. If you wish to allow use of your version of this file only
-# under the terms of either the GPL or the LGPL, and not to allow others to
-# use your version of this file under the terms of the MPL, indicate your
-# decision by deleting the provisions above and replace them with the notice
-# and other provisions required by the GPL or the LGPL. If you do not delete
-# the provisions above, a recipient may use your version of this file under
-# the terms of any one of the MPL, the GPL or the LGPL.
-#
-# ***** END LICENSE BLOCK *****
-
-DEPTH = ../../..
-topsrcdir = @top_srcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(DEPTH)/config/autoconf.mk
-
-MODULE = readstrings
-LIBRARY_NAME = readstrings
-FORCE_STATIC_LIB = 1
-export NO_SHUNT = 1
-USE_STATIC_LIBS = 1
-
-CPPSRCS = readstrings.cpp
-EXPORTS = readstrings.h
-
-include $(topsrcdir)/config/rules.mk
diff --git a/toolkit/mozapps/update/Makefile.in b/toolkit/mozapps/update/Makefile.in
index 752647bbad05..432046a9b40a 100644
--- a/toolkit/mozapps/update/Makefile.in
+++ b/toolkit/mozapps/update/Makefile.in
@@ -49,8 +49,6 @@ XPIDLSRCS = nsIUpdateTimerManager.idl
EXTRA_PP_COMPONENTS = nsUpdateTimerManager.js nsUpdateTimerManager.manifest
ifdef MOZ_UPDATER
-DIRS = ../readstrings
-
ifneq ($(OS_TARGET),Android)
DIRS += common
DIRS += updater
@@ -70,7 +68,6 @@ else
# used for other things. We need to build update/common
# which the maintenance service uses.
ifdef MOZ_MAINTENANCE_SERVICE
-DIRS = ../readstrings
ifneq ($(OS_TARGET),Android)
DIRS += common
endif
diff --git a/toolkit/mozapps/update/common/Makefile.in b/toolkit/mozapps/update/common/Makefile.in
index d7b91bbc5aa8..242b7a5ec9d9 100644
--- a/toolkit/mozapps/update/common/Makefile.in
+++ b/toolkit/mozapps/update/common/Makefile.in
@@ -52,10 +52,12 @@ endif
CPPSRCS = \
updatelogging.cpp \
+ readstrings.cpp \
$(NULL)
EXPORTS = updatelogging.h \
updatedefines.h \
+ readstrings.h \
$(NULL)
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
diff --git a/toolkit/mozapps/readstrings/errors.h b/toolkit/mozapps/update/common/errors.h
similarity index 82%
rename from toolkit/mozapps/readstrings/errors.h
rename to toolkit/mozapps/update/common/errors.h
index 7a156b42053d..9fc8e7ed6642 100644
--- a/toolkit/mozapps/readstrings/errors.h
+++ b/toolkit/mozapps/update/common/errors.h
@@ -40,8 +40,12 @@
#define Errors_h__
#define OK 0
-//#define MEM_ERROR 1 // Replaced with errors 10-16 (inclusive)
+
+// Old unused error codes:
+// #define MEM_ERROR 1 // Replaced with errors 10-16 (inclusive)
// #define IO_ERROR 2 // Use READ_ERROR or WRITE_ERROR instead
+
+// Error codes 3-16 are for general update problems.
#define USAGE_ERROR 3
#define CRC_ERROR 4
#define PARSE_ERROR 5
@@ -56,6 +60,9 @@
#define UPDATER_QUOTED_PATH_MEM_ERROR 14
#define BAD_ACTION_ERROR 15
#define STRING_CONVERSION_ERROR 16
+
+// Error codes 17-23 are related to security tasks for MAR
+// signing and MAR protection.
#define CERT_LOAD_ERROR 17
#define CERT_HANDLING_ERROR 18
#define CERT_VERIFY_ERROR 19
@@ -64,6 +71,16 @@
#define MAR_CHANNEL_MISMATCH_ERROR 22
#define VERSION_DOWNGRADE_ERROR 23
+// Error codes 24-30 are related to the maintenance service
+// and so are Windows only
+#define SERVICE_UPDATER_COULD_NOT_BE_STARTED 24
+#define SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS 25
+#define SERVICE_UPDATER_SIGN_ERROR 26
+#define SERVICE_UPDATER_COMPARE_ERROR 27
+#define SERVICE_UPDATER_IDENTITY_ERROR 28
+#define SERVICE_STILL_APPLYING_ON_SUCCESS 29
+#define SERVICE_STILL_APPLYING_ON_FAILURE 30
+
// The following error codes are only used by updater.exe
// when a fallback key exists and XPCShell tests are being run.
#define FALLBACKKEY_UNKNOWN_ERROR 100
diff --git a/toolkit/mozapps/readstrings/readstrings.cpp b/toolkit/mozapps/update/common/readstrings.cpp
similarity index 100%
rename from toolkit/mozapps/readstrings/readstrings.cpp
rename to toolkit/mozapps/update/common/readstrings.cpp
diff --git a/toolkit/mozapps/readstrings/readstrings.h b/toolkit/mozapps/update/common/readstrings.h
similarity index 100%
rename from toolkit/mozapps/readstrings/readstrings.h
rename to toolkit/mozapps/update/common/readstrings.h
diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js
index 2e57bea7a333..bd8b5fa2d9e6 100644
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -143,13 +143,13 @@ const UNEXPECTED_ERROR = 8;
const ELEVATION_CANCELED = 9;
// Windows service specific errors
-const SERVICE_UPDATER_COULD_NOT_BE_STARTED = 16000;
-const SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS = 16001;
-const SERVICE_UPDATER_SIGN_ERROR = 16002;
-const SERVICE_UPDATER_COMPARE_ERROR = 16003;
-const SERVICE_UPDATER_IDENTITY_ERROR = 16004;
-const SERVICE_STILL_APPLYING_ON_SUCCESS = 16005;
-const SERVICE_STILL_APPLYING_ON_FAILURE = 16006;
+const SERVICE_UPDATER_COULD_NOT_BE_STARTED = 24;
+const SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS = 25;
+const SERVICE_UPDATER_SIGN_ERROR = 26;
+const SERVICE_UPDATER_COMPARE_ERROR = 27;
+const SERVICE_UPDATER_IDENTITY_ERROR = 28;
+const SERVICE_STILL_APPLYING_ON_SUCCESS = 29;
+const SERVICE_STILL_APPLYING_ON_FAILURE = 30;
const CERT_ATTR_CHECK_FAILED_NO_UPDATE = 100;
const CERT_ATTR_CHECK_FAILED_HAS_UPDATE = 101;
diff --git a/toolkit/mozapps/update/test/Makefile.in b/toolkit/mozapps/update/test/Makefile.in
index 6fefd7761215..17ceb9499ecd 100644
--- a/toolkit/mozapps/update/test/Makefile.in
+++ b/toolkit/mozapps/update/test/Makefile.in
@@ -84,7 +84,7 @@ LOCAL_INCLUDES += \
MOZ_WINCONSOLE = 1
LIBS += \
- ../../readstrings/$(LIB_PREFIX)readstrings.$(LIB_SUFFIX) \
+ ../common/$(LIB_PREFIX)updatecommon.$(LIB_SUFFIX) \
$(NULL)
ifeq ($(OS_ARCH),WINNT)
diff --git a/toolkit/mozapps/update/test/TestAUSHelper.cpp b/toolkit/mozapps/update/test/TestAUSHelper.cpp
index 5a0983388758..e6405a777cc8 100644
--- a/toolkit/mozapps/update/test/TestAUSHelper.cpp
+++ b/toolkit/mozapps/update/test/TestAUSHelper.cpp
@@ -31,6 +31,9 @@
# define NS_ttoi _wtoi
# define NS_tstat _wstat
# define LOG_S "%S"
+
+#include "../common/updatehelper.h"
+
#else
# include
# define NS_main main
@@ -153,214 +156,6 @@ VerifyCertificateTrustForFile(LPCWSTR filePath)
return WinVerifyTrust(NULL, &policyGUID, &trustData);
}
-/**
- * Waits for a service to enter a stopped state.
- * This function does not stop the service, it just blocks until the service
- * is stopped.
- *
- * @param serviceName The service to wait for.
- * @param maxWaitSeconds The maximum number of seconds to wait
- * @return state of the service after a timeout or when stopped.
- * A value of 255 is returned for an error. Typical values are:
- * SERVICE_STOPPED 0x00000001
- * SERVICE_START_PENDING 0x00000002
- * SERVICE_STOP_PENDING 0x00000003
- * SERVICE_RUNNING 0x00000004
- * SERVICE_CONTINUE_PENDING 0x00000005
- * SERVICE_PAUSE_PENDING 0x00000006
- * SERVICE_PAUSED 0x00000007
- * last status not set 0x000000CF
- * Could no query status 0x000000DF
- * Could not open service, access denied 0x000000EB
- * Could not open service, invalid handle 0x000000EC
- * Could not open service, invalid name 0x000000ED
- * Could not open service, does not exist 0x000000EE
- * Could not open service, other error 0x000000EF
- * Could not open SCM, access denied 0x000000FD
- * Could not open SCM, database does not exist 0x000000FE;
- * Could not open SCM, other error 0x000000FF;
- * Note: The strange choice of error codes above SERVICE_PAUSED are chosen
- * in case Windows comes out with other service stats higher than 7, they
- * would likely call it 8 and above. JS code that uses this in TestAUSHelper
- * only handles values up to 255 so that's why we don't use GetLastError
- * directly.
- */
-DWORD
-WaitForServiceStop(LPCWSTR serviceName, DWORD maxWaitSeconds)
-{
- // 0x000000CF is defined above to be not set
- DWORD lastServiceState = 0x000000CF;
-
- // Get a handle to the SCM database.
- SC_HANDLE serviceManager = OpenSCManager(NULL, NULL,
- SC_MANAGER_CONNECT |
- SC_MANAGER_ENUMERATE_SERVICE);
- if (!serviceManager) {
- DWORD lastError = GetLastError();
- switch(lastError) {
- case ERROR_ACCESS_DENIED:
- return 0x000000FD;
- case ERROR_DATABASE_DOES_NOT_EXIST:
- return 0x000000FE;
- default:
- return 0x000000FF;
- }
- }
-
- // Get a handle to the service.
- SC_HANDLE service = OpenServiceW(serviceManager,
- serviceName,
- SERVICE_QUERY_STATUS);
- if (!service) {
- DWORD lastError = GetLastError();
- CloseServiceHandle(serviceManager);
- switch(lastError) {
- case ERROR_ACCESS_DENIED:
- return 0x000000EB;
- case ERROR_INVALID_HANDLE:
- return 0x000000EC;
- case ERROR_INVALID_NAME:
- return 0x000000ED;
- // If the service does not exist, keep trying in case it does exist soon.
- // I think there might be an issue with the TALOS machines and some of
- // the machines having an old maintenanceservice.exe that used to
- // uninstall when upgrading. Those should already be upgraded but this
- // is safer.
- case ERROR_SERVICE_DOES_NOT_EXIST:
- if (maxWaitSeconds == 0) {
- return 0x000000EE;
- } else {
- Sleep(1000);
- return WaitForServiceStop(serviceName, maxWaitSeconds - 1);
- }
- default:
- return 0x000000EF;
- }
- }
-
- DWORD currentWaitMS = 0;
- SERVICE_STATUS_PROCESS ssp;
- ssp.dwCurrentState = lastServiceState;
- while (currentWaitMS < maxWaitSeconds * 1000) {
- DWORD bytesNeeded;
- if (!QueryServiceStatusEx(service, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp,
- sizeof(SERVICE_STATUS_PROCESS), &bytesNeeded)) {
- DWORD lastError = GetLastError();
- switch (lastError) {
- case ERROR_INVALID_HANDLE:
- ssp.dwCurrentState = 0x000000D9;
- break;
- case ERROR_ACCESS_DENIED:
- ssp.dwCurrentState = 0x000000DA;
- break;
- case ERROR_INSUFFICIENT_BUFFER:
- ssp.dwCurrentState = 0x000000DB;
- break;
- case ERROR_INVALID_PARAMETER:
- ssp.dwCurrentState = 0x000000DC;
- break;
- case ERROR_INVALID_LEVEL:
- ssp.dwCurrentState = 0x000000DD;
- break;
- case ERROR_SHUTDOWN_IN_PROGRESS:
- ssp.dwCurrentState = 0x000000DE;
- break;
- // These 3 errors can occur when the service is not yet stopped but
- // it is stopping.
- case ERROR_INVALID_SERVICE_CONTROL:
- case ERROR_SERVICE_CANNOT_ACCEPT_CTRL:
- case ERROR_SERVICE_NOT_ACTIVE:
- currentWaitMS += 50;
- Sleep(50);
- continue;
- default:
- ssp.dwCurrentState = 0x000000DF;
- }
-
- // We couldn't query the status so just break out
- break;
- }
-
- // The service is already in use.
- if (ssp.dwCurrentState == SERVICE_STOPPED) {
- break;
- }
- currentWaitMS += 50;
- Sleep(50);
- }
-
- lastServiceState = ssp.dwCurrentState;
- CloseServiceHandle(service);
- CloseServiceHandle(serviceManager);
- return lastServiceState;
-}
-
-/**
- * Determines if there is at least one process running for the specified
- * application. A match will be found across any session for any user.
- *
- * @param process The process to check for existance
- * @return ERROR_NOT_FOUND if the process was not found
- * @ ERROR_SUCCESS if the process was found and there were no errors
- * @ Other Win32 system error code for other errors
-**/
-DWORD
-IsProcessRunning(LPCWSTR filename)
-{
- // Take a snapshot of all processes in the system.
- HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
- if (INVALID_HANDLE_VALUE == snapshot) {
- return GetLastError();
- }
-
- PROCESSENTRY32W processEntry;
- processEntry.dwSize = sizeof(PROCESSENTRY32W);
- if (!Process32FirstW(snapshot, &processEntry)) {
- DWORD lastError = GetLastError();
- CloseHandle(snapshot);
- return lastError;
- }
-
- do {
- if (wcsicmp(filename, processEntry.szExeFile) == 0) {
- CloseHandle(snapshot);
- return ERROR_SUCCESS;
- }
- } while (Process32NextW(snapshot, &processEntry));
- CloseHandle(snapshot);
- return ERROR_NOT_FOUND;
-}
-
-/**
- * Waits for the specified applicaiton to exit.
- *
- * @param filename The application to wait for.
- * @param maxSeconds The maximum amount of seconds to wait for all
- * instances of the application to exit.
- * @return ERROR_SUCCESS if no instances of the application exist
- * WAIT_TIMEOUT if the process is still running after maxSeconds.
- * Any other Win32 system error code.
-*/
-DWORD
-WaitForProcessExit(LPCWSTR filename, DWORD maxSeconds)
-{
- DWORD applicationRunningError = WAIT_TIMEOUT;
- for(DWORD i = 0; i < maxSeconds; i++) {
- DWORD applicationRunningError = IsProcessRunning(filename);
- if (ERROR_NOT_FOUND == applicationRunningError) {
- return ERROR_SUCCESS;
- }
- Sleep(1000);
- }
-
- if (ERROR_SUCCESS == applicationRunningError) {
- return WAIT_TIMEOUT;
- }
-
- return applicationRunningError;
-}
-
-
#endif
int NS_main(int argc, NS_tchar **argv)
diff --git a/toolkit/mozapps/update/test/TestAUSReadStrings.cpp b/toolkit/mozapps/update/test/TestAUSReadStrings.cpp
index 335cc228695c..77cfeb51e6f1 100644
--- a/toolkit/mozapps/update/test/TestAUSReadStrings.cpp
+++ b/toolkit/mozapps/update/test/TestAUSReadStrings.cpp
@@ -65,8 +65,8 @@
#include "updater/resource.h"
#include "updater/progressui.h"
-#include "../../readstrings/readstrings.h"
-#include "../../readstrings/errors.h"
+#include "common/readstrings.h"
+#include "common/errors.h"
#ifndef MAXPATHLEN
# ifdef PATH_MAX
diff --git a/toolkit/mozapps/update/updater/Makefile.in b/toolkit/mozapps/update/updater/Makefile.in
index d7321f5bf385..990ff477e11e 100644
--- a/toolkit/mozapps/update/updater/Makefile.in
+++ b/toolkit/mozapps/update/updater/Makefile.in
@@ -55,13 +55,13 @@ PROGRAM = updater$(BIN_SUFFIX)
MOZ_GLUE_LDFLAGS =
MOZ_GLUE_PROGRAM_LDFLAGS =
-LOCAL_INCLUDES += -I$(srcdir)/../../readstrings \
- -I$(srcdir)/../common
+LOCAL_INCLUDES += \
+ -I$(srcdir)/../common \
+ $(NULL)
LIBS += \
../common/$(LIB_PREFIX)updatecommon.$(LIB_SUFFIX) \
$(DEPTH)/modules/libmar/src/$(LIB_PREFIX)mar.$(LIB_SUFFIX) \
- ../../readstrings/$(LIB_PREFIX)readstrings.$(LIB_SUFFIX) \
$(BZ2_LIBS) \
$(NULL)
diff --git a/toolkit/toolkit-makefiles.sh b/toolkit/toolkit-makefiles.sh
index 6c91aa5633b9..f3d3138e70fb 100644
--- a/toolkit/toolkit-makefiles.sh
+++ b/toolkit/toolkit-makefiles.sh
@@ -1377,17 +1377,6 @@ if [ "$MOZ_UPDATER" ]; then
fi
fi
-if [ "$MOZ_UPDATER" -o "$MOZ_MAINTENANCE_SERVICE" ]; then
- add_makefiles "
- toolkit/mozapps/readstrings/Makefile
- "
- if [ "$OS_TARGET" != "Android" ]; then
- add_makefiles "
- toolkit/mozapps/update/common/Makefile
- "
- fi
-fi
-
if [ "$MOZ_UPDATER" -o "$MOZ_UPDATE_PACKAGING" ]; then
add_makefiles "
other-licenses/bsdiff/Makefile