Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Debugging GUI Apps which need elevated priveledges
I've seen quite a few threads here about this, albeit all of them 2+ years old, and just wondered if there was any new ways of getting around this.
Currently i am developing an application that needs explicit root privileges (via kdesu/gksu/whatever) as it deals with writing directly to removable devices (partitioning/formatting etc).
Now, as you will be aware, this is impossible for a regular user, thus making this app painfully impossible to debug, you can't even get a list of devices via libparted without being root.
Option #1: Read in another thread about creating a remote device, and a matching kit for it, trouble is, that would only ever work with console apps, as there would be no X Display over the ssh connection. My immediate though to remedy that, was setting up X11 Forwarding through sshd, while a huge security risk (not at all worried since im at a home pc behind all sorts of good stuff), but alas, that doesn't even work through qtcreator, but nevermind, was always a bad idea to start with.
Soooo, i guess my question is, how on earth is this to be accomplished without screwing up my system by blatantly running everything (creator included) as root (which will in all likelyhood fail anyway)?
Hi and welcome to devnet,
Did you tried the indirect route ? i.e. run gdbserver as root and connect to it to debug your application ?
Hope it helps
Hi, thank you, that seems to be the only idea i didnt try yet :)
Slight problem though, to save having to re-run gdbserver each time, i started it with --multi, meaning it will re-use connections when the app terminates, and the connecting debugger specifies what it should debug. However qtcreator just gives me a popup stating:
Connecting to remote server failed: The target is not running (try extended-remote?)
I can't see anywhere that i can pass extended-remote, or any option to enable it....any ideas?
Side note: So not to have development at a complete stand-still i've been having to work with a setuid gdb, and QApplication::setSetuidAllowed() set, not the best work-around i know, but no other choice atm. Tempted to add a suggestion for a "Run as root"/"Debug as root" option like Xcode has, more than useful in these situations.
Just an update on the above, sorry for the double post.
Finally got it working, its been a while since i worked with debugging linux apps, so i completely forgot about all the XServer auth stuff. Including this here for reference, as i know a lot of other people have been having the same issues.
Running gdbserver via sudo needs the XAUTHORITY environment var set accordingly , so the command would be:
$ XAUTHORITY=~/.Xauthority sudo gdbserver :55555 </path/app>
Then connect to remote debugging server with qtcreator as usual, should work fine :)
Now if only i could get qtcreator to use extended-remote, it would be awesome, having to navigate through menus to initiate the debug session, instead of hitting F5, is bad enough, but having to re-run gdbserver each time too is beginning to drain my patience lol.
Then you should try asking about it on the Qt-creator mailing list, you'll find there Qt Creator's developers/maintainers.