service: bind the systemd notify socket before fork

A notify:systemd service that calls sd_notify() early could lose its
READY=1 and never become ready.  Seen with udevd in an initramfs.

The socket address contained the PID of the service, so it was bound
in the parent after fork(), racing the service.

Let the kernel pick a unique abstract address instead, bound before
fork(), and pass it in NOTIFY_SOCKET.

Fixes #505

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-11-17 06:21:26 +01:00
1 parent 14fd315f38
commit a162551896
2 files changed
+34 -23

No files matched your search

+3
View File
@@ -166,6 +166,9 @@ All relevant changes are documented in this file.
- Fix #503: keventd did not touch its PID file after SIGHUP, so with a
daemon-owned PID file Finit never saw it reassert readiness after a
reload. Reported by Aaron Andersen
- Fix #505: a `notify:systemd` service could send `READY=1` before Finit
had bound the notify socket, losing it, so the service never became
ready. Seen with udevd in an initramfs. Reported by Aaron Andersen
- Fix a command whose name starts like a service option, e.g. `logger` or
`pidof`. It was taken as the `log` or `pid` option and the next argument
ran as the command, which also broke the `logger` example in finit.conf(5)