Skip to main content

default_runtime_dir

Function default_runtime_dir 

Source
pub fn default_runtime_dir() -> Option<PathBuf>
Expand description

Per-user runtime directory for short-lived sockets and pid files.

Resolution order:

  • Linux: $XDG_RUNTIME_DIR/cfgd if set, else $HOME/.cache/cfgd. The base $XDG_RUNTIME_DIR is owner-private by spec; the cache fallback is under the user’s home where Linux-default permissions already protect it.
  • macOS: $HOME/Library/Application Support/cfgd. There is no per-user tmpfs on macOS, and $TMPDIR is per-user but still world-traversable when the umask leaks; Application Support is the conventional per-user location for app state.
  • Windows: %LOCALAPPDATA%\cfgd via directories::BaseDirs. (Daemons on Windows use named pipes, which are kernel objects — this path is provided for parity and is unused by the daemon socket flow.)

Honors the TestHomeGuard thread-local override on every platform so tests can redirect the runtime dir without mutating process-global env state. Returns None only when no home directory can be resolved at all.