diff options
author | Christian Kandeler <[email protected]> | 2019-05-21 16:59:29 +0200 |
---|---|---|
committer | Christian Kandeler <[email protected]> | 2019-05-24 09:08:49 +0000 |
commit | 0a555018d1dda0aafff358774af2b564483a8c1e (patch) | |
tree | 657403526e058ab335f19b28e7283a86b2ac0810 /src/plugins | |
parent | be0d7aa3e94969234ebf4ba1ae552e973e7b6588 (diff) |
SSH: Pass remote command as QString
The old implementation sent the command over the wire as-is, so we
declared it as a QByteArray and let the caller choose the encoding. This
doesn't make sense anymore, as the command is now passed to an external
process as a QString anyway.
Change-Id: Ib84bc0f871db2b45b93f71d924c4177cc28d3bb0
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins')
11 files changed, 17 insertions, 24 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index 14414f05893..030e4057a3d 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -188,7 +188,7 @@ void SshDeviceProcess::handleConnected() d->process = runInTerminal() && d->runnable.executable.isEmpty() ? d->connection->createRemoteShell() - : d->connection->createRemoteProcess(fullCommandLine(d->runnable).toUtf8()); + : d->connection->createRemoteProcess(fullCommandLine(d->runnable)); const QString display = d->displayName(); if (!display.isEmpty()) d->process->requestX11Forwarding(display); diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp index c1c7b0a45f7..d8107458fd5 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocesslist.cpp @@ -54,7 +54,7 @@ void SshDeviceProcessList::doUpdate() this, &SshDeviceProcessList::handleConnectionError); connect(&d->process, &SshRemoteProcessRunner::processClosed, this, &SshDeviceProcessList::handleListProcessFinished); - d->process.run(listProcessesCommandLine().toUtf8(), device()->sshParameters()); + d->process.run(listProcessesCommandLine(), device()->sshParameters()); } void SshDeviceProcessList::doKillProcess(const DeviceProcessItem &process) diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp index 0e4a0b6ff56..4263a1e4985 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp @@ -292,12 +292,9 @@ void QnxDeployQtLibrariesDialog::checkRemoteDirectoryExistance() QTC_CHECK(m_state == Inactive); m_state = CheckingRemoteDirectory; - m_ui->deployLogWindow->appendPlainText(tr("Checking existence of \"%1\"") .arg(fullRemoteDirectory())); - - const QByteArray cmd = "test -d " + fullRemoteDirectory().toLatin1(); - m_processRunner->run(cmd, m_device->sshParameters()); + m_processRunner->run("test -d " + fullRemoteDirectory(), m_device->sshParameters()); } void QnxDeployQtLibrariesDialog::removeRemoteDirectory() @@ -305,11 +302,8 @@ void QnxDeployQtLibrariesDialog::removeRemoteDirectory() QTC_CHECK(m_state == CheckingRemoteDirectory); m_state = RemovingRemoteDirectory; - m_ui->deployLogWindow->appendPlainText(tr("Removing \"%1\"").arg(fullRemoteDirectory())); - - const QByteArray cmd = "rm -rf " + fullRemoteDirectory().toLatin1(); - m_processRunner->run(cmd, m_device->sshParameters()); + m_processRunner->run("rm -rf " + fullRemoteDirectory(), m_device->sshParameters()); } } // namespace Internal diff --git a/src/plugins/qnx/qnxdevicetester.cpp b/src/plugins/qnx/qnxdevicetester.cpp index b1374519d8a..5196043ad2b 100644 --- a/src/plugins/qnx/qnxdevicetester.cpp +++ b/src/plugins/qnx/qnxdevicetester.cpp @@ -113,8 +113,7 @@ void QnxDeviceTester::handleGenericTestFinished(TestResult result) m_state = VarRunTest; emit progressMessage(tr("Checking that files can be created in /var/run...")); m_processRunner->run(QStringLiteral("rm %1 > /dev/null 2>&1; echo ABC > %1 && rm %1") - .arg("/var/run/qtc_xxxx.pid") - .toLatin1(), + .arg("/var/run/qtc_xxxx.pid"), m_deviceConfiguration->sshParameters()); } @@ -189,7 +188,7 @@ void QnxDeviceTester::testNextCommand() QString command = m_commandsToTest[m_currentCommandIndex]; emit progressMessage(tr("Checking for %1...").arg(command)); - m_processRunner->run("command -v " + command.toLatin1(), m_deviceConfiguration->sshParameters()); + m_processRunner->run("command -v " + command, m_deviceConfiguration->sshParameters()); } void QnxDeviceTester::setFinished() diff --git a/src/plugins/remotelinux/genericdirectuploadservice.cpp b/src/plugins/remotelinux/genericdirectuploadservice.cpp index 014ed5db620..84779d373eb 100644 --- a/src/plugins/remotelinux/genericdirectuploadservice.cpp +++ b/src/plugins/remotelinux/genericdirectuploadservice.cpp @@ -238,8 +238,7 @@ void GenericDirectUploadService::queryFiles() continue; } // We'd like to use --format=%Y, but it's not supported by busybox. - const QByteArray statCmd = "stat -t " - + Utils::QtcProcess::quoteArgUnix(file.remoteFilePath()).toUtf8(); + const QString statCmd = "stat -t " + Utils::QtcProcess::quoteArgUnix(file.remoteFilePath()); SshRemoteProcess * const statProc = connection()->createRemoteProcess(statCmd).release(); statProc->setParent(this); connect(statProc, &SshRemoteProcess::done, this, @@ -328,7 +327,7 @@ void GenericDirectUploadService::chmod() const QString command = QLatin1String("chmod a+x ") + Utils::QtcProcess::quoteArgUnix(f.remoteFilePath()); SshRemoteProcess * const chmodProc - = connection()->createRemoteProcess(command.toUtf8()).release(); + = connection()->createRemoteProcess(command).release(); chmodProc->setParent(this); connect(chmodProc, &SshRemoteProcess::done, this, [this, chmodProc, state = d->state](const QString &error) { diff --git a/src/plugins/remotelinux/remotelinuxcheckforfreediskspaceservice.cpp b/src/plugins/remotelinux/remotelinuxcheckforfreediskspaceservice.cpp index 8b1fb6dfe8a..e1d2447c510 100644 --- a/src/plugins/remotelinux/remotelinuxcheckforfreediskspaceservice.cpp +++ b/src/plugins/remotelinux/remotelinuxcheckforfreediskspaceservice.cpp @@ -122,7 +122,7 @@ void RemoteLinuxCheckForFreeDiskSpaceService::doDeploy() this, &RemoteLinuxCheckForFreeDiskSpaceService::handleStdErr); const QString command = QString::fromLatin1("df -k %1 |tail -n 1 |sed 's/ */ /g' " "|cut -d ' ' -f 4").arg(d->pathToCheck); - d->processRunner->run(command.toUtf8(), deviceConfiguration()->sshParameters()); + d->processRunner->run(command, deviceConfiguration()->sshParameters()); } void RemoteLinuxCheckForFreeDiskSpaceService::stopDeployment() diff --git a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp index c385f2a4ba2..471ace1a0e6 100644 --- a/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp +++ b/src/plugins/remotelinux/remotelinuxcustomcommanddeployservice.cpp @@ -91,7 +91,7 @@ void RemoteLinuxCustomCommandDeployService::doDeploy() emit progressMessage(tr("Starting remote command \"%1\"...").arg(d->commandLine)); d->state = Running; - d->runner->run(d->commandLine.toUtf8(), deviceConfiguration()->sshParameters()); + d->runner->run(d->commandLine, deviceConfiguration()->sshParameters()); } void RemoteLinuxCustomCommandDeployService::stopDeployment() diff --git a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp index 4d3439931bb..bf27f6d03ea 100644 --- a/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp +++ b/src/plugins/remotelinux/remotelinuxpackageinstaller.cpp @@ -76,7 +76,7 @@ void AbstractRemoteLinuxPackageInstaller::installPackage(const IDevice::ConstPtr QString cmdLine = installCommandLine(packageFilePath); if (removePackageFile) cmdLine += QLatin1String(" && (rm ") + packageFilePath + QLatin1String(" || :)"); - d->installer->run(cmdLine.toUtf8(), deviceConfig->sshParameters()); + d->installer->run(cmdLine, deviceConfig->sshParameters()); d->isRunning = true; } @@ -86,7 +86,7 @@ void AbstractRemoteLinuxPackageInstaller::cancelInstallation() if (!d->killProcess) d->killProcess = new SshRemoteProcessRunner(this); - d->killProcess->run(cancelInstallationCommandLine().toUtf8(), d->deviceConfig->sshParameters()); + d->killProcess->run(cancelInstallationCommandLine(), d->deviceConfig->sshParameters()); setFinished(); } diff --git a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp index 64e1f5b2d3b..5a5def6bb31 100644 --- a/src/plugins/remotelinux/remotelinuxsignaloperation.cpp +++ b/src/plugins/remotelinux/remotelinuxsignaloperation.cpp @@ -60,7 +60,7 @@ void RemoteLinuxSignalOperation::run(const QString &command) this, &RemoteLinuxSignalOperation::runnerProcessFinished); connect(m_runner, &QSsh::SshRemoteProcessRunner::connectionError, this, &RemoteLinuxSignalOperation::runnerConnectionError); - m_runner->run(command.toLatin1(), m_sshParameters); + m_runner->run(command, m_sshParameters); } void RemoteLinuxSignalOperation::finish() diff --git a/src/plugins/remotelinux/rsyncdeploystep.cpp b/src/plugins/remotelinux/rsyncdeploystep.cpp index 8c0900d750b..644ad1c3d6b 100644 --- a/src/plugins/remotelinux/rsyncdeploystep.cpp +++ b/src/plugins/remotelinux/rsyncdeploystep.cpp @@ -101,7 +101,7 @@ void RsyncDeployService::createRemoteDirectories() remoteDirs.sort(); remoteDirs.removeDuplicates(); m_mkdir = connection()->createRemoteProcess("mkdir -p " + QtcProcess::Arguments - ::createUnixArgs(remoteDirs).toString().toUtf8()); + ::createUnixArgs(remoteDirs).toString()); connect(m_mkdir.get(), &SshRemoteProcess::done, this, [this](const QString &error) { QString userError; if (!error.isEmpty()) diff --git a/src/plugins/remotelinux/sshkeydeployer.cpp b/src/plugins/remotelinux/sshkeydeployer.cpp index 7581a720185..2c73ffeff1b 100644 --- a/src/plugins/remotelinux/sshkeydeployer.cpp +++ b/src/plugins/remotelinux/sshkeydeployer.cpp @@ -67,9 +67,10 @@ void SshKeyDeployer::deployPublicKey(const SshConnectionParameters &sshParams, this, &SshKeyDeployer::handleConnectionFailure); connect(&d->deployProcess, &SshRemoteProcessRunner::processClosed, this, &SshKeyDeployer::handleKeyUploadFinished); - const QByteArray command = "test -d .ssh " + const QString command = "test -d .ssh " "|| mkdir .ssh && chmod 0700 .ssh && echo '" - + reader.data() + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys"; + + QString::fromLocal8Bit(reader.data()) + + "' >> .ssh/authorized_keys && chmod 0600 .ssh/authorized_keys"; d->deployProcess.run(command, sshParams); } |