mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-27 04:30:08 +01:00
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>
This commit is contained in:
parent
b994830c7f
commit
faaa092f20
1 changed files with 25 additions and 6 deletions
|
|
@ -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)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue