forked from qt-creator/qt-creator
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:
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user