#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

#123 in #solution

44 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