]> err.no Git - systemd/commitdiff
unit: accept empty defaults for kill who/mode args
authorLennart Poettering <lennart@poettering.net>
Wed, 13 Jul 2011 17:56:40 +0000 (19:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Jul 2011 17:59:28 +0000 (19:59 +0200)
src/dbus-manager.c
src/dbus-unit.c

index b4e2f86aba51d4fee14c30ac231e65c402041a23..4bed5c88459641b0a7f263da8ceb47807d98b1a8 100644 (file)
@@ -542,10 +542,23 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection,
                                     DBUS_TYPE_INVALID))
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
-                if ((mode = kill_mode_from_string(smode)) < 0 ||
-                    (who = kill_who_from_string(swho)) < 0 ||
-                    signo <= 0 ||
-                    signo >= _NSIG)
+                if (isempty(swho))
+                        who = KILL_ALL;
+                else {
+                        who = kill_who_from_string(swho);
+                        if (who < 0)
+                                return bus_send_error_reply(connection, message, &error, -EINVAL);
+                }
+
+                if (isempty(smode))
+                        mode = KILL_CONTROL_GROUP;
+                else {
+                        mode = kill_mode_from_string(smode);
+                        if (mode < 0)
+                                return bus_send_error_reply(connection, message, &error, -EINVAL);
+                }
+
+                if (signo <= 0 || signo >= _NSIG)
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
                 if (!(u = manager_get_unit(m, name))) {
index ad8e9a1aef2090c472f05c423c373d9fa6d81a57..266fb39be20e1e8ca0babc3f0b4cc941a4e9744b 100644 (file)
@@ -372,10 +372,23 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *conn
                                     DBUS_TYPE_INVALID))
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
-                if ((mode = kill_mode_from_string(smode)) < 0 ||
-                    (who = kill_who_from_string(swho)) < 0 ||
-                    signo <= 0 ||
-                    signo >= _NSIG)
+                if (isempty(swho))
+                        who = KILL_ALL;
+                else {
+                        who = kill_who_from_string(swho);
+                        if (who < 0)
+                                return bus_send_error_reply(connection, message, &error, -EINVAL);
+                }
+
+                if (isempty(smode))
+                        mode = KILL_CONTROL_GROUP;
+                else {
+                        mode = kill_mode_from_string(smode);
+                        if (mode < 0)
+                                return bus_send_error_reply(connection, message, &error, -EINVAL);
+                }
+
+                if (signo <= 0 || signo >= _NSIG)
                         return bus_send_error_reply(connection, message, &error, -EINVAL);
 
                 if ((r = unit_kill(u, who, mode, signo, &error)) < 0)