X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Floginctl.c;h=1be47c8dde9b8a3340c251a947ebbf49d5a3a2f6;hb=de97b26ac5e29063632312ec1a20eb6318ca924c;hp=53058d07a730f47b36b82dd624c84dd3ffb9aa98;hpb=4b67834e9f8a336dbc917f3bf212550e61cc98b4;p=elogind.git diff --git a/src/loginctl.c b/src/loginctl.c index 53058d07a..1be47c8dd 100644 --- a/src/loginctl.c +++ b/src/loginctl.c @@ -64,6 +64,8 @@ static bool on_tty(void) { } static void pager_open_if_enabled(void) { + + /* Cache result before we open the pager */ on_tty(); if (!arg_no_pager) @@ -391,7 +393,7 @@ static void print_session_status_info(SessionStatusInfo *i) { printf("\t Leader: %u", (unsigned) i->leader); - get_process_name(i->leader, &t); + get_process_comm(i->leader, &t); if (t) { printf(" (%s)", t); free(t); @@ -1061,10 +1063,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) { uid_t uid; uint32_t u; - r = get_user_creds((const char**) (args+i), &uid, NULL, NULL); - if (r < 0) { + ret = get_user_creds((const char**) (args+i), &uid, NULL, NULL); + if (ret < 0) { log_error("User %s unknown.", args[i]); - r = -ENOENT; goto finish; } @@ -1146,7 +1147,7 @@ finish: } static int activate(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1157,6 +1158,8 @@ static int activate(DBusConnection *bus, char **args, unsigned n) { dbus_error_init(&error); for (i = 1; i < n; i++) { + DBusMessage *reply; + m = dbus_message_new_method_call( "org.freedesktop.login1", "/org/freedesktop/login1", @@ -1195,16 +1198,13 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; } static int kill_session(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1218,6 +1218,8 @@ static int kill_session(DBusConnection *bus, char **args, unsigned n) { arg_kill_who = "all"; for (i = 1; i < n; i++) { + DBusMessage *reply; + m = dbus_message_new_method_call( "org.freedesktop.login1", "/org/freedesktop/login1", @@ -1255,16 +1257,13 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; } static int enable_linger(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1278,6 +1277,7 @@ static int enable_linger(DBusConnection *bus, char **args, unsigned n) { b = streq(args[0], "enable-linger"); for (i = 1; i < n; i++) { + DBusMessage *reply; uint32_t u; uid_t uid; @@ -1327,16 +1327,13 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; } static int terminate_user(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1349,6 +1346,7 @@ static int terminate_user(DBusConnection *bus, char **args, unsigned n) { for (i = 1; i < n; i++) { uint32_t u; uid_t uid; + DBusMessage *reply; m = dbus_message_new_method_call( "org.freedesktop.login1", @@ -1394,16 +1392,13 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; } static int kill_user(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1417,6 +1412,7 @@ static int kill_user(DBusConnection *bus, char **args, unsigned n) { arg_kill_who = "all"; for (i = 1; i < n; i++) { + DBusMessage *reply; uid_t uid; uint32_t u; @@ -1465,16 +1461,13 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; } static int attach(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1486,6 +1479,8 @@ static int attach(DBusConnection *bus, char **args, unsigned n) { dbus_error_init(&error); for (i = 2; i < n; i++) { + DBusMessage *reply; + m = dbus_message_new_method_call( "org.freedesktop.login1", "/org/freedesktop/login1", @@ -1523,9 +1518,6 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret; @@ -1581,7 +1573,7 @@ finish: } static int terminate_seat(DBusConnection *bus, char **args, unsigned n) { - DBusMessage *m = NULL, *reply = NULL; + DBusMessage *m = NULL; int ret = 0; DBusError error; unsigned i; @@ -1592,6 +1584,8 @@ static int terminate_seat(DBusConnection *bus, char **args, unsigned n) { dbus_error_init(&error); for (i = 1; i < n; i++) { + DBusMessage *reply; + m = dbus_message_new_method_call( "org.freedesktop.login1", "/org/freedesktop/login1", @@ -1627,9 +1621,6 @@ finish: if (m) dbus_message_unref(m); - if (reply) - dbus_message_unref(reply); - dbus_error_free(&error); return ret;