On Linux, oping/noping can't be used by non-root users. This is because liboping uses SOCK_RAW.
$ oping google.com
PING google.com (142.250.129.139) 56 bytes of data.
ping_send failed: Operation not permitted
If liboping were to use SOCK_DGRAM instead of SOCK_RAW, then non-root users would be able to use it. This was the approach adopted by iputils' ping command:
$ strace -e socket ping -c1 127.0.0.1
socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP) = 3
socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6) = 4
socket(AF_INET, SOCK_DGRAM, IPPROTO_IP) = 5
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.079 ms
--- 127.0.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.079/0.079/0.079/0.000 ms
+++ exited with 0 +++
This would mean that oping/noping could be used without needing to elevate user privileges (via file capabilities or setuid bit).
(Forwarded from https://bugzilla.redhat.com/show_bug.cgi?id=2403785)
On Linux, oping/noping can't be used by non-root users. This is because liboping uses SOCK_RAW.
If liboping were to use SOCK_DGRAM instead of SOCK_RAW, then non-root users would be able to use it. This was the approach adopted by iputils' ping command:
This would mean that oping/noping could be used without needing to elevate user privileges (via file capabilities or setuid bit).
(Forwarded from https://bugzilla.redhat.com/show_bug.cgi?id=2403785)