Skip to content

Commit 7b7d025

Browse files
committed
Fixing MacOS bug on permissions
1 parent 81d0ee2 commit 7b7d025

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "arp-scan"
33
description = "A minimalistic ARP scan tool"
44
license = "AGPL-3.0-or-later"
5-
version = "0.15.0"
5+
version = "0.15.1"
66
authors = ["Saluki"]
77
edition = "2024"
88
readme = "README.md"
@@ -16,12 +16,14 @@ rust-version = "1.90"
1616
[dependencies]
1717

1818
# CLI & utilities
19-
caps = "0.5.6"
2019
clap = { version = "4.5", default-features = false, features = ["std", "suggestions", "color", "help"] }
2120
ansi_term = "0.12"
2221
rand = "0.9"
2322
ctrlc = "3.5"
2423

24+
[target.'cfg(target_os = "linux")'.dependencies]
25+
caps = "0.5.6"
26+
2527
# Network
2628
pnet = "0.35"
2729
pnet_datalink = "0.35"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ARP scan finished, 5 hosts found in 1.623 seconds
6464
Download the `arp-scan` binary for Linux (Ubuntu, Fedora, Debian, ...). See the [releases page](https://github.com/Saluki/arp-scan-rs/releases) for other binaries.
6565

6666
```bash
67-
wget -O arp-scan https://github.com/Saluki/arp-scan-rs/releases/download/v0.15.0/arp-scan-v0.15.0-x86_64-unknown-linux-musl && chmod +x ./arp-scan
67+
wget -O arp-scan https://github.com/Saluki/arp-scan-rs/releases/download/v0.15.1/arp-scan-v0.15.1-x86_64-unknown-linux-musl && chmod +x ./arp-scan
6868
```
6969

7070
Optionnaly, fetch the IEEE OUI reference file (CSV format) that contains all MAC address vendors.

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ fn main() {
4444
process::exit(0);
4545
}
4646

47-
if !cfg!(windows) && !utils::has_network_capability() {
47+
if !utils::has_network_capability() {
4848
eprintln!(
4949
"Should run this binary as root, an user with CAP_NET_RAW capabilities or use --help for options"
5050
);

src/utils.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::process;
22
use std::sync::Arc;
33

44
use ansi_term::Color::{Green, Red};
5+
#[cfg(target_os = "linux")]
56
use caps::{CapSet, Capability, has_cap};
67
use ipnetwork::{IpNetwork, NetworkSize};
78
use pnet_datalink::NetworkInterface;
@@ -17,9 +18,24 @@ use crate::network::{ResponseSummary, TargetDetails};
1718
* root - you just need CAP_NET_RAW capability to perform scans. This was before
1819
* implemented as a minimalistic check to see if the "USER" env was set to root,
1920
* but failed to work in containerized environments.
21+
*
22+
* On Linux, this checks for CAP_NET_RAW capability. On other Unix-like systems
23+
* (macOS, BSD, etc.), the capability check is not applicable - permissions must
24+
* be granted at runtime (e.g., via sudo).
2025
*/
2126
pub fn has_network_capability() -> bool {
22-
has_cap(None, CapSet::Effective, Capability::CAP_NET_RAW).unwrap_or(false)
27+
#[cfg(target_os = "linux")]
28+
{
29+
has_cap(None, CapSet::Effective, Capability::CAP_NET_RAW).unwrap_or(false)
30+
}
31+
#[cfg(not(target_os = "linux"))]
32+
{
33+
// On non-Linux systems (macOS, BSD, etc.), we can't check capabilities
34+
// at compile time. The user needs to run with appropriate privileges.
35+
// Return true here and let the actual network operations fail if
36+
// permissions are insufficient.
37+
true
38+
}
2339
}
2440

2541
/**

0 commit comments

Comments
 (0)