From 18458807574ec84f2bba4597ea5f8c925037d5f4 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 16 Jul 2015 14:37:08 +0200 Subject: sd-bus: properly match ID changes If the caller does not specify arg1 for NameOwnerChanged matches, we really must take the ID from arg2 or arg3, if provided. They are guaranteed to be identical to arg1 if either is supplied, but there is no strict requiredment that arg1 is supplied. Hence, make sure to always take the more restrictive match. Otherwise, we install rather wide matches without anyone requiring them. --- src/libsystemd/sd-bus/bus-control.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/libsystemd/sd-bus/bus-control.c') diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c index 526e1aa89f..99115d5e49 100644 --- a/src/libsystemd/sd-bus/bus-control.c +++ b/src/libsystemd/sd-bus/bus-control.c @@ -1187,6 +1187,8 @@ static int add_name_change_match(sd_bus *bus, * match against added ids */ if (!old_owner || old_owner[0] == 0) { item->type = KDBUS_ITEM_ID_ADD; + if (!isempty(new_owner)) + item->id_change.id = new_owner_id; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) @@ -1197,6 +1199,8 @@ static int add_name_change_match(sd_bus *bus, * match against removed ids */ if (!new_owner || new_owner[0] == 0) { item->type = KDBUS_ITEM_ID_REMOVE; + if (!isempty(old_owner)) + item->id_change.id = old_owner_id; r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_ADD, m); if (r < 0) -- cgit v1.2.3-54-g00ecf