Netbeans 11.2 running on Linux Mint 19.2 Cinnamon, Kernel 4.15.0-72-generic
I’ve moved a custom network packet sniffing project I developed some years ago over from Windows 7 to Linux. This uses jNetPcap to do the actual packet capture. JnetPcap is a wrapper for Libpcap.
Problem: When running my project in Netbeans I get the error “You don't have permission to capture on that device”.
Compiling the project to a .jar file which I then run as root, all is well. Thus demonstrating that the project code is OK and that the issue is confined to a lack of permissions.
The "native shared library" being used is libjnetcap.so
Essentially, I want to be able to run/debug this project in Netbeans 11.2
In an attempt to resolve this I’ve tried numerous things:
On the assumption that it is
libjnetcap.so
that is accessing the network interface, I tried giving it elevated privileges usingsetuid
, to no effect. I also tried giving it capabilities withsudo setcap cap_net_raw=p ./libjnetpcap.so
, again to no effect.Tried
setuid
on/usr/bin/java
. This time I could run the compiled projects.jar
file without usingsudo
. However, Netbeans IDE would not load from the desktop icon. Running Netbeans from a terminal elicited an error message that the use ofsetuid
was not permitted.I was unable to set capabilities on
/usr/bin/java
. The wrong type of file?
I found this on this forum:
In your case,
pcap
needs low-level access to the network interface. Due to the security implications (capturing network traffic, generating arbitrary network packets etc), such access is limited to privileged users only. On Linux, for example,pcap
needs theCAP_NET_RAW
capability to be available to the user.
This sounds like my problem, but where is pcap
? All I seem to have is the libjnetcap.so
library file.
I would be very grateful if some kind soul could give me any pointers etc.