How to make Qprocess run a command line as Root
-
You should give the executable "setuid/gid" permission. You can do this by invoking this command:
@chmod +s ./executable@Read more at:
http://en.wikipedia.org/wiki/Modes_(Unix)
But be warned that if this process gets exploited, the whole system may be compromised. There is a chance that you can do what you want to do without setuid.
-
Save the command to a shell script file and give it +s permission. Run the shell script using whatever means you can in your application, and it should be ok. But beware, if someone changes the shellscript to destroy your system, you will be in trouble, because he may do whatever root can do. So, place the file in appropriate location and revoke write permisson from it for all users except root. I think this should work:
@sudo chown root:root script.sh
sudo chmod 4755 script.sh@Be sure to read these articles on setuid before actually using it:
- "setuid on Shell Scripts":http://www.tuxation.com/setuid-on-shell-scripts.html
- "UNIX / Linux: Explains setuid File Permission":http://www.cyberciti.biz/faq/unix-bsd-linux-setuid-file/
-
It was already discussed on this forum. With details and at least 2 possible solutions with source code for testing. Please use search functions of this forum before you create new topic. Maybe you problem is already solved.
Topic I'm talking about: "[SOLVED]Is it possible to pass on password to process requiring root privileges":http://qt-project.org/forums/viewthread/20673/