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/omaha_response_handler_action.h" | 5 #include "update_engine/omaha_response_handler_action.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include <base/logging.h> | 9 #include <base/logging.h> |
10 | 10 |
11 #include "update_engine/delta_performer.h" | 11 #include "update_engine/delta_performer.h" |
12 #include "update_engine/prefs_interface.h" | 12 #include "update_engine/prefs_interface.h" |
13 #include "update_engine/utils.h" | 13 #include "update_engine/utils.h" |
14 | 14 |
15 using std::string; | 15 using std::string; |
16 | 16 |
17 namespace chromeos_update_engine { | 17 namespace chromeos_update_engine { |
18 | 18 |
19 const char OmahaResponseHandlerAction::kDeadlineFile[] = | 19 const char OmahaResponseHandlerAction::kDeadlineFile[] = |
20 "/tmp/update-check-response-deadline"; | 20 "/tmp/update-check-response-deadline"; |
21 | 21 |
| 22 OmahaResponseHandlerAction::OmahaResponseHandlerAction(PrefsInterface* prefs) |
| 23 : prefs_(prefs), |
| 24 got_no_update_response_(false), |
| 25 key_path_(DeltaPerformer::kUpdatePayloadPublicKeyPath) {} |
| 26 |
22 void OmahaResponseHandlerAction::PerformAction() { | 27 void OmahaResponseHandlerAction::PerformAction() { |
23 CHECK(HasInputObject()); | 28 CHECK(HasInputObject()); |
24 ScopedActionCompleter completer(processor_, this); | 29 ScopedActionCompleter completer(processor_, this); |
25 const OmahaResponse& response = GetInputObject(); | 30 const OmahaResponse& response = GetInputObject(); |
26 if (!response.update_exists) { | 31 if (!response.update_exists) { |
27 got_no_update_response_ = true; | 32 got_no_update_response_ = true; |
28 LOG(INFO) << "There are no updates. Aborting."; | 33 LOG(INFO) << "There are no updates. Aborting."; |
29 return; | 34 return; |
30 } | 35 } |
31 install_plan_.download_url = response.codebase; | 36 install_plan_.download_url = response.codebase; |
(...skipping 10 matching lines...) Expand all Loading... |
42 << "Unable to save the update check response hash."; | 47 << "Unable to save the update check response hash."; |
43 } | 48 } |
44 | 49 |
45 TEST_AND_RETURN(GetInstallDev( | 50 TEST_AND_RETURN(GetInstallDev( |
46 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), | 51 (!boot_device_.empty() ? boot_device_ : utils::BootDevice()), |
47 &install_plan_.install_path)); | 52 &install_plan_.install_path)); |
48 install_plan_.kernel_install_path = | 53 install_plan_.kernel_install_path = |
49 utils::BootKernelDevice(install_plan_.install_path); | 54 utils::BootKernelDevice(install_plan_.install_path); |
50 | 55 |
51 install_plan_.is_full_update = !response.is_delta; | 56 install_plan_.is_full_update = !response.is_delta; |
| 57 if (!response.is_delta && utils::FileExists(key_path_.c_str())) { |
| 58 // Can't sign old style full payloads but signature is required so bail out. |
| 59 completer.set_code(kActionCodeSignedDeltaPayloadExpectedError); |
| 60 return; |
| 61 } |
52 | 62 |
53 TEST_AND_RETURN(HasOutputPipe()); | 63 TEST_AND_RETURN(HasOutputPipe()); |
54 if (HasOutputPipe()) | 64 if (HasOutputPipe()) |
55 SetOutputObject(install_plan_); | 65 SetOutputObject(install_plan_); |
56 LOG(INFO) << "Using this install plan:"; | 66 LOG(INFO) << "Using this install plan:"; |
57 install_plan_.Dump(); | 67 install_plan_.Dump(); |
58 | 68 |
59 // Send the deadline data (if any) to Chrome through a file. This is a pretty | 69 // Send the deadline data (if any) to Chrome through a file. This is a pretty |
60 // hacky solution but should be OK for now. | 70 // hacky solution but should be OK for now. |
61 // | 71 // |
(...skipping 15 matching lines...) Expand all Loading... |
77 string ret(boot_dev); | 87 string ret(boot_dev); |
78 string::reverse_iterator it = ret.rbegin(); // last character in string | 88 string::reverse_iterator it = ret.rbegin(); // last character in string |
79 // Right now, we just switch '3' and '5' partition numbers. | 89 // Right now, we just switch '3' and '5' partition numbers. |
80 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); | 90 TEST_AND_RETURN_FALSE((*it == '3') || (*it == '5')); |
81 *it = (*it == '3') ? '5' : '3'; | 91 *it = (*it == '3') ? '5' : '3'; |
82 *install_dev = ret; | 92 *install_dev = ret; |
83 return true; | 93 return true; |
84 } | 94 } |
85 | 95 |
86 } // namespace chromeos_update_engine | 96 } // namespace chromeos_update_engine |
OLD | NEW |