socketsubuntunetwork-programmingping

How is ping for non-root user implemented on Linux distros?


I was browsing through the code for ping form iputils package for Linux.

I noticed that ping uses raw sockets SOCK_RAW, which any userspace application requires root privilege to use.

How do the developers of Linux distros manage to provide the ping command for non-root users ?


Solution

  • The ping executable is setuid root:

    $ ls -l /bin/ping
    -rwsr-xr-x 1 root root 35712 Nov  8  2011 /bin/ping