X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsystemctl.c;h=5c91c325cd2d5ae8b5012248dbb163f35ad7f117;hb=7e61bf2019c2cab4e1e21ee775bab25ef1a1bb81;hp=9b88da153803a4b348e4baec4be15aadc2e5d1f0;hpb=fc6071bfb38a118fd059e6f86750dfcf9580fd31;p=elogind.git diff --git a/src/systemctl.c b/src/systemctl.c index 9b88da153..5c91c325c 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -242,7 +242,7 @@ static int list_units(DBusConnection *bus, char **args, unsigned n) { if (job_id != 0) printf(" %-15s%n", job_type, &b); else - b = 1 + 15; + b = 1 + 16; if (a + b + 2 < columns()) { if (job_id == 0) @@ -856,6 +856,7 @@ static int check_unit(DBusConnection *bus, char **args, unsigned n) { if (!arg_quiet) puts("unknown"); + dbus_error_free(&error); continue; } @@ -951,8 +952,6 @@ static void show_cgroup(const char *name) { if (!f) return; - printf("\t\t \342\224\202\n"); - while (!feof(f)) { unsigned long ul; @@ -967,7 +966,8 @@ static void show_cgroup(const char *name) { get_process_cmdline(last, 60, &t); printf("\t\t \342\224\234 %lu %s\n", (unsigned long) last, strna(t)); free(t); - } + } else + printf("\t\t \342\224\202\n"); last = (pid_t) ul; } @@ -1618,6 +1618,42 @@ static int show(DBusConnection *bus, char **args, unsigned n) { goto finish; } + if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { + + if (!dbus_error_has_name(&error, DBUS_ERROR_ACCESS_DENIED)) { + log_error("Failed to issue method call: %s", error.message); + r = -EIO; + goto finish; + } + + dbus_error_free(&error); + + dbus_message_unref(m); + if (!(m = dbus_message_new_method_call( + "org.freedesktop.systemd1", + "/org/freedesktop/systemd1", + "org.freedesktop.systemd1.Manager", + "GetUnit"))) { + log_error("Could not allocate message."); + r = -ENOMEM; + goto finish; + } + + if (!dbus_message_append_args(m, + DBUS_TYPE_STRING, &args[i], + DBUS_TYPE_INVALID)) { + log_error("Could not append arguments to message."); + r = -ENOMEM; + goto finish; + } + + if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { + log_error("Failed to issue method call: %s", error.message); + r = -EIO; + goto finish; + } + } + } else { if (!(m = dbus_message_new_method_call( @@ -1637,12 +1673,12 @@ static int show(DBusConnection *bus, char **args, unsigned n) { r = -ENOMEM; goto finish; } - } - if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { - log_error("Failed to issue method call: %s", error.message); - r = -EIO; - goto finish; + if (!(reply = dbus_connection_send_with_reply_and_block(bus, m, -1, &error))) { + log_error("Failed to issue method call: %s", error.message); + r = -EIO; + goto finish; + } } if (!dbus_message_get_args(reply, &error,