Skip to content

Commit 3c2c6a0

Browse files
committed
Added crate sudo in order to provide an easier user experience by giving them an opportunity to escalate their privileges to root when running the app. This is in contrast to having the app exit and the user having the run the app again as sudo.
1 parent 206d03c commit 3c2c6a0

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ csv = "1.1"
3232
serde = { version = "1.0", features = ["derive"] }
3333
serde_json = "1.0"
3434
serde_yaml = "0.9"
35+
sudo = "0.6.0"

src/main.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ use crate::network::NetworkIterator;
1616
use crate::vendor::Vendor;
1717

1818
fn main() {
19+
// Upgrade user privileges when needed
20+
// ----------------------------------------
21+
// Providing a prompt for the user when
22+
// the app is run and user is not root
23+
sudo::escalate_if_needed().expect("You need root permissions to run this app. Unable to escalate to sudo");
1924

2025
let matches = args::build_args().get_matches();
2126

0 commit comments

Comments
 (0)