summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChengwei Yang <chengwei.yang@intel.com>2013-10-09 10:44:12 +0800
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-10-09 11:26:46 +0100
commitfaaa092f20fce37e8b8ceb57b388cd8e90f3d8de (patch)
tree5c17373aab4406a152b97276d0e72319e139c996 /tools
parentb994830c7f6e201e8e8c3e6d8eaeb67191b9338a (diff)
downloaddbus-faaa092f20fce37e8b8ceb57b388cd8e90f3d8de.tar.gz
dbus-monitor: keep backwards compatibility
eavesdropping as a match rule key introduced in DBus 1.5.6, and the privous implementation doesn't keep backwards compatibility with older dbus-daemon. And the reference dbus-daemon implementation just fail if unknwon key found in match rule, this is undefined hehavior in DBus Sepcification. Also there is a feature request for change this hehavior to "ignore unknown key in match rule", See https://bugs.freedesktop.org/show_bug.cgi?id=66114 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'tools')
-rw-r--r--tools/dbus-monitor.c31
1 files changed, 25 insertions, 6 deletions
diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c
index 1aa885f7..ff8390d7 100644
--- a/tools/dbus-monitor.c
+++ b/tools/dbus-monitor.c
@@ -367,26 +367,45 @@ main (int argc, char *argv[])
if (numFilters)
{
+ size_t offset = 0;
for (i = 0; i < j; i++)
{
- dbus_bus_add_match (connection, filters[i], &error);
- if (dbus_error_is_set (&error))
+ dbus_bus_add_match (connection, filters[i] + offset, &error);
+ if (dbus_error_is_set (&error) && i == 0 && offset == 0)
+ {
+ /* We might be talking to a pre-1.5.6 dbus-daemon
+ * which wouldn't understand eavesdrop=true.
+ * If this works, carry on with offset > 0
+ * on the remaining iterations. */
+ offset = strlen (EAVESDROPPING_RULE) + 1;
+ dbus_error_free (&error);
+ dbus_bus_add_match (connection, filters[i] + offset, &error);
+ }
+
+ if (dbus_error_is_set (&error))
{
fprintf (stderr, "Failed to setup match \"%s\": %s\n",
filters[i], error.message);
dbus_error_free (&error);
exit (1);
}
- free(filters[i]);
+ free(filters[i]);
}
}
else
{
dbus_bus_add_match (connection,
- EAVESDROPPING_RULE,
- &error);
+ EAVESDROPPING_RULE,
+ &error);
if (dbus_error_is_set (&error))
- goto lose;
+ {
+ dbus_error_free (&error);
+ dbus_bus_add_match (connection,
+ "",
+ &error);
+ if (dbus_error_is_set (&error))
+ goto lose;
+ }
}
if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) {