RemoteLinux: Proper double-remote

There seems something wrong with quoting the sed command for port
access which should be fixed independently.

As it is not crucial for plain deployment / run, make the test optional.

Change-Id: Id82bdc7c25a7fb6e2f8799676b869216a7720cfa
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
hjk
2023-03-31 12:10:20 +02:00
parent 305ccfe259
commit 432d8e6e63
3 changed files with 47 additions and 77 deletions

View File

@@ -392,7 +392,6 @@ public:
QString m_socketFilePath;
SshParameters m_sshParameters;
IDevice::ConstPtr m_linkDevice;
bool m_connecting = false;
bool m_killed = false;
@@ -596,12 +595,32 @@ SshProcessInterfacePrivate::SshProcessInterfacePrivate(SshProcessInterface *sshI
void SshProcessInterfacePrivate::start()
{
clearForStart();
m_sshParameters = m_device->sshParameters();
const Id linkDeviceId = Id::fromSetting(m_device->extraData(Constants::LinkDevice));
m_linkDevice = DeviceManager::instance()->find(linkDeviceId);
m_useConnectionSharing = !m_linkDevice && SshSettings::connectionSharingEnabled();
if (const IDevice::ConstPtr linkDevice = DeviceManager::instance()->find(linkDeviceId)) {
CommandLine cmd{linkDevice->filePath("ssh")};
if (!m_sshParameters.userName().isEmpty()) {
cmd.addArg("-l");
cmd.addArg(m_sshParameters.userName());
}
cmd.addArg(m_sshParameters.host());
const CommandLine full = q->m_setup.m_commandLine;
if (!full.isEmpty()) {
// Empty is ok in case of opening a terminal.
cmd.addArgs(QString("echo ") + s_pidMarker + "\\$\\$" + s_pidMarker + " \\&\\& ",
CommandLine::Raw);
cmd.addCommandLineAsArgs(full, CommandLine::Raw);
}
m_process.setCommand(cmd);
m_process.start();
return;
}
m_useConnectionSharing = SshSettings::connectionSharingEnabled();
m_sshParameters = m_device->sshParameters();
// TODO: Do we really need it for master process?
m_sshParameters.x11DisplayName
= q->m_setup.m_extraData.value("Ssh.X11ForwardToDisplay").toString();
@@ -672,17 +691,14 @@ void SshProcessInterfacePrivate::doStart()
m_process.start();
}
static CommandLine getCommandLine(
const FilePath sshBinary,
const CommandLine commandLine0,
const FilePath &workingDirectory,
const Environment &env,
const QStringList &options,
bool useX,
bool useTerminal,
bool usePidMarker,
bool sourceProfile)
CommandLine SshProcessInterfacePrivate::fullLocalCommandLine() const
{
const FilePath sshBinary = SshSettings::sshFilePath();
const bool useTerminal = q->m_setup.m_terminalMode != TerminalMode::Off || q->m_setup.m_ptyData;
const bool usePidMarker = !useTerminal;
const bool sourceProfile = m_device->extraData(Constants::SourceProfile).toBool();
const bool useX = !m_sshParameters.x11DisplayName.isEmpty();
CommandLine cmd{sshBinary};
if (useX)
@@ -692,9 +708,13 @@ static CommandLine getCommandLine(
cmd.addArg("-q");
cmd.addArgs(options);
cmd.addArgs(m_sshParameters.connectionOptions(sshBinary));
if (!m_socketFilePath.isEmpty())
cmd.addArgs({"-o", "ControlPath=" + m_socketFilePath});
CommandLine commandLine = commandLine0;
cmd.addArg(m_sshParameters.host());
CommandLine commandLine = q->m_setup.m_commandLine;
FilePath executable = FilePath::fromParts({}, {}, commandLine.executable().path());
commandLine.setExecutable(executable);
@@ -710,6 +730,7 @@ static CommandLine getCommandLine(
}
}
const FilePath &workingDirectory = q->m_setup.m_workingDirectory;
if (!workingDirectory.isEmpty()) {
inner.addArgs({"cd", workingDirectory.path()});
inner.addArgs("&&", CommandLine::Raw);
@@ -718,6 +739,7 @@ static CommandLine getCommandLine(
if (usePidMarker)
inner.addArgs(QString("echo ") + s_pidMarker + "$$" + s_pidMarker + " && ", CommandLine::Raw);
const Environment &env = q->m_setup.m_environment;
env.forEachEntry([&](const QString &key, const QString &value, bool) {
inner.addArgs(key + "='" + env.expandVariables(value) + '\'', CommandLine::Raw);
});
@@ -733,64 +755,6 @@ static CommandLine getCommandLine(
return cmd;
}
CommandLine SshProcessInterfacePrivate::fullLocalCommandLine() const
{
const FilePath sshBinary = SshSettings::sshFilePath();
const bool useTerminal = q->m_setup.m_terminalMode != TerminalMode::Off || q->m_setup.m_ptyData;
const bool usePidMarker = !useTerminal;
const bool sourceProfile = m_device->extraData(Constants::SourceProfile).toBool();
const bool useX = !m_sshParameters.x11DisplayName.isEmpty();
CommandLine cmd;
if (m_linkDevice) {
QStringList farOptions = m_sshParameters.connectionOptions("ssh");
farOptions << m_sshParameters.host();
const SshParameters nearParameters = m_linkDevice->sshParameters();
QStringList nearOptions = nearParameters.connectionOptions(sshBinary);
// if (!m_socketFilePath.isEmpty())
// options << "-o" << ("ControlPath=" + m_socketFilePath);
nearOptions << nearParameters.host();
cmd = getCommandLine("ssh",
q->m_setup.m_commandLine,
{},
{},
farOptions,
false,
false,
false,
false);
cmd = getCommandLine(sshBinary,
cmd,
{},
{},
nearOptions,
false,
false,
usePidMarker,
false);
} else {
QStringList options = m_sshParameters.connectionOptions(sshBinary);
if (!m_socketFilePath.isEmpty())
options << "-o" << ("ControlPath=" + m_socketFilePath);
options << m_sshParameters.host();
cmd = getCommandLine(sshBinary,
q->m_setup.m_commandLine,
q->m_setup.m_workingDirectory,
q->m_setup.m_environment,
options,
useX,
useTerminal,
usePidMarker,
sourceProfile);
}
return cmd;
}
// ShellThreadHandler
static SshParameters displayless(const SshParameters &sshParameters)

View File

@@ -154,9 +154,14 @@ TaskItem GenericLinuxDeviceTesterPrivate::gathererTask() const
}
};
const auto error = [this](const DeviceUsedPortsGatherer &gatherer) {
emit q->errorMessage(Tr::tr("Error gathering ports: %1").arg(gatherer.errorString()) + '\n');
emit q->errorMessage(Tr::tr("Error gathering ports: %1").arg(gatherer.errorString()) + '\n'
+ Tr::tr("Some tools will not work out of the box.\n"));
};
return Group {
optional,
PortGatherer(setup, done, error)
};
return PortGatherer(setup, done, error);
}
TaskItem GenericLinuxDeviceTesterPrivate::transferTask(FileTransferMethod method,

View File

@@ -65,7 +65,8 @@ RemoteLinuxRunConfiguration::RemoteLinuxRunConfiguration(Target *target, Id id)
QTC_ASSERT(runDevice, return);
const BuildTargetInfo bti = buildTargetInfo();
const FilePath localExecutable = bti.targetFilePath;
const DeployableFile depFile = target->deploymentData().deployableForLocalFile(localExecutable);
const DeploymentData deploymentData = target->deploymentData();
const DeployableFile depFile = deploymentData.deployableForLocalFile(localExecutable);
exeAspect->setExecutable(runDevice->filePath(depFile.remoteFilePath()));
symbolsAspect->setFilePath(localExecutable);