Skip to content

Commit 2a8a714

Browse files
committed
Moved the sudo escalate call to after scan_options.request_protocol_print() to allow users to use app for duties that do not require root access (e.g. view protocol ASCII print and list available interfaces).
1 parent f97427c commit 2a8a714

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/main.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ 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");
24-
2519
let matches = args::build_args().get_matches();
2620

2721
// Find interfaces & list them if requested
@@ -50,6 +44,16 @@ fn main() {
5044
process::exit(0);
5145
}
5246

47+
// Upgrade user privileges when needed
48+
// ----------------------------------------
49+
// Providing a prompt for the user when
50+
// the app is run and user is not root
51+
sudo::escalate_if_needed().expect("You need root permissions to run this app. Unable to escalate to sudo");
52+
53+
// Get network configuration
54+
// -------------------------
55+
// See args.rs and in particular the struct ScanOptions
56+
// for a full list of options
5357
let (selected_interface, ip_networks) = network::compute_network_configuration(&interfaces, &scan_options);
5458

5559
if scan_options.is_plain_output() {
@@ -61,7 +65,6 @@ fn main() {
6165
// ARP responses on the interface will be collected in a separate thread,
6266
// while the main thread sends a batch of ARP requests for each IP in the
6367
// local network.
64-
6568
let channel_config = pnet_datalink::Config {
6669
read_timeout: Some(Duration::from_millis(network::DATALINK_RCV_TIMEOUT)),
6770
..pnet_datalink::Config::default()

0 commit comments

Comments
 (0)