Results 1 to 4 of 4
Hi everyone.
my problem is such:
I am working in Linux on a program in c++ that incorporates qt.
In this programs I am using some system() calls.
these system() ...
- 07-13-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
C++ program getting sudo password
Hi everyone.
my problem is such:
I am working in Linux on a program in c++ that incorporates qt.
In this programs I am using some system() calls.
these system() calls are operation that require root privileges.
so for example:
mycode:
but when I run this my program just freezes because it is waiting for a password.Code:system("sudo su");
Is there any way with qt that I could prompt the user for a password and then pass it in when I call the system() commands???
so something layed out like this:
I hope you can understand this. Thanks for any help that anyone maybe able to supply!!Code:// Message box: what is you password? system("sudo su") < password;
- 07-13-2009 #2
The proper way to do this in Linux is with Setuid.
Check out this link...Gerard4143
GNU C Library (libc) Programming Guide - Setuid Program ExampleMake mine Arch Linux
- 07-14-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 8,974
If this program needs to run as root, then make it owned by root and set the setuid bit so that it will always run as a root process. WARNING! This is very dangerous as it provides a means for malware to access the system as root. Be very judicious in your use of this capability.
Doing this, when then program is run, it will run as user root and thus system() calls will run with root privileges. You will not need to do the "sudo su -" thing.Code:# as root chown root progname chmod ugo+s progname
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 07-15-2009 #4Just Joined!
- Join Date
- Jul 2009
- Posts
- 8
Thank you both for the reply!!!
I will have to try this and see if it works!!!
Many thanks again!


Reply With Quote