update_engine: Query dlcservice to avoid stale DLC module IDs
Within |UpdateAttempter|, the possibility of using stale DLC module IDs
existed. This should never happen. The fix is to go through |DlcService|
to recieve the list of fresh and current DLC module IDs. This change now
will handle both interactive and non-interactive update cases.
This is only for updates.
BUG=chromium:978525
TEST=FEATURES="test" emerge-${BOARD} update_engine
Change-Id: Iffa75f60f367b2a110c559654fa3df9c48c714b1
diff --git a/dlcservice_chromeos.cc b/dlcservice_chromeos.cc
index b7dee36..ad5806a 100644
--- a/dlcservice_chromeos.cc
+++ b/dlcservice_chromeos.cc
@@ -35,6 +35,8 @@
bool DlcServiceChromeOS::GetInstalled(vector<string>* dlc_module_ids) {
if (!dlc_module_ids)
return false;
+ dlc_module_ids->clear();
+
org::chromium::DlcServiceInterfaceProxy dlcservice_proxy(
DBusConnection::Get()->GetDBus());
diff --git a/dlcservice_chromeos.h b/dlcservice_chromeos.h
index 8d103c1..73442e6 100644
--- a/dlcservice_chromeos.h
+++ b/dlcservice_chromeos.h
@@ -33,6 +33,10 @@
~DlcServiceChromeOS() = default;
// BootControlInterface overrides.
+ // Will clear the |dlc_module_ids|, passed to be modified. Clearing by
+ // default has the added benefit of avoiding indeterminate behavior in the
+ // case that |dlc_module_ids| wasn't empty to begin which would lead to
+ // possible duplicates and cases when error was not checked it's still safe.
bool GetInstalled(std::vector<std::string>* dlc_module_ids) override;
private:
diff --git a/update_attempter.cc b/update_attempter.cc
index 9573c43..b06807d 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -425,7 +425,14 @@
// target channel.
omaha_request_params_->UpdateDownloadChannel();
}
- // Set the DLC module ID list.
+
+ // Set the |dlc_module_ids_| only for an update. This is required to get the
+ // currently installed DLC(s).
+ if (!is_install_ &&
+ !system_state_->dlcservice()->GetInstalled(&dlc_module_ids_)) {
+ LOG(INFO) << "Failed to retrieve DLC module IDs from dlcservice. Check the "
+ "state of dlcservice, will not update DLC modules.";
+ }
omaha_request_params_->set_dlc_module_ids(dlc_module_ids_);
omaha_request_params_->set_is_install(is_install_);
@@ -838,7 +845,6 @@
}
bool interactive = !(flags & UpdateAttemptFlags::kFlagNonInteractive);
- dlc_module_ids_.clear();
is_install_ = false;
LOG(INFO) << "Forced update check requested.";
@@ -903,9 +909,9 @@
if (IsAnyUpdateSourceAllowed()) {
forced_omaha_url_ = omaha_url;
}
- if (omaha_url == kScheduledAUTestURLRequest) {
- forced_omaha_url_ = constants::kOmahaDefaultAUTestURL;
- } else if (omaha_url == kAUTestURLRequest) {
+
+ if (omaha_url == kScheduledAUTestURLRequest ||
+ omaha_url == kAUTestURLRequest) {
forced_omaha_url_ = constants::kOmahaDefaultAUTestURL;
}