default to /tmp/rss/ for shared multi-user access
- runtime_dir() defaults to /tmp/rss (no user-specific fallback) - socket_path() defaults to /tmp/rss/rss.sock (overridable via RSS_SOCKET) - enabled markers in runtime_dir, not config_dir (shared state) - daemon creates /tmp/rss/ with explicit 770 permissions
This commit is contained in:
parent
7383445ea5
commit
38882b70c3
3 changed files with 10 additions and 26 deletions
|
|
@ -7,8 +7,6 @@ Type=simple
|
|||
ExecStart=%h/.cargo/bin/rss daemon
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
Environment=RSS_CONFIG=%h/.config/rss/config.toml
|
||||
Environment=RSS_STATE_DIR=%h/.local/share/rss
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
|
|
|||
|
|
@ -47,14 +47,7 @@ pub fn run(config_path: String) {
|
|||
}
|
||||
if let Some(parent) = sock_path.parent() {
|
||||
fs::create_dir_all(parent).ok();
|
||||
// Make directory group-accessible (rwxrwx---)
|
||||
if let Ok(dir) = fs::metadata(parent) {
|
||||
let perm = dir.permissions();
|
||||
let mode = perm.mode();
|
||||
// set group rwx if owner has it
|
||||
let group = (mode & 0o700) >> 3;
|
||||
let _ = fs::set_permissions(parent, fs::Permissions::from_mode(mode | group));
|
||||
}
|
||||
let _ = fs::set_permissions(parent, fs::Permissions::from_mode(0o770));
|
||||
}
|
||||
|
||||
// Load config
|
||||
|
|
|
|||
25
src/state.rs
25
src/state.rs
|
|
@ -4,14 +4,14 @@ pub fn runtime_dir() -> PathBuf {
|
|||
if let Ok(dir) = std::env::var("RSS_STATE_DIR") {
|
||||
return PathBuf::from(dir);
|
||||
}
|
||||
if let Ok(dir) = std::env::var("XDG_RUNTIME_DIR") {
|
||||
return PathBuf::from(dir).join("rss");
|
||||
PathBuf::from("/tmp/rss")
|
||||
}
|
||||
|
||||
pub fn socket_path() -> PathBuf {
|
||||
if let Ok(p) = std::env::var("RSS_SOCKET") {
|
||||
return PathBuf::from(p);
|
||||
}
|
||||
if let Ok(home) = std::env::var("HOME") {
|
||||
return PathBuf::from(home).join(".local/share/rss");
|
||||
}
|
||||
let user = std::env::var("USER").unwrap_or_else(|_| "unknown".into());
|
||||
PathBuf::from(format!("/tmp/rss-{}", user))
|
||||
PathBuf::from("/tmp/rss/rss.sock")
|
||||
}
|
||||
|
||||
pub fn config_dir() -> PathBuf {
|
||||
|
|
@ -24,13 +24,6 @@ pub fn config_dir() -> PathBuf {
|
|||
PathBuf::from("/etc/rss")
|
||||
}
|
||||
|
||||
pub fn socket_path() -> PathBuf {
|
||||
if let Ok(p) = std::env::var("RSS_SOCKET") {
|
||||
return PathBuf::from(p);
|
||||
}
|
||||
runtime_dir().join("rss.sock")
|
||||
}
|
||||
|
||||
pub fn daemon_pid_path() -> PathBuf {
|
||||
runtime_dir().join("daemon.pid")
|
||||
}
|
||||
|
|
@ -40,7 +33,7 @@ pub fn log_path(name: &str) -> PathBuf {
|
|||
}
|
||||
|
||||
pub fn enabled_path(name: &str) -> PathBuf {
|
||||
config_dir().join("enabled").join(name)
|
||||
runtime_dir().join("enabled").join(name)
|
||||
}
|
||||
|
||||
pub fn write_pid(path: &PathBuf) -> std::io::Result<()> {
|
||||
|
|
@ -68,7 +61,7 @@ pub fn disable(name: &str) {
|
|||
}
|
||||
|
||||
pub fn list_enabled() -> std::io::Result<Vec<String>> {
|
||||
let dir = config_dir().join("enabled");
|
||||
let dir = runtime_dir().join("enabled");
|
||||
if !dir.exists() {
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue