X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fupdate-utmp.c;h=b06f5a06cb6be57a19de2838a6bc4cbb480c8836;hp=3ec0a16c2a20ba9cd1dd51b356c311b5951d1325;hb=9841e8e3d305e6f4173c9aedbe8d57adfe10d145;hpb=3006982d93e92019dd6d94a7518684593b43a05e diff --git a/src/update-utmp.c b/src/update-utmp.c index 3ec0a16c2..b06f5a06c 100644 --- a/src/update-utmp.c +++ b/src/update-utmp.c @@ -77,7 +77,7 @@ static usec_t get_startup_time(Context *c) { } if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) { - log_error("Failed to send command: %s", error.message); + log_error("Failed to send command: %s", bus_error_message(&error)); goto finish; } @@ -114,7 +114,10 @@ static int get_current_runlevel(Context *c) { const char *special; } table[] = { /* The first target of this list that is active or has - * a job scheduled wins */ + * a job scheduled wins. We prefer runlevels 5 and 3 + * here over the others, since these are the main + * runlevels used on Fedora. It might make sense to + * change the order on some distributions. */ { '5', SPECIAL_RUNLEVEL5_TARGET }, { '3', SPECIAL_RUNLEVEL3_TARGET }, { '4', SPECIAL_RUNLEVEL4_TARGET }, @@ -164,7 +167,7 @@ static int get_current_runlevel(Context *c) { if (!dbus_message_get_args(reply, &error, DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID)) { - log_error("Failed to parse reply: %s", error.message); + log_error("Failed to parse reply: %s", bus_error_message(&error)); r = -EIO; goto finish; } @@ -191,7 +194,7 @@ static int get_current_runlevel(Context *c) { dbus_message_unref(reply); if (!(reply = dbus_connection_send_with_reply_and_block(c->bus, m, -1, &error))) { - log_error("Failed to send command: %s", error.message); + log_error("Failed to send command: %s", bus_error_message(&error)); r = -EIO; goto finish; } @@ -358,12 +361,12 @@ int main(int argc, char *argv[]) { if (getppid() != 1) { log_error("This program should be invoked by init only."); - return 1; + return EXIT_FAILURE; } if (argc != 2) { log_error("This program requires one argument."); - return 1; + return EXIT_FAILURE; } log_set_target(LOG_TARGET_SYSLOG_OR_KMSG); @@ -376,7 +379,7 @@ int main(int argc, char *argv[]) { #endif if (bus_connect(DBUS_BUS_SYSTEM, &c.bus, NULL, &error) < 0) { - log_error("Failed to get D-Bus connection: %s", error.message); + log_error("Failed to get D-Bus connection: %s", bus_error_message(&error)); r = -EIO; goto finish; } @@ -403,12 +406,13 @@ finish: #endif if (c.bus) { - dbus_connection_close(c.bus); - dbus_connection_unref(c.bus); + dbus_connection_flush(c.bus); + dbus_connection_close(c.bus); + dbus_connection_unref(c.bus); } dbus_error_free(&error); dbus_shutdown(); - return r < 0 ? 1 : 0; + return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; }