Products › lamco-dbus-tools › Docs

dbussee-monitor: The helper that records the D-Bus system bus

dbussee-monitor, the helper that records the D-Bus system bus for one group without root: Why it runs apart, the frames it writes, and its privilege.

Describes version 0.4.1. The source of truth is src/dbussee_monitor.rs, src/privilege.rs and src/transport/helper.rs.

The helper becomes the monitor in the recorder's place, reads and guards in a process of its own, and passes each message to the recorder through a pipe. dbussee record, watch and pending run it with --helper, and by themselves for the system bus when not run as root. A person rarely runs it.

Why a process of its own

A guard inside the recorder can't act while the recorder is stopped. The helper leaves the recorder's session and process group when it starts, so Ctrl-Z at the recorder's terminal, or a debugger stopping the recorder, doesn't stop it. When the recorder stops reading the pipe, the helper sees more than its budget waiting to be passed on, closes its own connection, and exits 3. Measured on both bus implementations: A recorder held stopped by SIGSTOP behind the helper, while 300 signals of 64 KiB were sent, left the sender done in about 1.1 s and an unrelated service answering. Without the helper, the measurements of 2026-11-28 showed dbus-daemon stalling the sender and dbus-broker cutting it off.

Its command line

dbussee-monitor listen (--bus <session|system> | --address <address>) (--match <rule>... | --all)
                       [--budget-bytes <n>] [--accept-known-flaw]

It stops when its standard input closes, which is how the recorder stops it and which happens by itself when the recorder dies, or on SIGTERM.

Exit code Meaning
0 Stopped as asked
1 It couldn't connect, the bus refused to make it a monitor, its privilege was refused, or it refused the known flaw. It says why on standard error
2 A usage error
3 It detached itself: More than its budget waited to be passed on
4 The bus closed its connection

What it writes

Standard output carries the bytes LDTM1 and a newline, then frames, little-endian:

Frame Bytes
Hello, once H, a 32-bit length, then JSON: unique_name, rules, budget_bytes, budget_basis, pid, privileged, and from dbuskeep service: program, version, socket, window_ms, held_cap_bytes, listening_since_ns
Owners, from dbuskeep only O, a 32-bit length, then JSON: as_of_ns, the first message's arrival; names, each well-known name and its owner as of it; history_messages, how many of the messages that follow it kept; basis
A message, for each M, the arrival on CLOCK_MONOTONIC in nanoseconds (64 bits), the position (64 bits), a 32-bit length, then the message's bytes as the bus sent them
End, when it can E, a 32-bit length, then JSON: ended (stopped, detached, closed_by_bus or refused), detail, messages, bytes, high_water_bytes, started_ns, ended_ns

dbuskeep sends the same frames over its socket, so a recorder reads it as it reads the helper; The service reference has what it adds. After detaching the helper doesn't wait to write its end, since whoever reads has stopped; the exit code says instead. The recorder's capture names the helper, its process and whether it ran with privilege in the monitor record's helper.

Privilege, for the system bus

Only a privileged connection may monitor the system bus: Root on dbus-daemon by its policy, and root or the bus's own user on dbus-broker by its code. The helper is installed setuid root and executable by one group:

cargo build --release
sudo scripts/install-helper target/release/dbussee-monitor
sudo usermod -aG lamco-dbus-monitor NAME     # then NAME logs in again

That installs /usr/libexec/lamco-dbus-tools/dbussee-monitor, owned by root and the group lamco-dbus-monitor, mode 4750, as dbus-daemon-launch-helper is installed. sudo scripts/install-helper --uninstall removes it; the group is kept until groupdel.

Started setuid, the helper settles its privilege before anything else, while it has one thread:

  • Only the system bus. For any other bus, or an address, it gives up privilege for good, real, effective and saved uid, before connecting.
  • Only the group. It checks the caller is in lamco-dbus-monitor as well, so a file installed with the wrong mode still refuses others.
  • Not to be stopped by its caller. It makes its real uid root too, so the user who started it can't signal it. A user who could stop it could make the system bus stall or cut programs off.
  • A cap on what it holds. With privilege it holds at most 256 MiB for the recorder, whatever --budget-bytes asks, since it's root's memory, and the capture's budget basis says when that applied.
  • Only the system bus's own socket, /run/dbus/system_bus_socket, never an address from the environment.
  • The known flaw. It reads the system dbus-daemon's version, running the bus's own program as nobody, and refuses one older than 1.16.4 unless given --accept-known-flaw, as record does.

The recorder, for the system bus, takes the installed helper before one beside it.

What an authorized user gets is the whole of the system bus's traffic, as root would see it. Bodies are passed on whole, and the recorder keeps them as its --bodies says: As their length unless asked for more. Who's in the group is the decision that matters.