Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Side by Side Diff: omaha_request_params.cc

Issue 6225001: AU: Don't allow stateful /etc/lsb-release override in normal boot mode... (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: ShouldLockDown and no rootfs track validation Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « omaha_request_params.h ('k') | omaha_request_params_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "update_engine/omaha_request_params.h" 5 #include "update_engine/omaha_request_params.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/utsname.h> 9 #include <sys/utsname.h>
10 10
(...skipping 20 matching lines...) Expand all
31 const char* const OmahaRequestParams::kAppId( 31 const char* const OmahaRequestParams::kAppId(
32 "{87efface-864d-49a5-9bb3-4b050a7c227a}"); 32 "{87efface-864d-49a5-9bb3-4b050a7c227a}");
33 const char* const OmahaRequestParams::kOsPlatform("Chrome OS"); 33 const char* const OmahaRequestParams::kOsPlatform("Chrome OS");
34 const char* const OmahaRequestParams::kOsVersion("Indy"); 34 const char* const OmahaRequestParams::kOsVersion("Indy");
35 const char* const OmahaRequestParams::kUpdateUrl( 35 const char* const OmahaRequestParams::kUpdateUrl(
36 "https://tools.google.com/service/update2"); 36 "https://tools.google.com/service/update2");
37 37
38 static const char kHWIDPath[] = "/sys/devices/platform/chromeos_acpi/HWID"; 38 static const char kHWIDPath[] = "/sys/devices/platform/chromeos_acpi/HWID";
39 39
40 OmahaRequestDeviceParams::OmahaRequestDeviceParams() : 40 OmahaRequestDeviceParams::OmahaRequestDeviceParams() :
41 force_build_type_(false), 41 force_lock_down_(false),
42 forced_official_build_(false) {} 42 forced_lock_down_(false) {}
43 43
44 bool OmahaRequestDeviceParams::Init(const std::string& in_app_version, 44 bool OmahaRequestDeviceParams::Init(const std::string& in_app_version,
45 const std::string& in_update_url) { 45 const std::string& in_update_url) {
46 bool stateful_override = !ShouldLockDown();
46 os_platform = OmahaRequestParams::kOsPlatform; 47 os_platform = OmahaRequestParams::kOsPlatform;
47 os_version = OmahaRequestParams::kOsVersion; 48 os_version = OmahaRequestParams::kOsVersion;
48 app_version = in_app_version.empty() ? 49 app_version = in_app_version.empty() ?
49 GetLsbValue("CHROMEOS_RELEASE_VERSION", "", NULL, true) : in_app_version; 50 GetLsbValue("CHROMEOS_RELEASE_VERSION", "", NULL, stateful_override) :
51 in_app_version;
50 os_sp = app_version + "_" + GetMachineType(); 52 os_sp = app_version + "_" + GetMachineType();
51 os_board = GetLsbValue("CHROMEOS_RELEASE_BOARD", "", NULL, true); 53 os_board = GetLsbValue("CHROMEOS_RELEASE_BOARD", "", NULL, stateful_override);
52 app_id = GetLsbValue("CHROMEOS_RELEASE_APPID", 54 app_id = GetLsbValue("CHROMEOS_RELEASE_APPID",
53 OmahaRequestParams::kAppId, 55 OmahaRequestParams::kAppId,
54 NULL, 56 NULL,
55 true); 57 stateful_override);
56 app_lang = "en-US"; 58 app_lang = "en-US";
57 app_track = GetLsbValue( 59 app_track = GetLsbValue(
58 kUpdateTrackKey, 60 kUpdateTrackKey,
59 "", 61 "",
60 &chromeos_update_engine::OmahaRequestDeviceParams::IsValidTrack, 62 &chromeos_update_engine::OmahaRequestDeviceParams::IsValidTrack,
61 true); 63 true); // stateful_override
62 hardware_class = GetHardwareClass(); 64 hardware_class = GetHardwareClass();
63 struct stat stbuf; 65 struct stat stbuf;
64 66
65 // Deltas are only okay if the /.nodelta file does not exist. If we don't 67 // Deltas are only okay if the /.nodelta file does not exist. If we don't
66 // know (i.e. stat() returns some unexpected error), then err on the side of 68 // know (i.e. stat() returns some unexpected error), then err on the side of
67 // caution and say deltas are not okay. 69 // caution and say deltas are not okay.
68 delta_okay = (stat((root_ + "/.nodelta").c_str(), &stbuf) < 0) && 70 delta_okay = (stat((root_ + "/.nodelta").c_str(), &stbuf) < 0) &&
69 (errno == ENOENT); 71 (errno == ENOENT);
70 72
71 // For now, disable delta updates if the rootfs track is different than the 73 // For now, disable delta updates if the rootfs track is different than the
72 // track that we're sending to the update server because such updates are 74 // track that we're sending to the update server because such updates are
73 // destined to fail -- the source rootfs hash will be different than the 75 // destined to fail -- the source rootfs hash will be different than the
74 // expected hash due to the different track in /etc/lsb-release. 76 // expected hash due to the different track in /etc/lsb-release.
75 // 77 //
76 // Longer term we should consider an alternative: (a) clients can send 78 // Longer term we should consider an alternative: (a) clients can send
77 // (current_version, current_channel, new_channel) information, or (b) the 79 // (current_version, current_channel, new_channel) information, or (b) the
78 // build process can make sure releases on separate tracks are identical (i.e, 80 // build process can make sure releases on separate tracks are identical (i.e,
79 // by not stamping the release with the channel), or (c) the release process 81 // by not stamping the release with the channel), or (c) the release process
80 // can ensure that different channels get different version numbers. 82 // can ensure that different channels get different version numbers.
81 const string rootfs_track = GetLsbValue( 83 const string rootfs_track = GetLsbValue(
82 kUpdateTrackKey, 84 kUpdateTrackKey,
83 "", 85 "",
84 &chromeos_update_engine::OmahaRequestDeviceParams::IsValidTrack, 86 NULL, // No need to validate the read-only rootfs track.
85 false); 87 false); // stateful_override
86 delta_okay = delta_okay && rootfs_track == app_track; 88 delta_okay = delta_okay && rootfs_track == app_track;
87 89
88 update_url = in_update_url.empty() ? 90 update_url = in_update_url.empty() ?
89 GetLsbValue("CHROMEOS_AUSERVER", 91 GetLsbValue("CHROMEOS_AUSERVER",
90 OmahaRequestParams::kUpdateUrl, 92 OmahaRequestParams::kUpdateUrl,
91 NULL, 93 NULL,
92 true) : 94 stateful_override) :
93 in_update_url; 95 in_update_url;
94 return true; 96 return true;
95 } 97 }
96 98
97 bool OmahaRequestDeviceParams::SetTrack(const std::string& track) { 99 bool OmahaRequestDeviceParams::SetTrack(const std::string& track) {
98 TEST_AND_RETURN_FALSE(IsValidTrack(track)); 100 TEST_AND_RETURN_FALSE(IsValidTrack(track));
99 FilePath kFile(root_ + utils::kStatefulPartition + "/etc/lsb-release"); 101 FilePath kFile(root_ + utils::kStatefulPartition + "/etc/lsb-release");
100 string file_data; 102 string file_data;
101 map<string, string> data; 103 map<string, string> data;
102 if (file_util::ReadFileToString(kFile, &file_data)) { 104 if (file_util::ReadFileToString(kFile, &file_data)) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 string OmahaRequestDeviceParams::GetHardwareClass() const { 168 string OmahaRequestDeviceParams::GetHardwareClass() const {
167 string hwid; 169 string hwid;
168 if (!file_util::ReadFileToString(FilePath(root_ + kHWIDPath), &hwid)) { 170 if (!file_util::ReadFileToString(FilePath(root_ + kHWIDPath), &hwid)) {
169 LOG(ERROR) << "Unable to determine the system hardware qualification ID."; 171 LOG(ERROR) << "Unable to determine the system hardware qualification ID.";
170 return ""; 172 return "";
171 } 173 }
172 TrimWhitespaceASCII(hwid, TRIM_ALL, &hwid); 174 TrimWhitespaceASCII(hwid, TRIM_ALL, &hwid);
173 return hwid; 175 return hwid;
174 } 176 }
175 177
176 bool OmahaRequestDeviceParams::IsOfficialBuild() const { 178 bool OmahaRequestDeviceParams::ShouldLockDown() const {
177 return force_build_type_ ? forced_official_build_ : utils::IsOfficialBuild(); 179 if (force_lock_down_) {
180 return forced_lock_down_;
181 }
182 return utils::IsOfficialBuild() && utils::IsNormalBootMode();
178 } 183 }
179 184
180 bool OmahaRequestDeviceParams::IsValidTrack(const std::string& track) const { 185 bool OmahaRequestDeviceParams::IsValidTrack(const std::string& track) const {
181 static const char* kValidTracks[] = { 186 static const char* kValidTracks[] = {
182 "canary-channel", 187 "canary-channel",
183 "beta-channel", 188 "beta-channel",
184 "dev-channel", 189 "dev-channel",
185 }; 190 };
186 if (!IsOfficialBuild()) { 191 if (!ShouldLockDown()) {
187 return true; 192 return true;
188 } 193 }
189 for (size_t t = 0; t < arraysize(kValidTracks); ++t) { 194 for (size_t t = 0; t < arraysize(kValidTracks); ++t) {
190 if (track == kValidTracks[t]) { 195 if (track == kValidTracks[t]) {
191 return true; 196 return true;
192 } 197 }
193 } 198 }
194 return false; 199 return false;
195 } 200 }
196 201
197 void OmahaRequestDeviceParams::SetBuildTypeOfficial(bool is_official) { 202 void OmahaRequestDeviceParams::SetLockDown(bool lock) {
198 force_build_type_ = true; 203 force_lock_down_ = true;
199 forced_official_build_ = is_official; 204 forced_lock_down_ = lock;
200 } 205 }
201 206
202 } // namespace chromeos_update_engine 207 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « omaha_request_params.h ('k') | omaha_request_params_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698