From 421e5d9c598d10768769e9c4586b775534db09d2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 10 Nov 2022 07:35:13 +0100 Subject: [PATCH] Utils: Better prerequisites check for DeviceShell Check the existence of all commands used by the DeviceShell script before trying to start it. Change-Id: I7a69957a979f8eb021c45e54615ad8d38353d28b Reviewed-by: hjk --- src/libs/utils/deviceshell.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libs/utils/deviceshell.cpp b/src/libs/utils/deviceshell.cpp index ef6814e9c4e..1712f5390f8 100644 --- a/src/libs/utils/deviceshell.cpp +++ b/src/libs/utils/deviceshell.cpp @@ -240,9 +240,9 @@ bool DeviceShell::start() bool DeviceShell::checkCommand(const QByteArray &command) { - const QByteArray checkBase64Cmd = "(which base64 || echo '')\n"; + const QByteArray checkCmd = "(which " + command + " || echo '')\n"; - m_shellProcess->writeRaw(checkBase64Cmd); + m_shellProcess->writeRaw(checkCmd); if (!m_shellProcess->waitForReadyRead()) { qCWarning(deviceShellLog) << "Timeout while trying to check for" << command; return false; @@ -265,9 +265,12 @@ bool DeviceShell::installShellScript() return false; } - if (!checkCommand("base64")) { - m_shellScriptState = State::NoScript; - return false; + static const QList requiredCommands + = {"base64", "cat", "echo", "kill", "mkfifo", "mktemp", "rm"}; + + for (const QByteArray &command : requiredCommands) { + if (!checkCommand(command)) + return false; } const static QByteArray shellScriptBase64 = FilePath(":/utils/scripts/deviceshell.sh")