fix(rc): clear stale colibri socket before start (Sam & Codex)
Some checks failed
CI / rust (pull_request) Has been cancelled
CI / markdown (pull_request) Has been cancelled

Remove stale socket and pidfiles in prestart while rc.d still has root privileges. This handles live USB repair cases where a previous corrupt/root-started daemon left /var/run/colibri/colibri.sock owned by root, causing the colibri user to fail unlink with EPERM and bind with EADDRINUSE.\n\nChecks: sh -n packaging/freebsd/colibri_daemon.in; git diff --check.
This commit is contained in:
Sam & Claude 2026-06-14 22:39:52 +02:00
parent 7d239053ed
commit 07e4660a95

View file

@ -84,6 +84,11 @@ colibri_daemon_prestart()
install -d -o "${colibri_daemon_user}" -g "${colibri_daemon_group}" -m 0750 \
"$(/usr/bin/dirname "${colibri_daemon_logfile}")"
# Remove stale runtime files while rc.d is still root. The daemon process
# runs as colibri and cannot unlink a stale socket left behind by a prior
# root/corrupt manual start.
rm -f "${colibri_daemon_socket}" "${pidfile}" "${supervisor_pidfile}"
# Config is passed to the child via the environment.
export COLIBRI_DAEMON_DATA_DIR="${colibri_daemon_data_dir}"
export COLIBRI_DAEMON_SOCKET="${colibri_daemon_socket}"