How to allow non root user to execute hping command ?

If you run hping command without root permission or without sudo and you receive this error :

[open_sockraw] socket(): Operation not permitted
[main] can't open raw socket

This command might be able to help you.

sudo setcap cap_net_raw+ep /usr/bin/hping3

(or any location of the hping command)

setcap command is to set file capabilities.

What are filesystem capabilities?  
For the purpose of performing permission checks, traditional Unix implementations distinguish two categories of processes: privileged processes (whose effective user ID is 0, referred to as superuser or root), and unprivileged processes (whose effective UID is non-zero). Privileged processes bypass all kernel permission checks, while unprivileged processes are subject to full permission checking based on the process's credentials (usually: effective UID, effective GID, and supplementary group list). 
Starting with kernel 2.2, Linux divides the privileges traditionally associated with superuser into distinct units, known as capabilities, which can be independently enabled and disabled. Capabilities are a per-thread attribute.

I believe all command that need to open raw socket, by using the method above will be able to allow non root user to run the command.



Popular posts from this blog

Fedora 19 with kernel 3.10 fail to install vmplayer module.

Boot Acronis from PXE

Run Linux Flash Player Projector in Fedora 14