Products › lamco-dbus-tools › Interfaces

D-Bus match rules and AddMatch: How each bus applies them

D-Bus match rules and AddMatch decide which messages a connection or monitor gets, and lamco-dbus-tools found four rules dbus-daemon and dbus-broker read apart.

D-Bus methods AddMatch, RemoveMatch

A match rule is a string such as type='signal',interface='org.freedesktop.Notifications' that tells the bus which messages a connection wants. Clients add them with AddMatch to receive signals, and remove them with RemoveMatch. A monitor is given its rules all at once with BecomeMonitor. Anyone who filters a recording with busctl or dbus-monitor writes them. lamco-dbus-tools takes any rule for a recording, builds its own for a service, and found four rules the two bus implementations read differently.

What it is

AddMatch and RemoveMatch are methods of org.freedesktop.DBus, each taking one string. The specification gives the format: Comma-separated key=value pairs, and a key left out matches anything. The keys:

  • type: signal, method_call, method_return or error.
  • sender, destination, interface, member, path and path_namespace.
  • arg0 to arg63, which compare a string argument, and argNpath and arg0namespace.
  • eavesdrop, which is how monitoring was done before BecomeMonitor. The specification calls that use deprecated.

For an ordinary connection, rules mainly select broadcast signals, since messages addressed to it arrive regardless. For a monitor they select from everything, calls and replies included. RemoveMatch removes the first rule equal to the one given.

The repository's reading of both implementations' source, held to the running buses by a test, found four rules read differently:

  • destination: dbus-daemon applies it. dbus-broker 37 parses it and never applies it, so a rule naming one takes every message the rest of the rule takes.
  • path_namespace='/': Every path on dbus-daemon, only / itself on dbus-broker.
  • An unquoted backslash before a comma: dbus-daemon keeps the comma in the value, and dbus-broker ends the value there, as the specification says.
  • NameAcquired for a new name: dbus-daemon sends it before it records the owner, so a rule with that name as destination misses it.

The first has a direct consequence: A recording of one service on dbus-broker, which needs a rule with destination, takes the whole bus.

dbus-broker before 37 reads two more keys apart. For every argN it checked the type of the zeroth argument, and for argNpath it compared the zeroth argument in one direction, so arg1='beta' missed a signal whose zeroth argument is an object path. Its commit f805f41 fixed both in 37, and Ubuntu 24.04 ships dbus-broker 35. dbuskeep reads the version of the dbus-broker it keeps and applies a reader's rules as that version does. Run on 2026-12-04 with dbus-broker 35 in an Ubuntu 24.04 container, its 23 test rules each gave the same messages from the bus and through the service (match rules, as the toolkit reads them).

How lamco-dbus-tools reads it

dbussee record --match takes any rule and checks it before anything is sent. --service NAME stands for two rules, sender='NAME' and destination='NAME', and --all asks for everything. On dbus-broker a rule with destination prints a note before the recording begins. Reading through dbuskeep, the service applies the rules itself, the way the bus it watches would, and --rules-as-specified has it apply them as the specification reads them on either bus. The capture records who filtered. dbustell compare sets two captures side by side in what lasts, such as the methods called and the errors seen, so two recordings taken with different rules can be told apart.

dbussee record --match "type='signal',interface='org.freedesktop.Notifications'" --duration 10 --out sig.json   # any rule
dbussee record --service org.freedesktop.Notifications --duration 30 --out notify.json   # sender or destination
dbussee record --service com.example.Svc --rules-as-specified --out svc.json   # through dbuskeep, as the specification reads rules
dbustell compare broker.json specified.json   # what differs between two captures

Where it has been run

The README's run record lists dbuskeep applying 23 rules message for message as each bus applies them, and four differences between the buses found and confirmed in their source, on 2026-12-01. The record doesn't say which bus releases that run used, and dbus-daemon releases other than 1.14.10 and 1.16.2, and dbus-broker releases other than 37, aren't recorded either way.

Findings

  • BUS-004: dbus-broker took messages to anyone for a rule naming a destination.
  • SIG-001: A signal came in a storm.

Related