ProjectExplorer: create provideAskPassEntry(Environment &) convenience

... to centrally set SUDO_ASKPASS unless present.

To be used for 'Run as root'

Change-Id: I85bac939e6a7fba0b2299fd17edfe73577bfa5ad
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2021-02-16 12:42:59 +01:00
parent 166fce5036
commit 2845427d46
2 changed files with 13 additions and 0 deletions

View File

@@ -50,6 +50,8 @@
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <ssh/sshsettings.h>
#include <QDir>
#include <QFormLayout>
#include <QHash>
@@ -1067,6 +1069,15 @@ bool RunControl::showPromptToStopDialog(const QString &title,
return close;
}
void RunControl::provideAskPassEntry(Environment &env)
{
if (env.value("SUDO_ASKPASS").isEmpty()) {
const FilePath askpass = QSsh::SshSettings::askpassFilePath();
if (askpass.exists())
env.set("SUDO_ASKPASS", askpass.toUserOutput());
}
}
bool RunControlPrivate::isAllowedTransition(RunControlState from, RunControlState to)
{
switch (from) {

View File

@@ -250,6 +250,8 @@ public:
const QString &cancelButtonText = QString(),
bool *prompt = nullptr);
static void provideAskPassEntry(Utils::Environment &env);
RunWorker *createWorker(Utils::Id workerId);
bool createMainWorker();