Mike Frysinger | 8155d08 | 2012-04-06 15:23:18 -0400 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 5 | #include <unistd.h> |
| 6 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 7 | #include <string> |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 8 | #include <vector> |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 9 | |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 10 | #include <base/at_exit.h> |
| 11 | #include <base/command_line.h> |
Ben Chan | 06c76a4 | 2014-09-05 08:21:06 -0700 | [diff] [blame] | 12 | #include <base/files/file_util.h> |
Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 13 | #include <base/location.h> |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 14 | #include <base/logging.h> |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 15 | #include <base/strings/string_util.h> |
| 16 | #include <base/strings/stringprintf.h> |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 17 | #include <base/time/time.h> |
Steve Fung | d570820 | 2014-09-28 23:24:06 -0700 | [diff] [blame] | 18 | #include <chromeos/flag_helper.h> |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 19 | #include <chromeos/message_loops/glib_message_loop.h> |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 20 | #include <glib.h> |
Darin Petkov | 1023a60 | 2010-08-30 13:47:51 -0700 | [diff] [blame] | 21 | #include <metrics/metrics_library.h> |
Chris Masone | 4dc2ada | 2010-09-23 12:43:03 -0700 | [diff] [blame] | 22 | #include <sys/stat.h> |
Alex Deymo | 44666f9 | 2014-07-22 20:29:24 -0700 | [diff] [blame] | 23 | #include <sys/types.h> |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 24 | |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 25 | #include "update_engine/certificate_checker.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 26 | #include "update_engine/dbus_constants.h" |
| 27 | #include "update_engine/dbus_service.h" |
Gilad Arnold | 1b9d6ae | 2014-03-03 13:46:07 -0800 | [diff] [blame] | 28 | #include "update_engine/dbus_wrapper_interface.h" |
Alex Deymo | 44666f9 | 2014-07-22 20:29:24 -0700 | [diff] [blame] | 29 | #include "update_engine/glib_utils.h" |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 30 | #include "update_engine/real_system_state.h" |
Andrew de los Reyes | 3d6a209 | 2010-08-23 18:23:26 -0700 | [diff] [blame] | 31 | #include "update_engine/subprocess.h" |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 32 | #include "update_engine/terminator.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 33 | #include "update_engine/update_attempter.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 34 | extern "C" { |
Timothy Jennison | 08d4931 | 2015-03-04 13:46:40 -0500 | [diff] [blame] | 35 | #include "update_engine/org.chromium.UpdateEngineInterface.dbusserver.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 36 | } |
Alex Vakulenko | 44cab30 | 2014-07-23 13:12:15 -0700 | [diff] [blame] | 37 | #include "update_engine/utils.h" |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 38 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 39 | using std::string; |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 40 | using std::vector; |
| 41 | |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 42 | namespace { |
| 43 | const int kDBusSystemMaxWaitSeconds = 2 * 60; |
| 44 | } // namespace |
| 45 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 46 | namespace chromeos_update_engine { |
| 47 | |
Andrew de los Reyes | 7352067 | 2010-05-10 13:44:58 -0700 | [diff] [blame] | 48 | namespace { |
| 49 | |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 50 | // Wait for DBus to be ready by attempting to get the system bus up to |
| 51 | // |timeout| time. Returns whether it succeeded to get the bus. |
| 52 | bool WaitForDBusSystem(base::TimeDelta timeout) { |
| 53 | GError *error = nullptr; |
| 54 | DBusGConnection *bus = nullptr; |
| 55 | Clock clock; |
| 56 | base::Time deadline = clock.GetMonotonicTime() + timeout; |
| 57 | |
| 58 | while (clock.GetMonotonicTime() < deadline) { |
| 59 | bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); |
| 60 | if (bus) |
| 61 | return true; |
| 62 | LOG(WARNING) << "Failed to get system bus, waiting: " |
| 63 | << utils::GetAndFreeGError(&error); |
| 64 | // Wait 1 second. |
| 65 | sleep(1); |
| 66 | } |
| 67 | LOG(ERROR) << "Failed to get system bus after " << timeout.InSeconds() |
| 68 | << " seconds."; |
| 69 | return false; |
| 70 | } |
| 71 | |
| 72 | void SetupDBusService(UpdateEngineService* service) { |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 73 | DBusGConnection *bus; |
| 74 | DBusGProxy *proxy; |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 75 | GError *error = nullptr; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 76 | |
| 77 | bus = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error); |
Darin Petkov | a0b9e77 | 2011-10-06 05:05:56 -0700 | [diff] [blame] | 78 | LOG_IF(FATAL, !bus) << "Failed to get bus: " |
| 79 | << utils::GetAndFreeGError(&error); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 80 | proxy = dbus_g_proxy_new_for_name(bus, |
| 81 | DBUS_SERVICE_DBUS, |
| 82 | DBUS_PATH_DBUS, |
| 83 | DBUS_INTERFACE_DBUS); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 84 | guint32 request_name_ret; |
| 85 | if (!org_freedesktop_DBus_request_name(proxy, |
| 86 | kUpdateEngineServiceName, |
| 87 | 0, |
| 88 | &request_name_ret, |
| 89 | &error)) { |
Darin Petkov | a0b9e77 | 2011-10-06 05:05:56 -0700 | [diff] [blame] | 90 | LOG(FATAL) << "Failed to get name: " << utils::GetAndFreeGError(&error); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 91 | } |
| 92 | if (request_name_ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { |
| 93 | g_warning("Got result code %u from requesting name", request_name_ret); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 94 | LOG(FATAL) << "Got result code " << request_name_ret |
| 95 | << " from requesting name, but expected " |
| 96 | << DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER; |
| 97 | } |
| 98 | dbus_g_connection_register_g_object(bus, |
| 99 | "/org/chromium/UpdateEngine", |
| 100 | G_OBJECT(service)); |
| 101 | } |
| 102 | |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 103 | void SetupLogSymlink(const string& symlink_path, const string& log_path) { |
| 104 | // TODO(petkov): To ensure a smooth transition between non-timestamped and |
| 105 | // timestamped logs, move an existing log to start the first timestamped |
| 106 | // one. This code can go away once all clients are switched to this version or |
| 107 | // we stop caring about the old-style logs. |
| 108 | if (utils::FileExists(symlink_path.c_str()) && |
| 109 | !utils::IsSymlink(symlink_path.c_str())) { |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 110 | base::ReplaceFile(base::FilePath(symlink_path), |
| 111 | base::FilePath(log_path), |
| 112 | nullptr); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 113 | } |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 114 | base::DeleteFile(base::FilePath(symlink_path), true); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 115 | if (symlink(log_path.c_str(), symlink_path.c_str()) == -1) { |
| 116 | PLOG(ERROR) << "Unable to create symlink " << symlink_path |
| 117 | << " pointing at " << log_path; |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | string GetTimeAsString(time_t utime) { |
| 122 | struct tm tm; |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 123 | CHECK_EQ(localtime_r(&utime, &tm), &tm); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 124 | char str[16]; |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 125 | CHECK_EQ(strftime(str, sizeof(str), "%Y%m%d-%H%M%S", &tm), 15u); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 126 | return str; |
| 127 | } |
| 128 | |
| 129 | string SetupLogFile(const string& kLogsRoot) { |
| 130 | const string kLogSymlink = kLogsRoot + "/update_engine.log"; |
| 131 | const string kLogsDir = kLogsRoot + "/update_engine"; |
| 132 | const string kLogPath = |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 133 | base::StringPrintf("%s/update_engine.%s", |
| 134 | kLogsDir.c_str(), |
| 135 | GetTimeAsString(::time(nullptr)).c_str()); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 136 | mkdir(kLogsDir.c_str(), 0755); |
| 137 | SetupLogSymlink(kLogSymlink, kLogPath); |
| 138 | return kLogSymlink; |
| 139 | } |
| 140 | |
Steve Fung | d570820 | 2014-09-28 23:24:06 -0700 | [diff] [blame] | 141 | void SetupLogging(bool log_to_std_err) { |
Alex Deymo | d603ba9 | 2014-10-03 14:51:33 -0700 | [diff] [blame] | 142 | string log_file; |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 143 | logging::LoggingSettings log_settings; |
| 144 | log_settings.lock_log = logging::DONT_LOCK_LOG_FILE; |
| 145 | log_settings.delete_old = logging::APPEND_TO_OLD_LOG_FILE; |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 146 | |
Steve Fung | d570820 | 2014-09-28 23:24:06 -0700 | [diff] [blame] | 147 | if (log_to_std_err) { |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 148 | // Log to stderr initially. |
| 149 | log_settings.log_file = nullptr; |
| 150 | log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 151 | } else { |
Alex Deymo | d603ba9 | 2014-10-03 14:51:33 -0700 | [diff] [blame] | 152 | log_file = SetupLogFile("/var/log"); |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 153 | log_settings.log_file = log_file.c_str(); |
| 154 | log_settings.logging_dest = logging::LOG_TO_FILE; |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 155 | } |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 156 | |
| 157 | logging::InitLogging(log_settings); |
Darin Petkov | 30291ed | 2010-11-12 10:23:06 -0800 | [diff] [blame] | 158 | } |
Andrew de los Reyes | 000d895 | 2011-03-02 15:21:14 -0800 | [diff] [blame] | 159 | |
Alex Vakulenko | d2779df | 2014-06-16 13:19:00 -0700 | [diff] [blame] | 160 | } // namespace |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 161 | } // namespace chromeos_update_engine |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 162 | |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 163 | int main(int argc, char** argv) { |
Steve Fung | d570820 | 2014-09-28 23:24:06 -0700 | [diff] [blame] | 164 | DEFINE_bool(logtostderr, false, |
| 165 | "Write logs to stderr instead of to a file in log_dir."); |
| 166 | DEFINE_bool(foreground, false, |
| 167 | "Don't daemon()ize; run in foreground."); |
| 168 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 169 | ::g_type_init(); |
Ben Chan | 46bf5c8 | 2013-06-24 11:17:41 -0700 | [diff] [blame] | 170 | dbus_threads_init_default(); |
Darin Petkov | 5c0a8af | 2010-08-24 13:39:13 -0700 | [diff] [blame] | 171 | base::AtExitManager exit_manager; // Required for base/rand_util.h. |
Darin Petkov | 9c0baf8 | 2010-10-07 13:44:48 -0700 | [diff] [blame] | 172 | chromeos_update_engine::Terminator::Init(); |
Steve Fung | d570820 | 2014-09-28 23:24:06 -0700 | [diff] [blame] | 173 | chromeos::FlagHelper::Init(argc, argv, "Chromium OS Update Engine"); |
| 174 | chromeos_update_engine::SetupLogging(FLAGS_logtostderr); |
Andrew de los Reyes | 6b78e29 | 2010-05-10 15:54:39 -0700 | [diff] [blame] | 175 | if (!FLAGS_foreground) |
| 176 | PLOG_IF(FATAL, daemon(0, 0) == 1) << "daemon() failed"; |
| 177 | |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 178 | LOG(INFO) << "Chrome OS Update Engine starting"; |
Darin Petkov | a4a8a8c | 2010-07-15 22:21:12 -0700 | [diff] [blame] | 179 | |
Chris Masone | 4dc2ada | 2010-09-23 12:43:03 -0700 | [diff] [blame] | 180 | // Ensure that all written files have safe permissions. |
| 181 | // This is a mask, so we _block_ execute for the owner, and ALL |
| 182 | // permissions for other users. |
| 183 | // Done _after_ log file creation. |
| 184 | umask(S_IXUSR | S_IRWXG | S_IRWXO); |
| 185 | |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 186 | // Create the single Glib main loop. Code accessing directly the glib main |
| 187 | // loop (such as calling g_timeout_add() or similar functions) will still work |
| 188 | // since the backend for the message loop is still the Glib main loop. |
| 189 | // TODO(deymo): Replace this |loop| with one based on libevent once no other |
| 190 | // code here uses glib directly. |
| 191 | chromeos::GlibMessageLoop loop; |
| 192 | loop.SetAsCurrent(); |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 193 | |
Alex Deymo | 461b259 | 2015-07-24 20:10:52 -0700 | [diff] [blame^] | 194 | // The Subprocess class requires a chromeos::MessageLoop setup. |
| 195 | chromeos_update_engine::Subprocess subprocess; |
| 196 | subprocess.Init(); |
| 197 | |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 198 | // Wait up to 2 minutes for DBus to be ready. |
| 199 | LOG_IF(FATAL, !chromeos_update_engine::WaitForDBusSystem( |
| 200 | base::TimeDelta::FromSeconds(kDBusSystemMaxWaitSeconds))) |
| 201 | << "Failed to initialize DBus, aborting."; |
| 202 | |
Jay Srinivasan | f057205 | 2012-10-23 18:12:56 -0700 | [diff] [blame] | 203 | chromeos_update_engine::RealSystemState real_system_state; |
Nam T. Nguyen | 7d623eb | 2014-05-13 16:06:28 -0700 | [diff] [blame] | 204 | LOG_IF(ERROR, !real_system_state.Initialize()) |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 205 | << "Failed to initialize system state."; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 206 | chromeos_update_engine::UpdateAttempter *update_attempter = |
| 207 | real_system_state.update_attempter(); |
| 208 | CHECK(update_attempter); |
Darin Petkov | 9d65b7b | 2010-07-20 09:13:01 -0700 | [diff] [blame] | 209 | |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 210 | // Sets static members for the certificate checker. |
Jay Srinivasan | 6f6ea00 | 2012-12-14 11:26:28 -0800 | [diff] [blame] | 211 | chromeos_update_engine::CertificateChecker::set_system_state( |
| 212 | &real_system_state); |
Bruno Rocha | 7f9aea2 | 2011-09-12 14:31:24 -0700 | [diff] [blame] | 213 | chromeos_update_engine::OpenSSLWrapper openssl_wrapper; |
| 214 | chromeos_update_engine::CertificateChecker::set_openssl_wrapper( |
| 215 | &openssl_wrapper); |
| 216 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 217 | // Create the dbus service object: |
| 218 | dbus_g_object_type_install_info(UPDATE_ENGINE_TYPE_SERVICE, |
| 219 | &dbus_glib_update_engine_service_object_info); |
Alex Deymo | 7e8ac06 | 2014-05-01 12:56:58 -0700 | [diff] [blame] | 220 | UpdateEngineService* service = update_engine_service_new(); |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 221 | service->system_state_ = &real_system_state; |
Jay Srinivasan | 55f50c2 | 2013-01-10 19:24:35 -0800 | [diff] [blame] | 222 | update_attempter->set_dbus_service(service); |
Alex Deymo | 67363ee | 2014-09-23 23:07:44 -0700 | [diff] [blame] | 223 | chromeos_update_engine::SetupDBusService(service); |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 224 | |
Gilad Arnold | ec7f916 | 2014-07-15 13:24:46 -0700 | [diff] [blame] | 225 | // Initiate update checks. |
| 226 | update_attempter->ScheduleUpdates(); |
Andrew de los Reyes | 7352067 | 2010-05-10 13:44:58 -0700 | [diff] [blame] | 227 | |
Darin Petkov | eee26ee | 2010-10-22 11:05:46 -0700 | [diff] [blame] | 228 | // Update boot flags after 45 seconds. |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 229 | loop.PostDelayedTask( |
Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 230 | FROM_HERE, |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 231 | base::Bind(&chromeos_update_engine::UpdateAttempter::UpdateBootFlags, |
| 232 | base::Unretained(update_attempter)), |
| 233 | base::TimeDelta::FromSeconds(45)); |
Andrew de los Reyes | 3d6a209 | 2010-08-23 18:23:26 -0700 | [diff] [blame] | 234 | |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 235 | // Broadcast the update engine status on startup to ensure consistent system |
| 236 | // state on crashes. |
Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 237 | loop.PostTask(FROM_HERE, base::Bind( |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 238 | &chromeos_update_engine::UpdateAttempter::BroadcastStatus, |
| 239 | base::Unretained(update_attempter))); |
Darin Petkov | 61635a9 | 2011-05-18 16:20:36 -0700 | [diff] [blame] | 240 | |
David Zeuthen | e4c58bf | 2013-06-18 17:26:50 -0700 | [diff] [blame] | 241 | // Run the UpdateEngineStarted() method on |update_attempter|. |
Alex Deymo | 0bb2341 | 2015-06-19 00:04:46 -0700 | [diff] [blame] | 242 | loop.PostTask(FROM_HERE, base::Bind( |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 243 | &chromeos_update_engine::UpdateAttempter::UpdateEngineStarted, |
| 244 | base::Unretained(update_attempter))); |
David Zeuthen | e4c58bf | 2013-06-18 17:26:50 -0700 | [diff] [blame] | 245 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 246 | // Run the main loop until exit time: |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 247 | loop.Run(); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 248 | |
| 249 | // Cleanup: |
Alex Vakulenko | 75039d7 | 2014-03-25 12:36:28 -0700 | [diff] [blame] | 250 | update_attempter->set_dbus_service(nullptr); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 251 | g_object_unref(G_OBJECT(service)); |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 252 | |
Alex Deymo | cc16925 | 2015-06-10 19:10:14 -0700 | [diff] [blame] | 253 | loop.ReleaseFromCurrent(); |
Andrew de los Reyes | 4fe15d0 | 2009-12-10 19:01:36 -0800 | [diff] [blame] | 254 | LOG(INFO) << "Chrome OS Update Engine terminating"; |
rspangler@google.com | 49fdf18 | 2009-10-10 00:57:34 +0000 | [diff] [blame] | 255 | return 0; |
| 256 | } |