#macos #user #cross-platform #solution #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

#127 in #solution

Download history 5/week @ 2024-07-26 2/week @ 2024-08-02 2/week @ 2024-09-06 2/week @ 2024-09-13 12/week @ 2024-09-20 12/week @ 2024-09-27 3/week @ 2024-10-04 19/week @ 2024-10-11 1556/week @ 2024-10-18 415/week @ 2024-10-25 530/week @ 2024-11-01

2,520 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

~220KB