From 07e4660a950f915d5bc7cfc1a212c39b65d169c7 Mon Sep 17 00:00:00 2001 From: Sam & Claude Date: Sun, 14 Jun 2026 22:39:52 +0200 Subject: [PATCH] fix(rc): clear stale colibri socket before start (Sam & Codex) 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. --- packaging/freebsd/colibri_daemon.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packaging/freebsd/colibri_daemon.in b/packaging/freebsd/colibri_daemon.in index 63f6260..9f0f454 100644 --- a/packaging/freebsd/colibri_daemon.in +++ b/packaging/freebsd/colibri_daemon.in @@ -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}"