I want to run an ICMP command to ping an IP Adress at Java:


However there is a security restriction that:

Normal users are allowed to create raw sockets. 

So I can not run it. I don't want to run my application as root. So, which privileges should I assign to the user that runs my application for CAP_NET_RAW capability?

  • From this it sounds like you have to setuid on the executable (and the executable must be owned by root) so it can either create the socket or setpcap on itself at runtime (I think CAP_NET_RAW applies to processes, not executables). Unfortunately, I'm not sure about the possibilities for a java program this way, since they're not strictly executables. – goldilocks Nov 19 '14 at 14:11
  • @goldilocks could you write it as answer? – kamaci Nov 20 '14 at 8:42
  • No, because I think I am wrong about CAP_NET_RAW not being being applicable to executables. However, it looks like WRT java you would have to set that on the runtime engine (java) itself, and there are some major PITA issues that come along with that if you are using, e.g., an Oracle install with libs outside of standard places like /usr/lib. See here: unix.stackexchange.com/questions/87978/… – goldilocks Nov 20 '14 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.