[][src]Crate sudo

crates.io docs.rs

Detect if you are running as root, restart self with sudo if needed or setup uid zero when running with the SUID flag set.

Requirements

  • The sudo program is required to be installed and setup correctly on the target system.
  • Linux or Mac OS X tested
    • It should work on *BSD. However, it is not tested.

Enums

RunningAs

Cross platform representation of the state the current program running

Functions

check

Check getuid() and geteuid() to learn about the configuration this program is running under

escalate_if_needed

Restart your program with sudo if the user is not privileged enough.

with_env

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