is_sudo 0.0.2

Checks whether the process is running as root/sudo/admin permission in Windows and Unix systems
Documentation
  • Coverage
  • 80%
    4 out of 5 items documented1 out of 2 items with examples
  • Size
  • Source code size: 12.34 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.5 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 29s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • spa5k/is_sudo
    4 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • spa5k

Is_sudo

Checks if program is running as sudo in unix systems, or using admin permission in windows.

Usage

use is_sudo::check;
use is_sudo::RunningAs;

fn main() {
    let running_as: RunningAs = is_sudo::check();

    match running_as {
        RunningAs::Root => println!("Running as root"),
        RunningAs::User => println!("Running as user"),
    }
}

Release

Push a semver tag such as v0.0.2 after updating Cargo.toml.

The GitHub release workflow will:

  • run the test matrix on Linux, macOS, and Windows
  • verify that the tag matches the crate version
  • publish the crate to crates.io using CARGO_REGISTRY_TOKEN
  • create a GitHub release and attach the packaged .crate file