Commit 5585b3e2 authored by xiaolingbao's avatar xiaolingbao Committed by Commit bot

Add flag '/deferredrun' to recovery executable for elevated install of...

Add flag '/deferredrun' to recovery executable for elevated install of recovery component so we can distinguish from first install.

Also changed version arg format from --version to /version.

BUG=

Review URL: https://codereview.chromium.org/1136943004

Cr-Commit-Position: refs/heads/master@{#330406}
parent 5a929370
...@@ -88,6 +88,32 @@ bool SimulatingElevatedRecovery() { ...@@ -88,6 +88,32 @@ bool SimulatingElevatedRecovery() {
} }
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
base::CommandLine GetRecoveryInstallCommandLine(
const base::FilePath& command,
const base::DictionaryValue& manifest,
bool is_deferred_run,
const Version& version) {
base::CommandLine command_line(command);
// Add a flag to for re-attempted install with elevated privilege so that the
// recovery executable can report back accordingly.
if (is_deferred_run)
command_line.AppendArg("/deferredrun");
std::string arguments;
if (manifest.GetStringASCII("x-recovery-args", &arguments))
command_line.AppendArg(arguments);
std::string add_version;
if (manifest.GetStringASCII("x-recovery-add-version", &add_version) &&
add_version == "yes") {
std::string version_string = "/version ";
version_string += version.GetString();
command_line.AppendArg(version_string);
}
return command_line;
}
#if defined(OS_WIN) #if defined(OS_WIN)
scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) { scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) {
JSONFileValueDeserializer deserializer(manifest); JSONFileValueDeserializer deserializer(manifest);
...@@ -132,15 +158,9 @@ void DoElevatedInstallRecoveryComponent(const base::FilePath& path) { ...@@ -132,15 +158,9 @@ void DoElevatedInstallRecoveryComponent(const base::FilePath& path) {
if (!version.IsValid()) if (!version.IsValid())
return; return;
base::CommandLine cmdline(main_file); const bool is_deferred_run = true;
std::string arguments; const auto cmdline = GetRecoveryInstallCommandLine(
if (manifest->GetStringASCII("x-recovery-args", &arguments)) main_file, *manifest, is_deferred_run, version);
cmdline.AppendArg(arguments);
std::string add_version;
if (manifest->GetStringASCII("x-recovery-add-version", &add_version) &&
add_version == "yes") {
cmdline.AppendSwitchASCII("version", version.GetString());
}
RecordRecoveryComponentUMAEvent(RCE_RUNNING_ELEVATED); RecordRecoveryComponentUMAEvent(RCE_RUNNING_ELEVATED);
...@@ -331,16 +351,11 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, ...@@ -331,16 +351,11 @@ bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest,
base::FilePath main_file = path.Append(kRecoveryFileName); base::FilePath main_file = path.Append(kRecoveryFileName);
if (!base::PathExists(main_file)) if (!base::PathExists(main_file))
return false; return false;
// Run the recovery component. // Run the recovery component.
base::CommandLine cmdline(main_file); const bool is_deferred_run = false;
std::string arguments; const auto cmdline = GetRecoveryInstallCommandLine(
if (manifest.GetStringASCII("x-recovery-args", &arguments)) main_file, manifest, is_deferred_run, current_version_);
cmdline.AppendArg(arguments);
std::string add_version;
if (manifest.GetStringASCII("x-recovery-add-version", &add_version) &&
add_version == "yes") {
cmdline.AppendSwitchASCII("version", current_version_.GetString());
}
if (!RunInstallCommand(cmdline, path)) { if (!RunInstallCommand(cmdline, path)) {
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment