Reject empty HOME envvar

This commit is contained in:
2026-03-20 21:43:08 +01:00
parent 4112288a30
commit ada9da7ae7
5 changed files with 30 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ mod sandbox;
pub use errors::SandboxError;
use std::env;
use std::ffi::OsString;
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
@@ -27,6 +28,13 @@ pub struct SandboxConfig {
pub dry_run: bool,
}
pub fn require_home() -> Result<String, SandboxError> {
env::var("HOME")
.ok()
.filter(|h| !h.is_empty())
.ok_or(SandboxError::HomeNotSet)
}
pub fn run(config: SandboxConfig) -> Result<(), SandboxError> {
preflight::check(&config)?;