pub fn privilege_request() -> Result<Privilege>Expand description
Check current privilege:
- If Root/Suid privilege -> donothing
- If User privilege -> password request and re-run the application.
Examples found in repository?
examples/sudo.rs (line 4)
3fn main() {
4 if let Ok(privilege) = privilege_request() {
5 match privilege {
6 privilege_rs::Privilege::Root => {
7 println!("Run the application as Root privilege");
8 }
9 privilege_rs::Privilege::User => {
10 println!("Failed to request privilege");
11 }
12 privilege_rs::Privilege::Suid => {
13 println!("Run the application as Root privilege");
14 }
15 }
16 }
17}