Skip to main content

Module systemd_dbus

Module systemd_dbus 

Source
Expand description

A minimal D-Bus client for the user session bus, for the provisioning’s two calls. What: A minimal D-Bus client for the user session bus: authenticate as the current user, say Hello, and call methods of org.freedesktop.systemd1.Manager with string arguments, each bounded by one deadline for the whole exchange. Why: The wrapper provisions socket activation itself, and may start no program to do it (systemctl would be one). The supported surface of the user manager is its D-Bus API (org.freedesktop.systemd1(5)), reached through the session bus; the manager’s own private socket is documented as private to systemd. Only Reload and StartUnit are needed, both with at most two string arguments, so the writer and the reader below cover exactly the types those calls and the bus’s replies use (s, o, g, u) and stop at anything else. The reader is total over arbitrary bytes (a fuzz target holds it to that). The comparison with a D-Bus crate is in doc/planning/cli-git-resident-service.md, “Provisioning”.

In TS you’d write (pseudocode):

const bus = await connect(address, 5000); await bus.startUnit('cli-git.socket', 'replace'); // throws with the error name

Structs§

Bus
An authenticated connection to the session bus, past Hello.
Reply
A reply: its type, the error name its header carries, and the first string of its body.
Target
Where a method call goes.

Enums§

CallError
Why a call did not succeed.

Constants§

EXCHANGE_WAIT
How long the whole exchange (connect, authenticate, say hello, make the calls) may take; a stuck bus never holds a commit longer.
HELLO
Hello on the bus daemon, the first call of every connection.
MANAGER_INTERFACE
The manager’s interface.
MANAGER_NAME
The manager’s bus name.
MANAGER_PATH
The manager’s object path.
RELOAD
Reload on the user manager.
START_UNIT
StartUnit on the user manager.

Functions§

decode_reply
What: Reads a complete reply message. Why: Only the type, the error name and the first string of the body matter; a header field of a kind this reader does not know ends the walk of the header, which is safe because the fields it needs come first in what the manager sends or are looked for before any unknown kind.
encode_call
What: The bytes of a method call with string arguments. Why: Kept apart from the socket so a test can read them back and compare them with the specification’s layout.
session_bus_path
The path of the session bus socket: the unix:path= entry of the address variable, else $XDG_RUNTIME_DIR/bus.