capabilities(7) are a great way for not giving all root privileges to a process and AFAIK can be used instead of setuid(2). According to this and many others,
"Unfortunately, still many binaries have the
setuidbit set, while they should be replaced withcapabilitiesinstead."
As a simple example, on Ubuntu,
$ ls -l `which ping`
-rwsr-xr-x 1 root root 44168 May 8 2014 /bin/ping
As you know, setting suid/guid on a file, changes the effective user ID to root. So if there the suid-enabled program contains a flaw, the non-privileged user can break-out and become the equivalent of the root user.
My question is why many Linux distributions still use setuid method while setting capabilities can be used instead with less security concerns?
This may not give the reason why some dudes somewhere decided one way or another, but some auditing tools and interfaces may not yet know about capabilities.
An example is the proc_connector netlink interface and the programs based on it (like
forkstat): there are events for a process changing its credentials, but not for it changing its capabilities.FWIW, the cause why you may not get eg a
net_raw+epping(8)instead of a setuid one on a Debian-like distro is because that depends on thesetcap(8)utility from thelibcap2-binpackage already existing before you installping. Fromiputils-ping.postinst:Also notice that
pingitself will drop any setuid privileges and switch to use capabilities on Linux upon starting, so your concerns about it may be a bit exagerated. Fromping.c:From
ping_common.c