[systemd-commits] 2 commits - src/systemctl.c src/util.c

Lennart Poettering lennart at kemper.freedesktop.org
Tue Jul 6 11:34:03 PDT 2010


 src/systemctl.c |   47 ++++++++++++++++++++++++++++++++++++++++++-----
 src/util.c      |    2 ++
 2 files changed, 44 insertions(+), 5 deletions(-)

New commits:
commit 057fbb58851f97cfcf4d90d5d3c539ac6f8ab13d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jul 6 20:15:08 2010 +0200

    util: fix space calculation in get_process_cmdline()

diff --git a/src/util.c b/src/util.c
index 8c22dbe..d1120c6 100644
--- a/src/util.c
+++ b/src/util.c
@@ -601,6 +601,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, char **line) {
                                         break;
 
                                 *(k++) = ' ';
+                                left--;
                                 space = false;
                         }
 
@@ -608,6 +609,7 @@ int get_process_cmdline(pid_t pid, size_t max_length, char **line) {
                                 break;
 
                         *(k++) = (char) c;
+                        left--;
                 }  else
                         space = true;
         }
commit ed2d7a4465f682be651ae95df6a60816bf7dce31
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Jul 6 20:14:51 2010 +0200

    systemctl: when we cannot load a unit, retry with getting it

diff --git a/src/systemctl.c b/src/systemctl.c
index 9b88da1..02c8e30 100644
--- a/src/systemctl.c
+++ b/src/systemctl.c
@@ -856,6 +856,7 @@ static int check_unit(DBusConnection *bus, char **args, unsigned n) {
                         if (!arg_quiet)
                                 puts("unknown");
 
+                        dbus_error_free(&error);
                         continue;
                 }
 
@@ -1618,6 +1619,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 +1674,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,


More information about the systemd-commits mailing list