Hello!
I have an oddly specific problem with the ping tool included in the BSP. First of all, it definitely worked with an older BSP version, however, I cannot tell the exact version breaking the wheel (as it is only a network diagnostic tool which isn’t used that much by our customers).
First to the architecture:
We have dedicated user, let’s call him Bob. And we have a Qt application which is auto started with systemd running with this user.
This is the corresponding source code:
bool Network::Ping(const QString &host)
{
return QProcess::execute("ping", QStringList() << "-c" << "1" << host) == QProcess::NormalExit;
}
Now we face the problem, that pings from our application result into the following error:
Aug 21 18:32:40 colibri-imx6 sh[386]: PING google.com (172.217.168.78): 56 data bytes
Aug 21 18:32:40 colibri-imx6 sh[386]: ping: permission denied (are you root?)
The message is speaking for itself, no we are note root, we are Bob.
Now the interesting part:
If I switch to the user Bob on the command line, the ping utility works as expected:
root@colibri-imx6:~# su - Bob
colibri-imx6:~$ ping google.com
PING google.com (172.217.22.238): 56 data bytes
64 bytes from 172.217.22.238: seq=0 ttl=56 time=14.138 ms
64 bytes from 172.217.22.238: seq=1 ttl=56 time=14.726 ms
64 bytes from 172.217.22.238: seq=2 ttl=56 time=10.158 ms
64 bytes from 172.217.22.238: seq=3 ttl=56 time=13.993 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 10.158/13.253/14.726 ms
After some research on Google, i also tried the following things:
- Setting the sticky bit with chmod +s /bin/ping
- Configure
net.ipv4.ping_group_range
- Installing the
iputils
package and using those ping binary instead
Nothing from that list solved our problem, however the last one results into a different error:
Sep 16 20:52:18 colibri-imx6 sh[1161]: ping: icmp open socket: Permission denied
Sep 16 20:52:18 colibri-imx6 sh[1161]: ping: unknown host
Any suggestions on how to resolve this error?