fix(rc.d): use child pidfile + unique procname for colibri-daemon (Sam & Hermes)

Fix three bugs identified in live USB diagnostics (COLIBRI-XFCE-HANDOFF-04.JUN.2026):

1. procname collision: 'colibri-daemon' instead of '/usr/sbin/daemon'
   so service status finds OUR process, not tailscaled or any other
   daemon(8)-managed service.

2. pidfile flag: -p (child pidfile) instead of -P (supervisor pidfile)
   so the pidfile holds the colibri-daemon PID, which rc.subr can
   match against the unique procname.

3. Cascading bypass: fixing procname prevents rc.subr from skipping
   daemon(8) entirely. Process tree should now be:
   rc.d → daemon(8) → colibri-daemon (with crash restart)
This commit is contained in:
123kupola 2026-06-04 09:53:55 +02:00
parent 067fee778c
commit 4f4d36b0ea

View file

@ -4,8 +4,8 @@
#
# colibri-daemon runs in the FOREGROUND — it does not self-daemonize or write a
# pidfile. rc.d runs it under daemon(8), which backgrounds it, writes the
# supervisor pidfile, restarts on crash, drops privileges to the colibri user,
# and redirects stdout/stderr (tracing) to a logfile.
# child pidfile (colibri-daemon PID), restarts on crash, drops privileges to
# the colibri user, and redirects stdout/stderr (tracing) to a logfile.
#
# Setup (one-time, as root):
# pw groupadd colibri
@ -48,15 +48,17 @@ load_rc_config $name
pidfile="${colibri_daemon_run_dir}/colibri-daemon.pid"
# Run colibri-daemon under daemon(8): -P supervisor pidfile, -r restart on exit,
# -t process title, -u drop to the colibri user, -o append stdout/stderr to log.
# Run colibri-daemon under daemon(8): -p child pidfile (writes colibri-daemon PID),
# -r restart on exit, -t process title, -u drop to the colibri user, -o append
# stdout/stderr to log.
command="/usr/sbin/daemon"
command_args="-P ${pidfile} -r -t ${name} -u ${colibri_daemon_user} \
command_args="-p ${pidfile} -r -t ${name} -u ${colibri_daemon_user} \
-o ${colibri_daemon_logfile} ${colibri_daemon_program}"
# rc.subr matches the pidfile's process against ${procname}; that is daemon(8),
# not colibri-daemon, since daemon(8) is the supervised parent.
procname="/usr/sbin/daemon"
# Use the child's process name so rc.subr can find the right process via the
# child pidfile. Using the daemon(8) supervisor path would collide with
# tailscaled and other daemon(8)-managed services on the system.
procname="colibri-daemon"
start_precmd="colibri_daemon_prestart"
start_postcmd="colibri_daemon_poststart"