5 ms·
Very nice! Noticed this uses pinger, which executes the actual ping command behind the scenes and parses the output. Which makes it fragile in case there are c
by aduitsis 6y ago
Very nice!
Noticed this uses pinger, which executes the actual ping command behind the scenes and parses the output. Which makes it fragile in case there are changes in the output format of ping. Are there any good alternative libraries that can use raw sockets, etc?
- m45t3r 6y agoThis is unlikely to change since if ping changes many programs would broke. It is kinda like ipconfig. AFAIK, ping is a setuid binary (since it needs raw socket, that is a privileged operation) so a program that implements ping by itself would need to do the same (or it would work for root).
- treve 6y agoWeird! Not setuid on my ubuntu machine.
- jandrese 6y agoIt is on my Ubuntu 18.04.5 LTS machine: -rwsr-xr-x 1 root root 64424 Jun 28 2019 /bin/ping
- unionpivo 6y agoIt's because of linux capabilities specificly CAP_NET_RAW How to check: $ getcap $(which ping) /usr/bin/ping = cap_net_raw+ep More about it on [1] https://blog.container-solutions.com/linux-capabilities-in-practice https://blog.container-solutions.com/linux-capabilities-in-p...
- jlgaddis 6y agoNowadays, the CAP_NET_RAW "capability" allows opening raw sockets by unprivileged users and without making binaries setuid.
- oarsinsync 6y ago> It is kinda like ipconfig. I assumed you were talking about windows until: > AFAIK, ping is a setuid binary Which unfortunately means you’ve partly helped make the GP’s point for them. Under Linux, the command you’re thinking of is ifconfig, which has long been deprecated and doesn’t ship by default anymore in newer distributions. Times change, tools move on.
- orf 6y agoI’ve just updated pinger to use a windows-specific API that doesn’t need root. But yes, in general it’s a nightmare especially with ping executables that don’t report timeouts at all. This is a great example of one of the failings of the UNIX model. You can’t really parse the ping output across distributions easily, it’s built for humans to consume and until recently didn’t even report timeouts to stdout. Not to mention needing to invoke “ping6” for ipv6, which I need to add support for. However it’s the best way to do this without needing to run gping and root.