AU: Restrict URL/version change over D-Bus to non-official builds only.
BUG=7159
TEST=unit tests, test on device
Change-Id: I7dd6293d3e61db123b2be2f1e3ee283fcb5ba968
Review URL: http://codereview.chromium.org/3965001
diff --git a/dbus_service.cc b/dbus_service.cc
index 677dbc8..63fbf50 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -3,9 +3,13 @@
// found in the LICENSE file.
#include "update_engine/dbus_service.h"
+
#include <string>
-#include "base/logging.h"
+
+#include <base/logging.h>
+
#include "update_engine/marshal.glibmarshal.h"
+#include "update_engine/utils.h"
using std::string;
@@ -51,8 +55,18 @@
gchar* app_version,
gchar* omaha_url,
GError **error) {
- const string update_app_version = app_version ? app_version : "";
- const string update_omaha_url = omaha_url ? omaha_url : "";
+ string update_app_version;
+ string update_omaha_url;
+ // Only non-official (e.g., dev and test) builds can override the current
+ // version and update server URL over D-Bus.
+ if (!chromeos_update_engine::utils::IsOfficialBuild()) {
+ if (app_version) {
+ update_app_version = app_version;
+ }
+ if (omaha_url) {
+ update_omaha_url = omaha_url;
+ }
+ }
LOG(INFO) << "Attempt update: app_version=\"" << update_app_version << "\" "
<< "omaha_url=\"" << update_omaha_url << "\"";
self->update_attempter_->CheckForUpdate(app_version, omaha_url);
diff --git a/utils.cc b/utils.cc
index c8a4da6..162fe7b 100644
--- a/utils.cc
+++ b/utils.cc
@@ -39,14 +39,10 @@
namespace utils {
static const char kOOBECompletedMarker[] = "/home/chronos/.oobe_completed";
+static const char kDevImageMarker[] = "/root/.dev_mode";
bool IsOfficialBuild() {
- OmahaRequestDeviceParams params;
- if (!params.Init("", "")) {
- return true;
- }
- return params.app_track != "buildbot-build" &&
- params.app_track != "developer-build";
+ return !file_util::PathExists(FilePath(kDevImageMarker));
}
bool IsOOBEComplete() {
diff --git a/utils.h b/utils.h
index 9beae04..57fb3bb 100644
--- a/utils.h
+++ b/utils.h
@@ -21,10 +21,7 @@
namespace utils {
-// Returns true if this is an official Chrome OS build, false
-// otherwise. Currently, this routine errs on the official build side
-// -- if it doesn't recognize the update track as non-official, it
-// assumes the build is official.
+// Returns true if this is an official Chrome OS build, false otherwise.
bool IsOfficialBuild();
// Returns true if the OOBE process has been completed and EULA accepted, false