зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1246972 - Always require the update working directory to be within the installation path; r=rstrong
This required fixing a few chrome tests which broke on Mac because they were assuming updater-settings.ini would be at the same location as the executables. Also, this patch removes many dependencies on the current working directory from updater.cpp by changing it to use absolute paths instead. Otherwise this patch would have required adding yet more chdir() calls to avoid invalidating existing assumptions about what the current directory is. MozReview-Commit-ID: ASxfV4uVpmD --HG-- extra : source : 91b303801c0d20c5a7962e40e5d9dde4cbf37911
This commit is contained in:
Родитель
37f7205455
Коммит
ef6bd6dd59
|
@ -83,8 +83,9 @@
|
|||
#define WRITE_ERROR_DELETE_BACKUP 69
|
||||
#define WRITE_ERROR_EXTRACT 70
|
||||
#define REMOVE_FILE_SPEC_ERROR 71
|
||||
#define INVALID_STAGED_PARENT_ERROR 72
|
||||
#define INVALID_APPLYTO_DIR_STAGED_ERROR 72
|
||||
#define LOCK_ERROR_PATCH_FILE 73
|
||||
#define INVALID_APPLYTO_DIR_ERROR 74
|
||||
|
||||
// Error codes 80 through 99 are reserved for nsUpdateService.js
|
||||
|
||||
|
|
|
@ -621,7 +621,7 @@ function verifyTestsRan() {
|
|||
*/
|
||||
function setupFiles() {
|
||||
// Backup the updater-settings.ini file if it exists by moving it.
|
||||
let baseAppDir = getAppBaseDir();
|
||||
let baseAppDir = getGREDir();
|
||||
let updateSettingsIni = baseAppDir.clone();
|
||||
updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
|
||||
if (updateSettingsIni.exists()) {
|
||||
|
@ -776,7 +776,7 @@ function setupPrefs() {
|
|||
*/
|
||||
function resetFiles() {
|
||||
// Restore the backed up updater-settings.ini if it exists.
|
||||
let baseAppDir = getAppBaseDir();
|
||||
let baseAppDir = getGREDir();
|
||||
let updateSettingsIni = baseAppDir.clone();
|
||||
updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI_BAK);
|
||||
if (updateSettingsIni.exists()) {
|
||||
|
|
|
@ -35,12 +35,14 @@ const STATE_SUCCEEDED = "succeeded";
|
|||
const STATE_DOWNLOAD_FAILED = "download-failed";
|
||||
const STATE_FAILED = "failed";
|
||||
|
||||
const LOADSOURCE_ERROR_WRONG_SIZE = 2;
|
||||
const CRC_ERROR = 4;
|
||||
const READ_ERROR = 6;
|
||||
const WRITE_ERROR = 7;
|
||||
const MAR_CHANNEL_MISMATCH_ERROR = 22;
|
||||
const VERSION_DOWNGRADE_ERROR = 23;
|
||||
const LOADSOURCE_ERROR_WRONG_SIZE = 2;
|
||||
const CRC_ERROR = 4;
|
||||
const READ_ERROR = 6;
|
||||
const WRITE_ERROR = 7;
|
||||
const MAR_CHANNEL_MISMATCH_ERROR = 22;
|
||||
const VERSION_DOWNGRADE_ERROR = 23;
|
||||
const INVALID_APPLYTO_DIR_STAGED_ERROR = 72;
|
||||
const INVALID_APPLYTO_DIR_ERROR = 74;
|
||||
|
||||
const STATE_FAILED_DELIMETER = ": ";
|
||||
|
||||
|
@ -56,6 +58,10 @@ const STATE_FAILED_MAR_CHANNEL_MISMATCH_ERROR =
|
|||
STATE_FAILED + STATE_FAILED_DELIMETER + MAR_CHANNEL_MISMATCH_ERROR;
|
||||
const STATE_FAILED_VERSION_DOWNGRADE_ERROR =
|
||||
STATE_FAILED + STATE_FAILED_DELIMETER + VERSION_DOWNGRADE_ERROR;
|
||||
const STATE_FAILED_INVALID_APPLYTO_DIR_STAGED_ERROR =
|
||||
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_APPLYTO_DIR_STAGED_ERROR;
|
||||
const STATE_FAILED_INVALID_APPLYTO_DIR_ERROR =
|
||||
STATE_FAILED + STATE_FAILED_DELIMETER + INVALID_APPLYTO_DIR_ERROR;
|
||||
|
||||
/**
|
||||
* Constructs a string representing a remote update xml file.
|
||||
|
|
|
@ -155,6 +155,8 @@ var gGREDirOrig;
|
|||
var gGREBinDirOrig;
|
||||
var gAppDirOrig;
|
||||
|
||||
var gApplyToDirOverride;
|
||||
|
||||
var gServiceLaunchedCallbackLog = null;
|
||||
var gServiceLaunchedCallbackArgs = null;
|
||||
|
||||
|
@ -1137,6 +1139,18 @@ function getAppVersion() {
|
|||
return iniParser.getString("App", "Version");
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the apply-to directory parameter to be passed to the updater.
|
||||
* This ought to cause the updater to fail when using any value that isn't the
|
||||
* default, automatically computed one.
|
||||
*
|
||||
* @param dir
|
||||
* Complete string to use as the apply-to directory parameter.
|
||||
*/
|
||||
function overrideApplyToDir(dir) {
|
||||
gApplyToDirOverride = dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for getting the relative path to the directory where the
|
||||
* application binary is located (e.g. <test_file_leafname>/dir.app/).
|
||||
|
@ -1706,10 +1720,10 @@ function runUpdateUsingUpdater(aExpectedStatus, aSwitchApp, aExpectedExitValue)
|
|||
|
||||
let args = [updatesDirPath, applyToDirPath];
|
||||
if (aSwitchApp) {
|
||||
args[2] = stageDirPath;
|
||||
args[2] = gApplyToDirOverride || stageDirPath;
|
||||
args[3] = "0/replace";
|
||||
} else {
|
||||
args[2] = applyToDirPath;
|
||||
args[2] = gApplyToDirOverride || applyToDirPath;
|
||||
args[3] = "0";
|
||||
}
|
||||
args = args.concat([callbackApp.parent.path, callbackApp.path]);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/* 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/.
|
||||
*/
|
||||
|
||||
/* Test trying to use an apply-to directory different from the install
|
||||
* directory, which should fail.
|
||||
*/
|
||||
|
||||
function run_test() {
|
||||
if (!setupTestCommon()) {
|
||||
return;
|
||||
}
|
||||
gTestFiles = gTestFilesCompleteSuccess;
|
||||
gTestDirs = gTestDirsCompleteSuccess;
|
||||
setTestFilesAndDirsForFailure();
|
||||
setupUpdaterTest(FILE_COMPLETE_MAR, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the call to setupUpdaterTest finishes.
|
||||
*/
|
||||
function setupUpdaterTestFinished() {
|
||||
overrideApplyToDir(getApplyDirPath() + "/../NoSuchDir");
|
||||
// If execv is used the updater process will turn into the callback process
|
||||
// and the updater's return code will be that of the callback process.
|
||||
runUpdateUsingUpdater(STATE_FAILED_INVALID_APPLYTO_DIR_ERROR, false,
|
||||
(USE_EXECV ? 0 : 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the call to runUpdateUsingUpdater finishes.
|
||||
*/
|
||||
function runUpdateFinished() {
|
||||
standardInit();
|
||||
checkPostUpdateRunningFile(false);
|
||||
checkFilesAfterUpdateFailure(getApplyDirFile);
|
||||
waitForFilesInUse();
|
||||
}
|
|
@ -104,3 +104,6 @@ reason = bug 1291985 and bug 1164150
|
|||
[marAppApplyUpdateStageSuccess.js]
|
||||
skip-if = os == 'win' && debug && (os_version == '5.1' || os_version == '5.2') || toolkit == 'gonk'
|
||||
reason = bug 1291985 and bug 1164150
|
||||
[marWrongApplyToDirFailure_win.js]
|
||||
skip-if = os != 'win' || debug && (os_version == '5.1' || os_version == '5.2')
|
||||
reason = Windows only test and bug 1291985
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче