Skip to content

Commit

Permalink
fix(error): mention setcap(8)-fix in EPERM error on Linux (imsnif#108)
Browse files Browse the repository at this point in the history
This is already mentioned in the README, but I figured that it might be
helpful to point linux-users to this if they try to run `bandwhich`
right after installing it and encountering this kind of error.
  • Loading branch information
Ma27 authored and imsnif committed Jan 11, 2020
1 parent 9736df0 commit ec75411
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/os/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ pub fn get_input(
for iface in network_frames {
if let Some(iface_error) = iface.err() {
if let ErrorKind::PermissionDenied = iface_error.kind() {
failure::bail!(
"Insufficient permissions to listen on network interface(s). Try running with sudo.",
)
failure::bail!(eperm_message())
}
}
}
Expand Down Expand Up @@ -143,3 +141,23 @@ pub fn get_input(
write_to_stdout,
})
}

#[inline]
#[cfg(target_os = "macos")]
fn eperm_message() -> &'static str {
"Insufficient permissions to listen on network interface(s). Try running with sudo."
}

#[inline]
#[cfg(target_os = "linux")]
fn eperm_message() -> &'static str {
r#"
Insufficient permissions to listen on network interface(s). You can work around
this issue like this:
* Try running `bandwhich` with `sudo`
* Build a `setcap(8)` wrapper for `bandwhich` with the following rules:
`cap_net_raw,cap_net_admin+ep`
"#
}

0 comments on commit ec75411

Please sign in to comment.