[avahi] [PATCH] D-Bus NameOwnerChanged: better match rule
Alban Crequy
alban.crequy at collabora.co.uk
Tue Jul 15 06:37:06 PDT 2014
When subscribing to the D-Bus signal NameOwnerChanged from the bus driver,
specify the object path and the sender in the match rule. Otherwise, random
connections on the bus could impersonate the bus driver.
In addition, specify the member NameOwnerChanged in the match rules: the other
D-Bus signals received don't require a match rule to be received.
---
avahi-daemon/dbus-protocol.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/avahi-daemon/dbus-protocol.c b/avahi-daemon/dbus-protocol.c
index eb8a662..03c2930 100644
--- a/avahi-daemon/dbus-protocol.c
+++ b/avahi-daemon/dbus-protocol.c
@@ -1111,7 +1111,16 @@ static int dbus_connect(void) {
goto fail;
}
- dbus_bus_add_match(server->bus, "type='signal',""interface='" DBUS_INTERFACE_DBUS "'", &error);
+ /* Only register the rule for NameOwnerChanged.
+ * NameAcquired and Disconnected don't require a match rule to be received.
+ */
+ dbus_bus_add_match(server->bus,
+ "type='signal',"
+ "path='" DBUS_PATH_DBUS "',"
+ "interface='" DBUS_INTERFACE_DBUS "',"
+ "member='NameOwnerChanged',"
+ "sender='"DBUS_SERVICE_DBUS"'",
+ &error);
if (dbus_error_is_set(&error)) {
avahi_log_error("dbus_bus_add_match(): %s", error.message);
--
1.8.5.3
More information about the avahi
mailing list