diff options
author | Rodrigo Moya <rodrigo.moya@collabora.co.uk> | 2012-06-15 09:50:19 +0200 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2012-06-15 09:50:19 +0200 |
commit | 837b047e3246c638d9c1085cd5b8e0a022328db2 (patch) | |
tree | 4d42d2800ea91c7d85f7d61e1c87677d44765ef2 | |
parent | d230f861c2dacb31d811cacb4c0ff2a134d3f30b (diff) | |
download | dbus-837b047e3246c638d9c1085cd5b8e0a022328db2.tar.gz |
Set eavesdropping on when a match rule includes 'eavesdrop=true'
-rw-r--r-- | bus/driver-afbus.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/bus/driver-afbus.c b/bus/driver-afbus.c index 2591300d..e64e34f1 100644 --- a/bus/driver-afbus.c +++ b/bus/driver-afbus.c @@ -190,7 +190,34 @@ bus_driver_afbus_add_match_rule (DBusConnection *connection, const char *rule, DBusError *error) { - return bus_driver_afbus_upload_match_rule (connection, rule, NFDBUS_CMD_ADDMATCH, error); + if (bus_driver_afbus_upload_match_rule (connection, rule, NFDBUS_CMD_ADDMATCH, error)) + { + /* Check if the match rule is for eavesdropping, and set the socket + * to allow receiving all messages if so */ + if (strstr (rule, "eavesdrop=true")) + { + int fd; + + if (dbus_connection_get_socket (connection, &fd)) + { + if (setsockopt (fd, SOL_BUS, BUS_SET_EAVESDROP, NULL, 0) == 0) + return TRUE; + else + { + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to setsockopt on socket %d: %s", + fd, _dbus_strerror (errno)); + } + } + else + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + } + else + return TRUE; + } + + return FALSE; } dbus_bool_t |