RemoteLinux: Implement some of the remote file API

Implementation of remote file API for correct FilePath
work with RemoteLinux.
Added tests for this functionality

Run ssh shell in separate thread.
The linux device instance keeps its own thread for running
SshRemoteProcess. In this way all calls to filepath
interface of linux device coming from different threads
are executed in one thread (SshRemoteProcess is reentrant,
but not thread safe). The redirection to the device thread
is done by invoking SshRemoteProcess' methods through
BlockingQueuedConnection.

Done-by: Artem Sokolovskii
Change-Id: Id8756738d3a4597f175c8ef000c148d0c8536eeb
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2021-07-27 09:50:43 +02:00
committed by Artem Sokolovskii
parent 8d06519211
commit 20d19aa5bf
11 changed files with 722 additions and 39 deletions

View File

@@ -66,6 +66,46 @@ SshConnectionParameters::SshConnectionParameters()
url.setPort(0);
}
QStringList SshConnectionParameters::connectionOptions(const FilePath &binary) const
{
QString hostKeyCheckingString;
switch (hostKeyCheckingMode) {
case SshHostKeyCheckingNone:
case SshHostKeyCheckingAllowNoMatch:
// There is "accept-new" as well, but only since 7.6.
hostKeyCheckingString = "no";
break;
case SshHostKeyCheckingStrict:
hostKeyCheckingString = "yes";
break;
}
QStringList args{"-o", "StrictHostKeyChecking=" + hostKeyCheckingString,
"-o", "Port=" + QString::number(port())};
if (!userName().isEmpty())
args.append({"-o", "User=" + userName()});
const bool keyOnly = authenticationType ==
SshConnectionParameters::AuthenticationTypeSpecificKey;
if (keyOnly) {
args << "-o" << "IdentitiesOnly=yes";
args << "-i" << privateKeyFile.path();
}
if (keyOnly || SshSettings::askpassFilePath().isEmpty())
args << "-o" << "BatchMode=yes";
bool useTimeout = timeout != 0;
if (useTimeout && HostOsInfo::isWindowsHost()
&& binary.toString().toLower().contains("/system32/")) {
useTimeout = false;
}
if (useTimeout)
args << "-o" << ("ConnectTimeout=" + QString::number(timeout));
return args;
}
static inline bool equals(const SshConnectionParameters &p1, const SshConnectionParameters &p2)
{
return p1.url == p2.url
@@ -113,38 +153,10 @@ struct SshConnection::SshConnectionPrivate
QStringList connectionOptions(const FilePath &binary) const
{
QString hostKeyCheckingString;
switch (connParams.hostKeyCheckingMode) {
case SshHostKeyCheckingNone:
case SshHostKeyCheckingAllowNoMatch:
// There is "accept-new" as well, but only since 7.6.
hostKeyCheckingString = "no";
break;
case SshHostKeyCheckingStrict:
hostKeyCheckingString = "yes";
break;
}
QStringList args{"-o", "StrictHostKeyChecking=" + hostKeyCheckingString,
"-o", "User=" + connParams.userName(),
"-o", "Port=" + QString::number(connParams.port())};
const bool keyOnly = connParams.authenticationType ==
SshConnectionParameters::AuthenticationTypeSpecificKey;
if (keyOnly) {
args << "-o" << "IdentitiesOnly=yes";
args << "-i" << connParams.privateKeyFile.path();
}
if (keyOnly || SshSettings::askpassFilePath().isEmpty())
args << "-o" << "BatchMode=yes";
QStringList options = connParams.connectionOptions(binary);
if (sharingEnabled)
args << "-o" << ("ControlPath=" + socketFilePath());
bool useTimeout = connParams.timeout != 0;
if (useTimeout && HostOsInfo::isWindowsHost()
&& binary.toString().toLower().contains("/system32/")) {
useTimeout = false;
}
if (useTimeout)
args << "-o" << ("ConnectTimeout=" + QString::number(connParams.timeout));
return args;
options << "-o" << ("ControlPath=" + socketFilePath());
return options;
}
QStringList connectionArgs(const FilePath &binary) const