{"record":{"id":"c573890a933ce3ea","repo":"imsnif/bandwhich","slug":"err-msg","errorCode":null,"errorMessage":"{err_msg}","messagePattern":"\\{err_msg\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/os/shared.rs","lineNumber":199,"sourceCode":"            },\n        );\n\n        let err_msg = match (permission_err_interfaces.is_empty(), other_errs.is_empty()) {\n            (false, false) => format!(\n                \"\\n\\n{}: {}\\nAdditional errors:\\n{}\",\n                permission_err_interfaces.join(\", \"),\n                eperm_message(),\n                other_errs.join(\"\\n\")\n            ),\n            (false, true) => format!(\n                \"\\n\\n{}: {}\",\n                permission_err_interfaces.join(\", \"),\n                eperm_message()\n            ),\n            (true, false) => format!(\"\\n\\n{}\", other_errs.join(\"\\n\")),\n            (true, true) => unreachable!(\"Found no errors in error handling code path.\"),\n        };\n        bail!(err_msg);\n    }\n\n    // filter out interfaces for which we failed to acquire a frame receiver\n    let interfaces_with_frames = interfaces_with_frames_res\n        .into_iter()\n        .filter_map(|(interface, res)| res.ok().map(|frames| (interface, frames)))\n        .collect();\n\n    let dns_client = if resolve {\n        let runtime = Runtime::new()?;\n        let resolver = runtime\n            .block_on(dns::Resolver::new(dns_server))\n            .map_err(|err| {\n                eyre!(\"Could not initialize the DNS resolver. Are you offline?\\n\\nReason: {err}\")\n            })?;\n        let dns_client = dns::Client::new(resolver, runtime)?;\n        Some(dns_client)\n    } else {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/imsnif/bandwhich/blob/1899870cea8bb377948f05cfea64733ec6ea2cd6/src/os/shared.rs#L181-L217","documentation":"After filtering available interfaces, bandwhich tries to open a packet frame receiver on each. If every attempt fails, it aggregates the underlying errors into `err_msg` (distinguishing EPERM/permission errors from other errors) and bails with this message.","triggerScenarios":"All calls to create a frame receiver (via `pnet`/datalink channel creation) fail for every interface — e.g. EPERM because the process lacks root/cap_net_raw, or bind failures — leaving `interfaces_with_frames` empty.","commonSituations":"Running bandwithout sudo, missing CAP_NET_RAW capability in containers, SELinux/AppArmor denials, or all interfaces bound by another capture process.","solutions":["Run with elevated privileges: `sudo bandwhich` (raw capture needs CAP_NET_RAW)","Grant the binary capabilities instead of sudo: `sudo setcap cap_net_raw,cap_net_admin=eip $(which bandwhich)`","Check container security options (`--cap-add=NET_RAW --cap-add=NET_ADMIN`)","Ensure no other sniffer exclusively holds the interface; read the aggregated err_msg to see the per-interface cause"],"exampleFix":"// before\nbandwhich  # EPERM on all interfaces\n// after\nsudo setcap cap_net_raw,cap_net_admin=eip $(which bandwhich)\nbandwhich","handlingStrategy":"validation","validationCode":"// shell: confirm capture privileges before running\nif [ \"$(id -u)\" -ne 0 ] && ! getcap \"$(which bandwhich)\" | grep -q cap_net_raw; then\n  echo \"Run with sudo or setcap cap_net_raw,cap_net_admin=eip\"\n  exit 1\nfi","typeGuard":null,"tryCatchPattern":"sudo bandwhich 2>errs.log || { cat errs.log; echo \"check per-interface errors above (EPERM => privileges)\"; }","preventionTips":["Always run packet capture with sudo or cap_net_raw capability","Grant capabilities once: setcap cap_net_raw,cap_net_admin=eip $(which bandwhich)","In containers add --cap-add=NET_RAW --cap-add=NET_ADMIN","Check SELinux/AppAudit denials in audit logs when EPERM persists","Ensure no other sniffer exclusively holds the interface"],"tags":["network","permissions","packet-capture","rust"],"backgroundTag":"permission-denied","analyzedSha":"1899870cea8bb377948f05cfea64733ec6ea2cd6","analyzedAt":"2026-09-08T10:26:38.858Z","contentChangedAt":"2026-09-08T10:26:38.858Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}