If want ping no root then have use capability (setcap). Always you can make group that have raw socket capability but normal is have grant program raw socket capability.
Thank you Thausand. I'm aware that I can set 'net_raw' capability to my
program. But this has 2 disadvantages:
- after each new compile (and that can be many times a day) I have to repeat that step and this step needs sudo
- the users of my program must repeat this step after every program-update and this step needs sudo
Both makes this solution quiet uncomfortable.
But you wrote:
Always you can make group that have raw socket capability
Does that mean:
- I create a new group and give it raw socket capability
- then I add the current user to this group
- after this, all programs which are started by the current user, do
not need sudo any longer to use the PING feature of Synapse?
This would be a great solution!Did you mean this?
I just read, trixie make change again and not use raw-socket but now use proto capability. So look like depends distribution and version. I not have maked test with trixie (I no have trixie).
With trixie you mean Debian 13 "Trixie"?
Couldn't you do it like it's done for the ping command itself. There the /bin/ping is just set as setuid root.
chown root:root /path/yourapp; chmod u+srwx,go=rx /path/yourapp
Thanks rvk too. I'm aware of this possibility. But this has 3 disadvantages:
- after each new compile (and that can be many times a day) I have to repeat that 2 steps and this steps needs sudo
- the users of my program must repeat this 2 steps after every program-update and this steps needs sudo
Both makes this solution quiet uncomfortable.
And AFAIK GUI-programs should not run with root privileges.
Aren't SOCK_DGRAM and IPPROTO_ICMP already available on older versions? And isn't it just that Trixie is only implementing this now in ping versions?
In that case you could create your own ping function with SOCK_DGRAM and IPPROTO_ICMP without needing privileges.
I'm a bloody beginner to all that network stuff. The above would be very far beyond my horizon. I would like to use Synapse for PING, because then I have to code everything only once and it works for Linux + Windows.
Raw socket access is required for tools like ping, traceroute etc to send ICMP packets on Linux.
Only root user can use Raw socket access.
If you want just use ping to see if a server is alive, try to use a tcp connection with an opened port on the server.
Thank you Jurassic Pork. To "use a tcp connection with an opened port on the server" would be very difficult for me as a bloody beginner to all that network stuff.
In this case it would be easier for me:
- for Windows to use PING via Synapse
- and for Linux to call /usr/bin/ping from my program. Therefore I had to use "sudo chmod u+s /usr/bin/ping" only once.
Conclusion:
The only left possible solution seems to be from Thausand to create a new group and give it raw socket capability and to add the current user to this group (as I described at the beginning of this post), If I understood him correctly. Did I?
Thanks again for all your help.