chiark / gitweb /
unit: when deserializing jobs, don't pull in dependencies
[elogind.git] / src / dbus-unit.c
index 45eba8ab55752344e0a816ea4a7d7dc31bd1d522..563ef7079a89e5500a31d25d61cd752fcbad5e4f 100644 (file)
@@ -26,7 +26,7 @@
 #include "dbus-unit.h"
 #include "bus-errors.h"
 
-const char bus_unit_interface[] = BUS_UNIT_INTERFACE;
+const char bus_unit_interface[] _introspect_("Unit") = BUS_UNIT_INTERFACE;
 
 #define INVALIDATING_PROPERTIES                 \
         "LoadState\0"                           \
@@ -37,8 +37,7 @@ const char bus_unit_interface[] = BUS_UNIT_INTERFACE;
         "ActiveExitTimestamp\0"                 \
         "InactiveEnterTimestamp\0"              \
         "Job\0"                                 \
-        "NeedDaemonReload\0"                    \
-        "\0"
+        "NeedDaemonReload\0"
 
 int bus_unit_append_names(Manager *m, DBusMessageIter *i, const char *property, void *data) {
         char *t;
@@ -367,6 +366,34 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ReloadOrTryRestart")) {
                 reload_if_possible = true;
                 job_type = JOB_TRY_RESTART;
+        } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Kill")) {
+                const char *swho, *smode;
+                int32_t signo;
+                KillMode mode;
+                KillWho who;
+                int r;
+
+                if (!dbus_message_get_args(
+                                    message,
+                                    &error,
+                                    DBUS_TYPE_STRING, &swho,
+                                    DBUS_TYPE_STRING, &smode,
+                                    DBUS_TYPE_INT32, &signo,
+                                    DBUS_TYPE_INVALID))
+                        return bus_send_error_reply(m, connection, message, &error, -EINVAL);
+
+                if ((mode = kill_mode_from_string(smode)) < 0 ||
+                    (who = kill_who_from_string(swho)) < 0 ||
+                    signo <= 0 ||
+                    signo >= _NSIG)
+                        return bus_send_error_reply(m, connection, message, &error, -EINVAL);
+
+                if ((r = unit_kill(u, who, mode, signo, &error)) < 0)
+                        return bus_send_error_reply(m, connection, message, &error, r);
+
+                if (!(reply = dbus_message_new_method_return(message)))
+                        goto oom;
+
         } else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "ResetFailed")) {
 
                 unit_reset_failed(u);
@@ -539,8 +566,13 @@ static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DB
                 if (r == -ENOMEM)
                         return DBUS_HANDLER_RESULT_NEED_MEMORY;
 
-                if (r == -ENOENT)
-                        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+                if (r == -ENOENT) {
+                        DBusError e;
+
+                        dbus_error_init(&e);
+                        dbus_set_error_const(&e, DBUS_ERROR_UNKNOWN_OBJECT, "Unknown unit");
+                        return bus_send_error_reply(m, connection, message, &e, r);
+                }
 
                 return bus_send_error_reply(m, connection, message, NULL, r);
         }