Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QProcess as another user?
I am working on a application that will build a linux cross platform multilib toolchain. The first part of the application does some prep and needs to be run with root privileges. Everything after needs to be ran from a crippled user account. My question is how would I run a QProcess as another user?
baysmith last edited by
I don't think that is possible through Qt APIs. You'll probably have to use some platform specific functions.
Until I find another way to do it I guess I will just write a function that wraps the following...
echo password | sudo -u username -S "command"
goetz last edited by
If you are on KDE you can use kdesudo instead of sudo. It popups a password dialog.
Noooo I can't use kdesudo that would make my Qt only project a Kde project and suck in about a million dependences. I did however try setuid() and getuid() but it turns out there disabled in most distro's for security reasons. And I also did some digging threw kdesudo's and it's dependences source code. But it wasn't at all obvious to me as to how they were accomplishing the samething. In kdesudo's configure file it does check for /usr/bin/sudo
frankcyblogic.de last edited by
Checkout out http://doc.qt.nokia.com/4.7/qprocess.html#setupChildProcess .
Thank you that is exactly what I was looking for. Can't beleve that I didn't see that before! Hmmm Thanks again.
[quote author="unclewerner" date="1297353342"]Checkout out http://doc.qt.nokia.com/4.7/qprocess.html#setupChildProcess .[/quote]