diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2020-01-11 12:32:09 +0100 |
---|---|---|
committer | Aram Drevekenin <aram@poor.dev> | 2020-01-11 12:32:09 +0100 |
commit | ec7541111f200ed38aef1aa474b652ed800cb917 (patch) | |
tree | eaa5865e9ceba642963027d3533b2da2269e9503 | |
parent | 9736df02632814a8ca706049d3bb360f3ce8683e (diff) |
fix(error): mention `setcap(8)`-fix in EPERM error on Linux (#108)
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.
-rw-r--r-- | src/os/shared.rs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/os/shared.rs b/src/os/shared.rs index 385f253..55a8553 100644 --- a/src/os/shared.rs +++ b/src/os/shared.rs @@ -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()) } } } @@ -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` + "# +} |