diff options
author | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-09 17:38:19 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@nokia.com> | 2011-11-09 17:41:27 +0100 |
commit | 5d5db225a82964a40178abc360811456dabda8a4 (patch) | |
tree | ba3933d2244674c140000ee3617da378a5d44f99 /src/plugins | |
parent | bddfae718242d8bf2b6868cb6628f97c9b3a10f2 (diff) | |
download | qt-creator-5d5db225a82964a40178abc360811456dabda8a4.tar.gz |
SSH: Don't allow external access to process runner's connection object.
It does not belong to the runner anymore after the process has finished,
so we must prevent anyone from getting a copy.
(This includes a minor API fix for RemoteLinux code that depended on
the connection being available.)
Change-Id: Icc28dc3c820f4c2210bb6fb08171cd6a84534dee
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
Diffstat (limited to 'src/plugins')
12 files changed, 33 insertions, 45 deletions
diff --git a/src/plugins/madde/maddedevicetester.cpp b/src/plugins/madde/maddedevicetester.cpp index 2ca4d09425..658693de4c 100644 --- a/src/plugins/madde/maddedevicetester.cpp +++ b/src/plugins/madde/maddedevicetester.cpp @@ -109,8 +109,7 @@ void MaddeDeviceTester::handleGenericTestFinished(TestResult result) if (!m_processRunner) m_processRunner = new SshRemoteProcessRunner(this); - connect(m_processRunner, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); + connect(m_processRunner, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(m_processRunner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleStdout(QByteArray))); connect(m_processRunner, SIGNAL(processErrorOutputAvailable(QByteArray)), @@ -137,7 +136,7 @@ void MaddeDeviceTester::handleConnectionError() QTC_ASSERT(m_state != Inactive, return); emit errorMessage(tr("SSH connection error: %1\n") - .arg(m_processRunner->connection()->errorString())); + .arg(m_processRunner->lastConnectionErrorString())); m_result = TestFailure; setFinished(); } diff --git a/src/plugins/madde/maemodeploybymountsteps.cpp b/src/plugins/madde/maemodeploybymountsteps.cpp index 062176d6ac..8d82eb1924 100644 --- a/src/plugins/madde/maemodeploybymountsteps.cpp +++ b/src/plugins/madde/maemodeploybymountsteps.cpp @@ -309,7 +309,7 @@ void MaemoMountAndInstallPackageService::doInstall() { const QString remoteFilePath = deployMountPoint() + QLatin1Char('/') + QFileInfo(m_packageFilePath).fileName(); - m_installer->installPackage(connection(), remoteFilePath, false); + m_installer->installPackage(deviceConfiguration(), remoteFilePath, false); } void MaemoMountAndInstallPackageService::cancelInstallation() diff --git a/src/plugins/madde/maemopublisherfremantlefree.cpp b/src/plugins/madde/maemopublisherfremantlefree.cpp index db953d4664..6c48286c45 100644 --- a/src/plugins/madde/maemopublisherfremantlefree.cpp +++ b/src/plugins/madde/maemopublisherfremantlefree.cpp @@ -388,8 +388,7 @@ void MaemoPublisherFremantleFree::uploadPackage() if (!m_uploader) m_uploader = new SshRemoteProcessRunner(this); connect(m_uploader, SIGNAL(processStarted()), SLOT(handleScpStarted())); - connect(m_uploader, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); + connect(m_uploader, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(m_uploader, SIGNAL(processClosed(int)), SLOT(handleUploadJobFinished(int))); connect(m_uploader, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleScpStdOut(QByteArray))); @@ -409,7 +408,7 @@ void MaemoPublisherFremantleFree::handleScpStarted() void MaemoPublisherFremantleFree::handleConnectionError() { if (m_state != Inactive) { - finishWithFailure(tr("SSH error: %1").arg(m_uploader->connection()->errorString()), + finishWithFailure(tr("SSH error: %1").arg(m_uploader->lastConnectionErrorString()), tr("Upload failed.")); } } diff --git a/src/plugins/madde/maemoremotecopyfacility.cpp b/src/plugins/madde/maemoremotecopyfacility.cpp index dd2593ad2a..064d8388d9 100644 --- a/src/plugins/madde/maemoremotecopyfacility.cpp +++ b/src/plugins/madde/maemoremotecopyfacility.cpp @@ -65,7 +65,7 @@ void MaemoRemoteCopyFacility::copyFiles(const SshConnection::Ptr &connection, if (!m_copyRunner) m_copyRunner = new SshRemoteProcessRunner(this); - connect(m_copyRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); + connect(m_copyRunner, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(m_copyRunner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleRemoteStdout(QByteArray))); connect(m_copyRunner, SIGNAL(processErrorOutputAvailable(QByteArray)), @@ -88,9 +88,8 @@ void MaemoRemoteCopyFacility::cancel() void MaemoRemoteCopyFacility::handleConnectionError() { - const QString errMsg = m_copyRunner->connection()->errorString(); setFinished(); - emit finished(tr("Connection failed: %1").arg(errMsg)); + emit finished(tr("Connection failed: %1").arg(m_copyRunner->lastConnectionErrorString())); } void MaemoRemoteCopyFacility::handleRemoteStdout(const QByteArray &output) diff --git a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp index d0c6dc63c3..9f7d658973 100644 --- a/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp +++ b/src/plugins/remotelinux/abstractuploadandinstallpackageservice.cpp @@ -159,7 +159,7 @@ void AbstractUploadAndInstallPackageService::handleUploadFinished(const QString connect(packageInstaller(), SIGNAL(stderrData(QString)), SIGNAL(stdErrData(QString))); connect(packageInstaller(), SIGNAL(finished(QString)), SLOT(handleInstallationFinished(QString))); - packageInstaller()->installPackage(connection(), remoteFilePath, true); + packageInstaller()->installPackage(deviceConfiguration(), remoteFilePath, true); } void AbstractUploadAndInstallPackageService::handleInstallationFinished(const QString &errorMsg) diff --git a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp index 9a15d27db7..c82f4b1752 100644 --- a/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp +++ b/src/plugins/remotelinux/remotelinuxenvironmentreader.cpp @@ -61,8 +61,7 @@ void RemoteLinuxEnvironmentReader::start(const QString &environmentSetupCommand) m_stop = false; if (!m_remoteProcessRunner) m_remoteProcessRunner = new Utils::SshRemoteProcessRunner(this); - connect(m_remoteProcessRunner, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionFailure())); + connect(m_remoteProcessRunner, SIGNAL(connectionError()), SLOT(handleConnectionFailure())); connect(m_remoteProcessRunner, SIGNAL(processClosed(int)), SLOT(remoteProcessFinished(int))); connect(m_remoteProcessRunner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(remoteOutput(QByteArray))); @@ -87,8 +86,7 @@ void RemoteLinuxEnvironmentReader::handleConnectionFailure() return; disconnect(m_remoteProcessRunner, 0, this, 0); - emit error(tr("Connection error: %1") - .arg(m_remoteProcessRunner->connection()->errorString())); + emit error(tr("Connection error: %1").arg(m_remoteProcessRunner->lastConnectionErrorString())); emit finished(); } diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp index f02d8c417f..b7be388482 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp @@ -31,12 +31,13 @@ **************************************************************************/ #include "remotelinuxpackageinstaller.h" -#include <QtCore/QByteArray> +#include "linuxdeviceconfiguration.h" #include <utils/qtcassert.h> -#include <utils/ssh/sshconnection.h> #include <utils/ssh/sshremoteprocessrunner.h> +#include <QtCore/QByteArray> + using namespace Utils; namespace RemoteLinux { @@ -48,6 +49,7 @@ public: AbstractRemoteLinuxPackageInstallerPrivate() : isRunning(false), installer(0), killProcess(0) {} bool isRunning; + LinuxDeviceConfiguration::ConstPtr deviceConfig; Utils::SshRemoteProcessRunner *installer; Utils::SshRemoteProcessRunner *killProcess; }; @@ -64,17 +66,16 @@ AbstractRemoteLinuxPackageInstaller::~AbstractRemoteLinuxPackageInstaller() delete d; } -void AbstractRemoteLinuxPackageInstaller::installPackage(const SshConnection::Ptr &connection, +void AbstractRemoteLinuxPackageInstaller::installPackage(const LinuxDeviceConfiguration::ConstPtr &deviceConfig, const QString &packageFilePath, bool removePackageFile) { - QTC_ASSERT(connection && connection->state() == SshConnection::Connected - && !d->isRunning, return); + QTC_ASSERT(!d->isRunning, return); + d->deviceConfig = deviceConfig; prepareInstallation(); if (!d->installer) d->installer = new SshRemoteProcessRunner(this); - connect(d->installer, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); + connect(d->installer, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(d->installer, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleInstallerOutput(QByteArray))); connect(d->installer, SIGNAL(processErrorOutputAvailable(QByteArray)), @@ -84,19 +85,17 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const SshConnection::Pt QString cmdLine = installCommandLine(packageFilePath); if (removePackageFile) cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); - d->installer->run(cmdLine.toUtf8(), connection->connectionParameters()); + d->installer->run(cmdLine.toUtf8(), deviceConfig->sshParameters()); d->isRunning = true; } void AbstractRemoteLinuxPackageInstaller::cancelInstallation() { - QTC_ASSERT(d->installer && d->installer->connection()->state() == SshConnection::Connected - && d->isRunning, return); + QTC_ASSERT(d->installer && d->isRunning, return); if (!d->killProcess) d->killProcess = new SshRemoteProcessRunner(this); - d->killProcess->run(cancelInstallationCommandLine().toUtf8(), - d->installer->connection()->connectionParameters()); + d->killProcess->run(cancelInstallationCommandLine().toUtf8(), d->deviceConfig->sshParameters()); setFinished(); } @@ -104,7 +103,7 @@ void AbstractRemoteLinuxPackageInstaller::handleConnectionError() { if (!d->isRunning) return; - emit finished(tr("Connection failure: %1").arg(d->installer->connection()->errorString())); + emit finished(tr("Connection failure: %1").arg(d->installer->lastConnectionErrorString())); setFinished(); } diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.h b/src/plugins/remotelinux/remotelinuxpackageinstaller.h index 02982b135e..9c40164976 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.h +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.h @@ -38,11 +38,9 @@ #include <QtCore/QSharedPointer> #include <QtCore/QString> -namespace Utils { -class SshConnection; -} - namespace RemoteLinux { +class LinuxDeviceConfiguration; + namespace Internal { class AbstractRemoteLinuxPackageInstallerPrivate; } // namespace Internal @@ -54,7 +52,7 @@ class REMOTELINUX_EXPORT AbstractRemoteLinuxPackageInstaller : public QObject public: ~AbstractRemoteLinuxPackageInstaller(); - void installPackage(const QSharedPointer<Utils::SshConnection> &connection, + void installPackage(const QSharedPointer<const LinuxDeviceConfiguration> &deviceConfig, const QString &packageFilePath, bool removePackageFile); void cancelInstallation(); diff --git a/src/plugins/remotelinux/remotelinuxprocesslist.cpp b/src/plugins/remotelinux/remotelinuxprocesslist.cpp index c5f62e363e..aa5ea9db47 100644 --- a/src/plugins/remotelinux/remotelinuxprocesslist.cpp +++ b/src/plugins/remotelinux/remotelinuxprocesslist.cpp @@ -154,7 +154,7 @@ void AbstractRemoteLinuxProcessList::handleConnectionError() { QTC_ASSERT(d->state != Inactive, return); - emit error(tr("Connection failure: %1").arg(d->process.connection()->errorString())); + emit error(tr("Connection failure: %1").arg(d->process.lastConnectionErrorString())); beginResetModel(); d->remoteProcesses.clear(); endResetModel(); @@ -204,8 +204,7 @@ void AbstractRemoteLinuxProcessList::handleRemoteProcessFinished(int exitStatus) void AbstractRemoteLinuxProcessList::startProcess(const QString &cmdLine) { - connect(&d->process, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); + connect(&d->process, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(&d->process, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleRemoteStdOut(QByteArray))); connect(&d->process, SIGNAL(processErrorOutputAvailable(QByteArray)), diff --git a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp index e5092f9a0c..36056b8d9b 100644 --- a/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp +++ b/src/plugins/remotelinux/remotelinuxusedportsgatherer.cpp @@ -78,7 +78,7 @@ void RemoteLinuxUsedPortsGatherer::start(const Utils::SshConnection::Ptr &connec d->usedPorts.clear(); d->remoteStdout.clear(); d->remoteStderr.clear(); - connect(&d->procRunner, SIGNAL(connectionError(Utils::SshError)), SLOT(handleConnectionError())); + connect(&d->procRunner, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(&d->procRunner, SIGNAL(processClosed(int)), SLOT(handleProcessClosed(int))); connect(&d->procRunner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleRemoteStdOut(QByteArray))); @@ -150,7 +150,7 @@ void RemoteLinuxUsedPortsGatherer::handleConnectionError() { if (!d->running) return; - emit error(tr("Connection error: %1").arg(d->procRunner.connection()->errorString())); + emit error(tr("Connection error: %1").arg(d->procRunner.lastConnectionErrorString())); stop(); } diff --git a/src/plugins/remotelinux/sshkeydeployer.cpp b/src/plugins/remotelinux/sshkeydeployer.cpp index 5bd32846a8..4a944c5ccf 100644 --- a/src/plugins/remotelinux/sshkeydeployer.cpp +++ b/src/plugins/remotelinux/sshkeydeployer.cpp @@ -71,8 +71,7 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams, return; } - connect(&d->deployProcess, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionFailure())); + connect(&d->deployProcess, SIGNAL(connectionError()), SLOT(handleConnectionFailure())); connect(&d->deployProcess, SIGNAL(processClosed(int)), SLOT(handleKeyUploadFinished(int))); const QByteArray command = "test -d .ssh " "|| mkdir .ssh && chmod 0700 .ssh && echo '" @@ -82,9 +81,8 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams, void SshKeyDeployer::handleConnectionFailure() { - const QString errorMsg = d->deployProcess.connection()->errorString(); cleanup(); - emit error(tr("Connection failed: %1").arg(errorMsg)); + emit error(tr("Connection failed: %1").arg(d->deployProcess.lastConnectionErrorString())); } void SshKeyDeployer::handleKeyUploadFinished(int exitStatus) diff --git a/src/plugins/remotelinux/startgdbserverdialog.cpp b/src/plugins/remotelinux/startgdbserverdialog.cpp index c41061f24c..a8eadec9cc 100644 --- a/src/plugins/remotelinux/startgdbserverdialog.cpp +++ b/src/plugins/remotelinux/startgdbserverdialog.cpp @@ -203,7 +203,7 @@ void StartGdbServerDialog::startGdbServer() void StartGdbServerDialog::handleConnectionError() { d->ui.textBrowser->append(tr("Connection error: %1") - .arg(d->runner.connection()->errorString())); + .arg(d->runner.lastConnectionErrorString())); emit processAborted(); } @@ -238,8 +238,7 @@ void StartGdbServerDialog::handleProcessClosed(int status) void StartGdbServerDialog::startGdbServerOnPort(int port, int pid) { LinuxDeviceConfiguration::ConstPtr device = d->currentDevice(); - connect(&d->runner, SIGNAL(connectionError(Utils::SshError)), - SLOT(handleConnectionError())); + connect(&d->runner, SIGNAL(connectionError()), SLOT(handleConnectionError())); connect(&d->runner, SIGNAL(processStarted()), SLOT(handleProcessStarted())); connect(&d->runner, SIGNAL(processOutputAvailable(QByteArray)), SLOT(handleProcessOutputAvailable(QByteArray))); |