pub struct Sudo {
prefix: Vec<String>,
askpass: Option<PathBuf>,
_shim: Option<TempShim>,
}Expand description
Resolved sudo strategy: the argv prefix plus any owned askpass shim.
Fields§
§prefix: Vec<String>e.g. [] (root), ["sudo", "-A"], or ["sudo", "-n"].
askpass: Option<PathBuf>Askpass shim exported to spawned sudo commands via SUDO_ASKPASS.
None when sudo is not used, or when the caller’s own SUDO_ASKPASS
is inherited from the environment.
_shim: Option<TempShim>Implementations§
Source§impl Sudo
impl Sudo
Sourcepub fn resolve(password_file: Option<&Path>) -> Result<Sudo>
pub fn resolve(password_file: Option<&Path>) -> Result<Sudo>
Decide the sudo strategy from euid, the environment, and an optional
password file resolved from the spec (takes precedence over
$SCX_SUDO_PASSWORD_FILE).
Sourcefn apply_env(&self, c: &mut Command)
fn apply_env(&self, c: &mut Command)
Export the askpass shim (if any) to a spawned sudo command.
Sourcepub fn command(&self, program: &str, args: &[String]) -> Command
pub fn command(&self, program: &str, args: &[String]) -> Command
Build a Command running program (with args) as root.
Sourcepub fn authenticate(&self) -> Result<()>
pub fn authenticate(&self) -> Result<()>
Validate that sudo authenticates now (sudo <prefix> -v). No-op as root.
Returns Err with sudo’s stderr on failure.
Auto Trait Implementations§
impl Freeze for Sudo
impl RefUnwindSafe for Sudo
impl Send for Sudo
impl Sync for Sudo
impl Unpin for Sudo
impl UnsafeUnpin for Sudo
impl UnwindSafe for Sudo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more