Products › lamco-dbus-tools › Docs

Build lamco-dbus-tools from source

Build lamco-dbus-tools from source with cargo: The five programs, static builds for x86_64 and for 64-bit ARM (run only under emulation), and the D-Bus tests.

Describes version 0.4.1.

What's needed

  • Rust 1.89 or newer, with cargo.
  • Nothing else to build. The package links no C library.
  • To run the tests: dbus-daemon, and dbus-broker with systemd-socket-activate for the tests of that implementation. No test touches the session or system bus of the machine. Each starts a private bus.

Build

cargo build --release

Five programs are written to target/release/: dbussee, dbusdo, dbustell, dbuskeep and dbussee-monitor.

Build one static file

A static program has no dependency on the machine's libraries. It's the form to attach to a bug report, copy into a container, or run inside a sandbox.

rustup target add x86_64-unknown-linux-musl
cargo build --release --target x86_64-unknown-linux-musl

The programs are in target/x86_64-unknown-linux-musl/release/. dbussee is about 1.2 MB in this version.

Build for 64-bit ARM, from an x86_64 machine

No ARM toolchain is needed beyond the Rust target, since Rust's own linker links it.

rustup target add aarch64-unknown-linux-musl
RUSTFLAGS="-C linker=rust-lld -C link-self-contained=yes" \
    cargo build --release --target aarch64-unknown-linux-musl

The result is a static 64-bit ARM program. It has run only under emulation: On 2026-11-28, dbussee and dbustell of this version, and a test program that served, called and monitored on a private dbus-daemon 1.16.2, ran on Debian 13 for 64-bit ARM (kernel 6.12, an emulated machine).

Run the gate

scripts/gate

It checks that the mirrored sources match their table, the formatting, clippy at the pedantic level with warnings denied, the tests, and both static builds. Each step is judged by its own exit code. A step that couldn't run is listed as NOT RUN and never counted as passed: On a machine without dbus-broker the summary says its tests weren't run.

Test against dbus-broker without installing it

On Debian, installing the dbus-broker package makes it the machine's own bus at the next boot. The package's install script says so: "Replacing the running dbus-daemon with dbus-broker requires a reboot". To test against dbus-broker and leave the machine's bus alone, unpack the package and name the directory:

apt-get download dbus-broker
dpkg-deb -x dbus-broker_*.deb ~/.local/opt/dbus-broker
LAMCO_DBUS_BROKER_DIR=~/.local/opt/dbus-broker/usr/bin scripts/gate

Nothing is installed and no privilege is used. dbus-broker's launcher starts the broker from the fixed path /usr/bin/dbus-broker, so the test harness runs the launcher inside a mount namespace of its own, made by bwrap, in which the two unpacked programs appear at that path. bwrap has to be installed.

The launcher of a private dbus-broker opens one ordinary connection to the user's own bus, to reach the service manager. That's how dbus-broker works, and it's the only contact a test has with the machine's bus.

Where there's no user's bus and no user's service manager, as on a CI runner or over a bare ssh login, dbus-broker can't start services: Its launcher starts each through the user's systemd manager. Ubuntu 24.04's dbus-broker 35 goes further and exits without the user's bus, taking the broker with it, so every test on dbus-broker fails with a broken pipe (run 2026-12-04 in an Ubuntu 24.04 container and on GitHub's runner). sudo loginctl enable-linger $USER starts both for your user, as the CI workflow does.

Fuzz the readers

fuzz/ holds a fuzz target for each reader of input other people write: capture (a capture file, read and then summarized as dbustell health does), pcap (a pcap or pcapng file, imported every way of keeping bodies), wire (one message's header), helper_frames (the helper's output), introspection (an interface description), keyfile (a sandbox's key file), policy (a bus policy file, read as each implementation reads it) and polkit_actions (a polkit action file). They need cargo-fuzz and a nightly toolchain:

cargo install cargo-fuzz
cargo +nightly fuzz run -O capture -- -max_total_time=900

A crash leaves its input under fuzz/artifacts/. Each target starts from an empty corpus unless given one; the repository's own captures, pcap files, XML and policy files are good seeds.

Run 2026-12-04 for 15 minutes each, from the repository's files as seeds. The policy reader panicked on a file that begins with a byte-order mark, at two places that cut its text at the XML reader's byte offset, and the polkit reader had the same flaw. Then it took more than ten seconds on a file whose <includedir> named its own directory, twice, so it read itself again at every level: It now refuses a file that includes itself, as dbus-daemon does. Each input is a test. The policy reader's last 15 minutes, 3.9 million inputs, and the polkit reader's, about a million, found nothing more, and no other target found anything.

What can go wrong

  • mirror: src/... differs from the table: A mirrored file was edited here. Those five files are owned by lamco-dsi-tools. Restore the file, and make the change there. See docs/reference/mirrored-sources.md.
  • A test fails with ... is not installed, and LAMCO_DBUS_TOOLS_ALLOW_MISSING does not name it: A bus implementation is missing. Install it, or run the tests through scripts/gate, which names what's missing and reports it as not run.