#user #cross-platform #solution #macos #superuser #privileged #deciding

is_superuser

A cross-platform solution for finding out if the running user is a superuser

1 stable release

1.0.1 Sep 18, 2022

#118 in #solution

Download history 159/week @ 2024-11-16 937/week @ 2024-11-23 295/week @ 2024-11-30 566/week @ 2024-12-07 861/week @ 2024-12-14 251/week @ 2024-12-21 574/week @ 2024-12-28 1522/week @ 2025-01-04 299/week @ 2025-01-11 363/week @ 2025-01-18 542/week @ 2025-01-25 1451/week @ 2025-02-01 384/week @ 2025-02-08 950/week @ 2025-02-15 2272/week @ 2025-02-22 728/week @ 2025-03-01

5,124 downloads per month

MIT license

5KB
56 lines

is_superuser

A simple cross-platform solution for deciding if a given user is privileged. Works on Unix (Linux and MacOS) and Windows, please make an issue if it doesn't work for you!

Usage:

use is_superuser::is_superuser;
fn main() {
    if is_superuser() {
        println!("I am running with sudo/admin privileges!");
    } else {
        println!("I am a normal user!");
    }
}

lib.rs:

A simple cross-platform solution for deciding if a given user is privileged. Works on Unix (Linux and MacOS) and Windows, please make an issue if it doesn't work for you!

Usage:

use is_superuser::is_superuser;
fn main() {
    if is_superuser() {
        println!("I am running with sudo/admin privileges!");
    } else {
        println!("I am a normal user!");
    }
}

Dependencies

~215KB