1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
use anyhow::{Error, Result}; use kelpdot_macros::red; use std::path::Path; pub fn get_root_exec_program() -> Result<String> { if Path::new("/usr/bin/doas").exists() { return Ok(String::from("doas")); } if Path::new("/usr/bin/sudo").exists() { return Ok(String::from("sudo")); } Err(Error::new(std::io::Error::new( std::io::ErrorKind::NotFound, red!("Could not find sudo or doas!"), ))) }