[][src]Function procshot_server::check_sudo

pub fn check_sudo(uid: u32) -> Result<(), &'static str>

Checks if the program is run as sudo (root) user. This doesn't check if the user has the privilege to read over all of /proc or write to /var/log but just checks if the uid passed to this is 0, and returns a Result

Examples

 
 use procshot_server::check_sudo;
 use std::process;

 fn main() {
     match check_sudo(0) { // Can also use get_current_uid() from the `users` crate
         Err(e) => {
             eprintln!("Error encountered checking privileges, {:?}", e);
             process::exit(1);
         },
         _ => (),
     }
 }