busctl: also monitor messages to SERVICE arguments
authorLars Uebernickel <lars@uebernic.de>
Tue, 22 Sep 2015 22:06:18 +0000 (00:06 +0200)
committerLars Uebernickel <lars@uebernic.de>
Tue, 22 Sep 2015 22:06:18 +0000 (00:06 +0200)
Add a 'destination' match rule for every SERVICE argument in addition to
the 'sender' rule. This is consistent with busctl(1), which documents
monitor as dumping "messages to or from this peer".

src/libsystemd/sd-bus/busctl.c

index 09eba51..5d07d58 100644 (file)
@@ -1096,6 +1096,15 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
                 if (r < 0)
                         return log_error_errno(r, "Failed to add match: %m");
 
+                free(m);
+                m = strjoin("destination='", *i, "'", NULL);
+                if (!m)
+                        return log_oom();
+
+                r = sd_bus_add_match(bus, NULL, m, NULL, NULL);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to add match: %m");
+
                 added_something = true;
         }