Skip to main content

authenticate_sudo

Function authenticate_sudo 

Source
pub fn authenticate_sudo(password: &str) -> Result<bool>
Expand description

Attempt to authenticate as root using sudo -S -v with the given password piped over stdin. Returns Ok(true) if authentication succeeded, Ok(false) if the password was rejected, and Err if sudo could not be invoked at all.

On success, the password is also cached (see cache_sudo_password) so that subsequent privileged commands run via crate::utils::execute_with_sudo can re-authenticate reliably without depending on sudo’s own (TTY/session-keyed) credential cache.