Skip to main content

apply_sudo_with

Function apply_sudo_with 

Source
pub fn apply_sudo_with(
    name: &str,
    args: &[String],
    geteuid: impl Fn() -> u32,
    look_path: impl Fn(&str) -> Result<PathBuf, ExecError>,
) -> (String, Vec<String>)
Expand description

Ported from ApplySudo. Go stubs geteuid/lookPath as reassignable package-level vars for testing; Rust has no equivalent to mutable top-level function pointers without unsafe global state, so this port takes the euid getter and PATH lookup as explicit parameters instead. The zero-argument apply_sudo below is the production entry point, wiring in a real geteuid(2) call and look_path; ported tests call apply_sudo_with directly. See PORT_NOTES.md.