diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-01-23 19:11:31 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-02-04 17:15:08 +0000 |
commit | 00af6389be46d65afcce8cdfd060f278aaaa9466 (patch) | |
tree | f5f32aadd98ef4e46b97453a01fa582600acba4b /bus/driver.c | |
parent | 4a0f1849be319b1b2b7a6d415b57e5544ec191d6 (diff) | |
download | dbus-00af6389be46d65afcce8cdfd060f278aaaa9466.tar.gz |
Add support for morphing a D-Bus connection into a "monitor"
This is a special connection that is not allowed to send anything,
and loses all its well-known names.
In future commits, it will get a new set of match rules and the
ability to eavesdrop on messages before the rest of the bus daemon
has had a chance to process them.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Diffstat (limited to 'bus/driver.c')
-rw-r--r-- | bus/driver.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/bus/driver.c b/bus/driver.c index 6e8a6dac..ac29b9f1 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1788,6 +1788,35 @@ bus_driver_handle_get_id (DBusConnection *connection, return FALSE; } +static dbus_bool_t +bus_driver_handle_become_monitor (DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (!bus_driver_check_message_is_for_us (message, error)) + return FALSE; + + if (!bus_driver_check_caller_is_privileged (connection, transaction, + message, error)) + return FALSE; + + /* Send the ack before we remove the rule, since the ack is undone + * on transaction cancel, but becoming a monitor isn't. + */ + if (!send_ack_reply (connection, transaction, message, error)) + return FALSE; + + /* FIXME: use the array of filters from the message */ + + if (!bus_connection_be_monitor (connection, transaction, error)) + return FALSE; + + return TRUE; +} + typedef struct { const char *name; @@ -1889,6 +1918,11 @@ static const MessageHandler introspectable_message_handlers[] = { { NULL, NULL, NULL, NULL } }; +static const MessageHandler monitoring_message_handlers[] = { + { "BecomeMonitor", "asu", "", bus_driver_handle_become_monitor }, + { NULL, NULL, NULL, NULL } +}; + #ifdef DBUS_ENABLE_STATS static const MessageHandler stats_message_handlers[] = { { "GetStats", "", "a{sv}", bus_stats_handle_get_stats }, @@ -1920,6 +1954,7 @@ static InterfaceHandler interface_handlers[] = { " <arg type=\"s\"/>\n" " </signal>\n" }, { DBUS_INTERFACE_INTROSPECTABLE, introspectable_message_handlers, NULL }, + { DBUS_INTERFACE_MONITORING, monitoring_message_handlers, NULL }, #ifdef DBUS_ENABLE_STATS { BUS_INTERFACE_STATS, stats_message_handlers, NULL }, #endif |