partially solved - interacting with "sudo" using C++
-
Partially solved
I missed adding more options to the "sudo"
sudo -S ps (password)
That works .
Now I need to figure out WHEN to actually reply to the correct prompt with a password.
I have no idea from where is "unknown prompt" coming from
]DEBUG TRACE TODO check for running .... "[sudo] password for q5: " correct prompt "" unknown prompt
I have been relatively happy with passing "system" commands and running QProcess. I can live with QProcess blocking the main app flow.
Now I need to figure a way to pass "sudo" command and interactively set the correct password.
In other words - I cannot wait for QProcess to finish because it won't even start without a password.
I was thinking to send "sudo su" command first, but I have no clue how to "intercept "the response and then input the password .
I am looking for a sample code on how to setup for the command response.
What "event" am I looking for ? Simple "while" ( for what ?) would be silly in event driven QT.And no, I do not want to disable password in OS settings.
ADDENDUM
I think the answer is in QProcess "wait for finish ".MORE ADD
This is what sudo man say about -S option-S, --stdin
Write the prompt to the standard error and read the
password from the standard input instead of using the
terminal device.BUT this
BTUL->ProcessCommand_Ext( "sudo -S ", ui->listWidget_27, ui->listWidget_29, ui->listWidget_28, 0xF);
brings up "sudo :help", but "sudo _S -v " works with QProcess taking time.
PS
I know this has very little to do with QT, so do not crucify me...