From fb487a7d78276322ec5d5b60f0020a2bd48ed42a Mon Sep 17 00:00:00 2001 From: salmon Date: Sun, 9 Aug 2026 23:57:02 +0200 Subject: rc service: create state dir and log before daemon(8) starts --- rsplayer.rc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'rsplayer.rc') diff --git a/rsplayer.rc b/rsplayer.rc index 706387b..ccc2bc9 100755 --- a/rsplayer.rc +++ b/rsplayer.rc @@ -63,6 +63,14 @@ rsplayer_start() echo " connect to the daemon socket. Set rsplayer_user in rc.conf." fi + # daemon(8) opens the log file (-o) before exec'ing rsp and before + # dropping privileges, but the state dir is only created by rsp itself — + # create both up front so the log can open and stays user-owned/readable. + install -d -o "${rsplayer_user}" -g "${rsplayer_group}" -m 700 "${state_dir}" + if [ ! -e "${state_dir}/rsplayer.log" ]; then + install -o "${rsplayer_user}" -g "${rsplayer_group}" -m 600 /dev/null "${state_dir}/rsplayer.log" + fi + echo "Starting rsplayer as ${rsplayer_user} (HOME=${rsplayer_home})." /usr/bin/env HOME="${rsplayer_home}" \ /usr/sbin/daemon -u "${rsplayer_user}" -o "${state_dir}/rsplayer.log" \ -- cgit v1.2.3