diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-02-02 19:45:17 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2015-02-04 17:15:17 +0000 |
commit | 9fce7380331d24e8dd5fb9203eb8275ebb49e1d8 (patch) | |
tree | 6f655086533c73df8b24166c0e7b39f38b7939f3 /bus/dispatch.c | |
parent | 00af6389be46d65afcce8cdfd060f278aaaa9466 (diff) | |
download | dbus-9fce7380331d24e8dd5fb9203eb8275ebb49e1d8.tar.gz |
Capture all messages received or sent, and send them to monitors
Unlike eavesdropping, the point of capture is when the message is
received, except for messages originating inside the dbus-daemon.
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787
Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r-- | bus/dispatch.c | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c index 97fe3712..630f814c 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -291,6 +291,10 @@ bus_dispatch (DBusConnection *connection, { /* DBusConnection also handles some of these automatically, we leave * it to do so. + * + * FIXME: this means monitors won't get the opportunity to see + * non-signals with NULL destination, or their replies (which in + * practice are UnknownMethod errors) */ result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; goto out; @@ -316,13 +320,30 @@ bus_dispatch (DBusConnection *connection, BUS_SET_OOM (&error); goto out; } + } + else + { + /* For monitors' benefit: we don't want the sender to be able to + * trick the monitor by supplying a forged sender, and we also + * don't want the message to have no sender at all. */ + if (!dbus_message_set_sender (message, ":not.active.yet")) + { + BUS_SET_OOM (&error); + goto out; + } + } - /* We need to refetch the service name here, because - * dbus_message_set_sender can cause the header to be - * reallocated, and thus the service_name pointer will become - * invalid. - */ - service_name = dbus_message_get_destination (message); + /* We need to refetch the service name here, because + * dbus_message_set_sender can cause the header to be + * reallocated, and thus the service_name pointer will become + * invalid. + */ + service_name = dbus_message_get_destination (message); + + if (!bus_transaction_capture (transaction, connection, message)) + { + BUS_SET_OOM (&error); + goto out; } if (service_name && @@ -402,14 +423,10 @@ bus_dispatch (DBusConnection *connection, out: if (dbus_error_is_set (&error)) { - if (!dbus_connection_get_is_connected (connection)) - { - /* If we disconnected it, we won't bother to send it any error - * messages. - */ - _dbus_verbose ("Not sending error to connection we disconnected\n"); - } - else if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) + /* Even if we disconnected it, pretend to send it any pending error + * messages so that monitors can observe them. + */ + if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY)) { bus_connection_send_oom_error (connection, message); |