Setting the capabilities to sniff on an interface with libpcap
From AcrodusWiki
So i did this in rust, however is the case for any language. This allows you to run a program as a non root user but have access to the interface for sniffing.
This command sets the capabilities of the executable. It must have both cap_net_admin and cap_net_raw.
sudo setcap cap_net_raw,cap_net_admin=+ep target/debug/rp2009_sniffer
The code then also needs to set it?
11 caps::raise(None, caps::CapSet::Inheritable, caps::Capability::CAP_NET_ADMIN).unwrap(); 12 caps::raise(None, caps::CapSet::Ambient, caps::Capability::CAP_NET_ADMIN).unwrap(); 13 caps::raise(None, caps::CapSet::Inheritable, caps::Capability::CAP_NET_RAW).unwrap(); 14 caps::raise(None, caps::CapSet::Ambient, caps::Capability::CAP_NET_RAW).unwrap();