dbus-waiter

Crates.iodbus-waiter
lib.rsdbus-waiter
version0.2.0
sourcesrc
created_at2023-08-09 14:38:00.758612
updated_at2023-08-09 14:38:00.758612
descriptionImplement readiness notifications for dbus services
homepagehttps://git.sr.ht/~whynothugo/dbus-waiter
repository
max_upload_size
id940105
size39,837
Hugo (WhyNotHugo)

documentation

README

dbus-waiter

dbus-waiter is a small program that implements readiness checks for services that take D-Bus names.

Usage

dbus-waiter --notify-fd FD --bus-name BUS_NAME PROG...

The following example executes xdg-desktop-portal, and sends a readiness notification on file descriptor 3 once the executed process takes the bus named org.freedesktop.portal.Desktop:

dbus-waiter \
    --notify-fd 3 \
    --bus-name org.freedesktop.portal.Desktop \
    /usr/libexec/xdg-desktop-portal

The implemented readiness notification mechanism works on both systemd and s6.

If no file descriptor matches the value of --notify-fd, the output error will include:

Error: Invalid argument (os error 22)

Implementation

dbus-waiter first forks. The child process listens to NameOwnerChanged events for bus BUS_NAME. The parent execs into PROG.

When BUS_NAME has a new owner, if the owner is the parent process, the child will send a readiness notification and exit.

If a different process takes over the BUS_NAME, the child will exit immediately. In this error scenario the readiness check is expected time out, and the supervisor should kill the parent process.

Caveats

  • Attacks based on PID re-use are theoretically possible, although the attacker needs to have permissions to take BUS_NAME on the specified bus.

See also

LICENCE

This project is licensed under the ISC licence. See LICENCE for details.

Commit count: 0

cargo fmt