Fix running as root

There is no need for TerminalRunner::setRunAsRoot()
as debugger is already being run as root.
Implement runAsRoot for non-terminal QtcProcess, too.

Fixes: QTCREATORBUG-26964
Change-Id: Id5110db86b7b809a5608714464241cee73875f2b
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2022-02-01 14:51:23 +01:00
parent 2be0fc2537
commit 239688180d
9 changed files with 62 additions and 77 deletions

View File

@@ -188,11 +188,6 @@ void TerminalRunner::interruptProcess()
m_stubProc->interruptProcess();
}
void TerminalRunner::setRunAsRoot(bool on)
{
m_runAsRoot = on;
}
void TerminalRunner::start()
{
QTC_ASSERT(m_stubRunnable, reportFailure({}); return);
@@ -209,20 +204,11 @@ void TerminalRunner::start()
connect(m_stubProc, &QtcProcess::finished,
this, &TerminalRunner::reportDone);
CommandLine commandLine = stub.command;
if (m_runAsRoot) { // TODO: fix me
m_stubProc->setRunAsRoot(true);
// CommandLine wrapped("sudo", {"-A"});
// wrapped.addCommandLineAsArgs(commandLine);
// commandLine = wrapped;
RunControl::provideAskPassEntry(stub.environment);
}
m_stubProc->setEnvironment(stub.environment);
m_stubProc->setWorkingDirectory(stub.workingDirectory);
// Error message for user is delivered via a signal.
m_stubProc->setCommand(commandLine);
m_stubProc->setCommand(stub.command);
m_stubProc->start();
}