summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-13 19:56:40 +0200
committerLennart Poettering <lennart@poettering.net>2011-07-13 19:59:28 +0200
commit0a524ba7c3d86f17e61928763633b5a817a7d020 (patch)
tree81f43976e885ecc7b32796146549d38b43dc5e63 /src
parent88e3dc903bd543a74b8699c1575b0da9eeab24a2 (diff)
unit: accept empty defaults for kill who/mode args
Diffstat (limited to 'src')
-rw-r--r--src/dbus-manager.c21
-rw-r--r--src/dbus-unit.c21
2 files changed, 34 insertions, 8 deletions
diff --git a/src/dbus-manager.c b/src/dbus-manager.c
index b4e2f86aba..4bed5c8845 100644
--- a/src/dbus-manager.c
+++ b/src/dbus-manager.c
@@ -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))) {
diff --git a/src/dbus-unit.c b/src/dbus-unit.c
index ad8e9a1aef..266fb39be2 100644
--- a/src/dbus-unit.c
+++ b/src/dbus-unit.c
@@ -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)