Skip to main content

check_root_privilege

Function check_root_privilege 

Source
pub fn check_root_privilege(allow_root: bool, euid: u32) -> Option<String>
Expand description

Refuse to start when running as root (UID 0) unless allow_root is set.

ยงErrors

Returns an error message when the effective UID is 0 and allow_root is false.

let msg = praxis::check_root_privilege(false, 0);
assert!(msg.is_some());

let msg = praxis::check_root_privilege(true, 0);
assert!(msg.is_none());

let msg = praxis::check_root_privilege(false, 1000);
assert!(msg.is_none());