Reject empty HOME envvar
This commit is contained in:
@@ -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)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user