update_engine: Add rollback_allowed policy in Omaha requests
Send rollback_allowed="true" parameter to Omaha if rollback is
allowed through enterprise policy.
This parameter indicates to Omaha that the returned image might
be a rollback image, if the targetversionprefix parameter is set
and it is an earlier version than the one which is currently on
the device.
Also, this CL changes update_engine behavior to only send
targetversionprefix to Omaha if it's not empty.
BUG=chromium:814830
TEST='cros_run_unit_tests --board=cyan --packages update_engine'
Change-Id: Iaa5503e217631311fb9ba3a5237ccbfedf04afe9
Reviewed-on: https://chromium-review.googlesource.com/932123
Commit-Ready: Marton Hunyady <hunyadym@chromium.org>
Tested-by: Marton Hunyady <hunyadym@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 424cb66..6809979 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -127,10 +127,17 @@
if (include_ping)
app_body = GetPingXml(ping_active_days, ping_roll_call_days);
if (!ping_only) {
- app_body += base::StringPrintf(
- " <updatecheck targetversionprefix=\"%s\""
- "></updatecheck>\n",
- XmlEncodeWithDefault(params->target_version_prefix(), "").c_str());
+ app_body += " <updatecheck";
+ if (!params->target_version_prefix().empty()) {
+ app_body += base::StringPrintf(
+ " targetversionprefix=\"%s\"",
+ XmlEncodeWithDefault(params->target_version_prefix(), "").c_str());
+ // Rollback requires target_version_prefix set.
+ if (params->rollback_allowed()) {
+ app_body += " rollback_allowed=\"true\"";
+ }
+ }
+ app_body += "></updatecheck>\n";
// If this is the first update check after a reboot following a previous
// update, generate an event containing the previous version number. If