OLD | NEW |
---|---|
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/download_action.h" | 5 #include "update_engine/download_action.h" |
6 #include <errno.h> | 6 #include <errno.h> |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include <glib.h> | 10 #include <glib.h> |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer."; | 154 LOG_IF(WARNING, writer_->Close() != 0) << "Error closing the writer."; |
155 writer_ = NULL; | 155 writer_ = NULL; |
156 } | 156 } |
157 if (delegate_) { | 157 if (delegate_) { |
158 delegate_->SetDownloadStatus(false); // Set to inactive. | 158 delegate_->SetDownloadStatus(false); // Set to inactive. |
159 } | 159 } |
160 ActionExitCode code = | 160 ActionExitCode code = |
161 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; | 161 successful ? kActionCodeSuccess : kActionCodeDownloadTransferError; |
162 if (code == kActionCodeSuccess) { | 162 if (code == kActionCodeSuccess) { |
163 if (!install_plan_.is_full_update) { | 163 if (!install_plan_.is_full_update) { |
164 bool public_key_verify_failed = false; | |
164 if (!delta_performer_->VerifyPayload("", | 165 if (!delta_performer_->VerifyPayload("", |
165 install_plan_.download_hash, | 166 install_plan_.download_hash, |
166 install_plan_.size)) { | 167 install_plan_.size, |
168 &public_key_verify_failed)) { | |
167 LOG(ERROR) << "Download of " << install_plan_.download_url | 169 LOG(ERROR) << "Download of " << install_plan_.download_url |
168 << " failed due to payload verification error."; | 170 << " failed due to payload verification error."; |
169 code = kActionCodeDownloadPayloadVerificationError; | 171 code = kActionCodeDownloadPayloadVerificationError; |
170 } else if (!delta_performer_->GetNewPartitionInfo( | 172 } else if (!delta_performer_->GetNewPartitionInfo( |
171 &install_plan_.kernel_size, | 173 &install_plan_.kernel_size, |
172 &install_plan_.kernel_hash, | 174 &install_plan_.kernel_hash, |
173 &install_plan_.rootfs_size, | 175 &install_plan_.rootfs_size, |
174 &install_plan_.rootfs_hash)) { | 176 &install_plan_.rootfs_hash)) { |
175 LOG(ERROR) << "Unable to get new partition hash info."; | 177 LOG(ERROR) << "Unable to get new partition hash info."; |
176 code = kActionCodeDownloadNewPartitionInfoError; | 178 code = kActionCodeDownloadNewPartitionInfoError; |
177 } | 179 } |
180 if (!public_key_verify_failed) { | |
181 // TODO(adlr): squash the http verify failure warning | |
petkov
2011/03/30 21:04:42
what do you mean?
adlr
2011/03/30 21:52:19
Removed this code and made a cleaner comment
| |
182 } | |
178 } else { | 183 } else { |
179 // Makes sure the hash and size are correct for an old-style full update. | 184 // Makes sure the hash and size are correct for an old-style full update. |
180 omaha_hash_calculator_.Finalize(); | 185 omaha_hash_calculator_.Finalize(); |
181 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { | 186 if (omaha_hash_calculator_.hash() != install_plan_.download_hash) { |
182 LOG(ERROR) << "Download of " << install_plan_.download_url | 187 LOG(ERROR) << "Download of " << install_plan_.download_url |
183 << " failed. Expected hash " << install_plan_.download_hash | 188 << " failed. Expected hash " << install_plan_.download_hash |
184 << " but got hash " << omaha_hash_calculator_.hash(); | 189 << " but got hash " << omaha_hash_calculator_.hash(); |
185 code = kActionCodeDownloadHashMismatchError; | 190 code = kActionCodeDownloadHashMismatchError; |
186 } else if (bytes_received_ != install_plan_.size) { | 191 } else if (bytes_received_ != install_plan_.size) { |
187 LOG(ERROR) << "Download of " << install_plan_.download_url | 192 LOG(ERROR) << "Download of " << install_plan_.download_url |
(...skipping 12 matching lines...) Expand all Loading... | |
200 processor_->ActionComplete(this, code); | 205 processor_->ActionComplete(this, code); |
201 } | 206 } |
202 | 207 |
203 void DownloadAction::TransferTerminated(HttpFetcher *fetcher) { | 208 void DownloadAction::TransferTerminated(HttpFetcher *fetcher) { |
204 if (code_ != kActionCodeSuccess) { | 209 if (code_ != kActionCodeSuccess) { |
205 processor_->ActionComplete(this, code_); | 210 processor_->ActionComplete(this, code_); |
206 } | 211 } |
207 } | 212 } |
208 | 213 |
209 }; // namespace {} | 214 }; // namespace {} |
OLD | NEW |