#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 6/week @ 2024-07-27 1/week @ 2024-08-03 2/week @ 2024-09-07 2/week @ 2024-09-14 16/week @ 2024-09-21 9/week @ 2024-09-28 2/week @ 2024-10-05 23/week @ 2024-10-12 1553/week @ 2024-10-19 676/week @ 2024-10-26 278/week @ 2024-11-02

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