PDA

View Full Version : Ping from Qt Application



Axtroz
29th September 2012, 12:45
Greetings!
I wrote a network monitoring application with a Qt GUI. On Windows it's running fine (via IcmpSendEcho), but on Linux opening a raw socket requires superuser privileges. At first I tried setcap cap_net_raw+ep, like ping and fping (under Archlinux those aren't setuid/setgid root, but have capabilities of opening raw sockets), but it still gives me an "Operation not permitted" when trying to open the socket. Then I tried setuid/setgit root the GUI program and it still gives me Operation not permitted. Is there any limitation in Qt apps for using raw sockets or something else is denying the operation? Thanks!

wysota
29th September 2012, 18:51
Is there any limitation in Qt apps for using raw sockets
No. Especially since that you're not using Qt API for operating the socket.

or something else is denying the operation? Thanks!
Does it work if you run it as root?

Axtroz
1st October 2012, 02:13
Yes, it ran as root. It ran with setuid/setgit and setcap later, after I figured out that everytime I run the program from QtCreator via Run it builds and replaces the old executable with a new one without special privileges :) I ran it from the build folder and everything was fine.