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