LinuxDevice: Fix starting a shell with SSH_ASKPASS

Change-Id: I11a8a477a1f9796ceb021037b781da2ca8d87f43
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Jarek Kobus
2022-05-25 15:25:22 +02:00
parent c6c919e671
commit 78d8dd8997

View File

@@ -804,11 +804,30 @@ public:
m_shell->setWriteData("echo\n"); m_shell->setWriteData("echo\n");
m_shell->start(); m_shell->start();
if (!m_shell->waitForStarted() || !m_shell->waitForReadyRead() auto failed = [this] {
|| m_shell->readAllStandardOutput() != "\n") {
closeShell(); closeShell();
qCDebug(linuxDeviceLog) << "Failed to connect to" << m_displaylessSshParameters.host(); qCDebug(linuxDeviceLog) << "Failed to connect to" << m_displaylessSshParameters.host();
return false; return false;
};
QDeadlineTimer timer(30000);
if (!m_shell->waitForStarted(timer.remainingTime()))
return failed();
while (true) {
if (!m_shell->waitForReadyRead(timer.remainingTime()))
return failed();
const QByteArray output = m_shell->readAllStandardOutput();
if (output == "\n")
break; // expected output from echo
if (output.size() > 0)
return failed(); // other unidentified output
// In case of trying to run a shell using SSH_ASKPASS, it may happen
// that we receive ready read signal but for error channel, while output
// channel still is empty. In this case we wait in loop until the user
// provides the right password, otherwise we timeout after 30 seconds.
} }
return true; return true;
} }