1 unstable release
0.2.0 | Aug 9, 2023 |
---|
#97 in #notification
13KB
75 lines
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 exec
s 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.
Dependencies
~12–25MB
~374K SLoC