Skip to main content

with_env

Function with_env 

Source
pub fn with_env(prefixes: &[&str]) -> Result<RunningAs, Box<dyn Error>>
Expand description

Escalate privileges while maintaining RUST_BACKTRACE and selected environment variables (or none).

Activates SUID privileges when available.

sudo::with_env(&["CARGO_", "MY_APP_"])?;
// the following gets only executed in privileged mode