From ce1b4011d409997b10ca205f459cedcb6b292bd7 Mon Sep 17 00:00:00 2001 From: salmon Date: Sun, 9 Aug 2026 23:53:47 +0200 Subject: Make daemon socket/PID paths environment-independent; fix rc service HOME --- src/daemon.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/daemon.rs') diff --git a/src/daemon.rs b/src/daemon.rs index 279620d..21f1a3b 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -203,13 +203,8 @@ pub fn start_daemon() -> Result<(), Box> { std::fs::remove_file(&socket_path).ok(); } - // Create runtime directory - if let Some(parent) = socket_path.parent() { - std::fs::create_dir_all(parent)?; - } - if let Some(parent) = pid_path.parent() { - std::fs::create_dir_all(parent)?; - } + // Create runtime directory (private, 0700) + crate::config::ensure_runtime_dir()?; // Write PID file let pid = std::process::id(); @@ -1609,10 +1604,7 @@ fn find_audio_in_dir(dir: &Path) -> Option> { /// Get the PID file path for the daemon fn get_pid_path(_config: &Config) -> std::path::PathBuf { - let runtime_dir = std::env::var("XDG_RUNTIME_DIR") - .map(std::path::PathBuf::from) - .unwrap_or_else(|_| std::path::PathBuf::from("/tmp")); - runtime_dir.join("rsplayer").join("rsplayer.pid") + crate::config::runtime_dir().join("rsplayer.pid") } /// Check if a process with the given PID is running -- cgit v1.2.3