mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 711054 - Stop using readstrings errors for updater. r=rstrong
--HG-- rename : toolkit/mozapps/readstrings/errors.h => toolkit/mozapps/update/common/errors.h rename : toolkit/mozapps/readstrings/readstrings.cpp => toolkit/mozapps/update/common/readstrings.cpp rename : toolkit/mozapps/readstrings/readstrings.h => toolkit/mozapps/update/common/readstrings.h
This commit is contained in:
parent
3612e788bd
commit
22c90e2a57
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 <http://www.mozilla.org/>. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brad Lassey <blassey@mozilla.com> (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
|
@ -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
|
||||
|
@ -52,10 +52,12 @@ endif
|
||||
|
||||
CPPSRCS = \
|
||||
updatelogging.cpp \
|
||||
readstrings.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = updatelogging.h \
|
||||
updatedefines.h \
|
||||
readstrings.h \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
|
||||
|
@ -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
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -31,6 +31,9 @@
|
||||
# define NS_ttoi _wtoi
|
||||
# define NS_tstat _wstat
|
||||
# define LOG_S "%S"
|
||||
|
||||
#include "../common/updatehelper.h"
|
||||
|
||||
#else
|
||||
# include <unistd.h>
|
||||
# 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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user