aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/terminalinterface.cpp
diff options
context:
space:
mode:
authorMarcus Tillmanns <[email protected]>2023-06-09 14:31:09 +0200
committerMarcus Tillmanns <[email protected]>2023-06-12 08:09:04 +0000
commit11ec14ebf43aafb75596bdf492531cd007518578 (patch)
treede38191f142729b01b1345abe75e795834739949 /src/libs/utils/terminalinterface.cpp
parent52fba04af5d1f1a6fcc93b91e2f3ff7f4f1fb237 (diff)
Utils: Dont auto add sudo to all processes
Terminal processes need to add to the stub and not the target app, so sudo is only automatically added for default processes. The terminal interface is changed such that sudo is added to the stub. Task-number: QTCREATORBUG-27519 Change-Id: Ife11e937644c4e946401a5b079e90fa64aee2c52 Reviewed-by: Jarek Kobus <[email protected]>
Diffstat (limited to 'src/libs/utils/terminalinterface.cpp')
-rw-r--r--src/libs/utils/terminalinterface.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libs/utils/terminalinterface.cpp b/src/libs/utils/terminalinterface.cpp
index 6767c16c61f..7046d7855ca 100644
--- a/src/libs/utils/terminalinterface.cpp
+++ b/src/libs/utils/terminalinterface.cpp
@@ -385,6 +385,22 @@ void TerminalInterface::start()
ProcessSetupData stubSetupData = m_setup;
stubSetupData.m_commandLine = cmd;
+ if (m_setup.m_runAsRoot && !HostOsInfo::isWindowsHost()) {
+ CommandLine rootCommand(FilePath("sudo").searchInPath(), {"-A"});
+ rootCommand.addCommandLineAsArgs(cmd);
+
+ const FilePath askPassPath = FilePath::fromUserInput(QCoreApplication::applicationDirPath())
+ .pathAppended(QLatin1String(RELATIVE_LIBEXEC_PATH))
+ .pathAppended(QLatin1String("qtc-askpass"));
+
+ if (askPassPath.exists())
+ stubSetupData.m_environment.setFallback("SUDO_ASKPASS", askPassPath.toUserOutput());
+
+ stubSetupData.m_commandLine = rootCommand;
+ } else {
+ stubSetupData.m_commandLine = cmd;
+ }
+
QMetaObject::invokeMethod(
d->stubCreator,
[stubSetupData, this] { d->stubCreator->startStubProcess(stubSetupData); },