Most of the other questions about this seem to be C related. I am using Free Pascal and the Lazarus IDE, version 2.4.0 and 0.9.30 respectively.
I am creating a GUI that calls and passes arguments to a Linux command. I don't want my users to have to run the whole GUI using sudo\root, but rather be prompted for the password at the appropriate time.
I am using TProcess to call the Linux commands and pass and read values. I can't work out, though, how to pass the sudo password to the command from my own program?
To give an example, take the following normal command line:
dd if=/dev/hda1 of=~/image.dd
Enter sudo password:
My program is calling dd, passing it the if and of values from a GUI interface - it then needs to gather and pass the sudo password to dd.
A little bit old, but - use pkexec in front of your command, like: pkexec ls /root
You will have each time the GUI info for entering root password. Tested on LinuxMint
On the premise that you're already using TProcess, instead of issuing the command line call directly to dd you can use one of the following established methods of invoking su/sudo:
gksudo (Ubuntu natty man page)kdesudo (Ubuntu natty man page)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With