summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libs/ssh/CMakeLists.txt1
-rw-r--r--src/libs/ssh/sftpsession.cpp5
-rw-r--r--src/libs/ssh/sftptransfer.cpp5
-rw-r--r--src/libs/ssh/ssh.qbs2
-rw-r--r--src/libs/ssh/sshconnection.cpp8
-rw-r--r--src/libs/ssh/sshprocess.cpp50
-rw-r--r--src/libs/ssh/sshprocess.h40
-rw-r--r--src/libs/ssh/sshremoteprocess.cpp31
-rw-r--r--src/libs/ssh/sshremoteprocess.h7
-rw-r--r--src/plugins/remotelinux/linuxdevice.cpp16
-rw-r--r--src/plugins/remotelinux/linuxdevicetester.cpp3
-rw-r--r--src/plugins/remotelinux/rsyncdeploystep.cpp5
12 files changed, 48 insertions, 125 deletions
diff --git a/src/libs/ssh/CMakeLists.txt b/src/libs/ssh/CMakeLists.txt
index 6f5d1cb764..290afe5acd 100644
--- a/src/libs/ssh/CMakeLists.txt
+++ b/src/libs/ssh/CMakeLists.txt
@@ -11,7 +11,6 @@ add_qtc_library(QtcSsh
sshconnectionmanager.cpp sshconnectionmanager.h
sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui
sshlogging.cpp sshlogging_p.h
- sshprocess.cpp sshprocess.h
sshconnection.cpp sshconnection.h
sshconnectionmanager.cpp sshconnectionmanager.h
sshkeycreationdialog.cpp sshkeycreationdialog.h sshkeycreationdialog.ui
diff --git a/src/libs/ssh/sftpsession.cpp b/src/libs/ssh/sftpsession.cpp
index 6fbe26fb3c..2b5535e129 100644
--- a/src/libs/ssh/sftpsession.cpp
+++ b/src/libs/ssh/sftpsession.cpp
@@ -26,7 +26,7 @@
#include "sftpsession.h"
#include "sshlogging_p.h"
-#include "sshprocess.h"
+#include "sshremoteprocess.h"
#include "sshsettings.h"
#include <utils/fileutils.h>
@@ -58,7 +58,7 @@ struct Command
struct SftpSession::SftpSessionPrivate
{
- SshProcess sftpProc;
+ QtcProcess sftpProc;
QStringList connectionArgs;
QByteArray output;
QQueue<Command> pendingCommands;
@@ -111,6 +111,7 @@ static QByteArray prompt() { return "sftp> "; }
SftpSession::SftpSession(const QStringList &connectionArgs) : d(new SftpSessionPrivate)
{
+ SshRemoteProcess::setupSshEnvironment(&d->sftpProc);
d->sftpProc.setProcessMode(ProcessMode::Writer);
d->connectionArgs = connectionArgs;
connect(&d->sftpProc, &QtcProcess::started, [this] {
diff --git a/src/libs/ssh/sftptransfer.cpp b/src/libs/ssh/sftptransfer.cpp
index 26d4306f5c..3b2acf784c 100644
--- a/src/libs/ssh/sftptransfer.cpp
+++ b/src/libs/ssh/sftptransfer.cpp
@@ -26,7 +26,7 @@
#include "sftptransfer.h"
#include "sshlogging_p.h"
-#include "sshprocess.h"
+#include "sshremoteprocess.h"
#include "sshsettings.h"
#include <QDir>
@@ -44,7 +44,7 @@ namespace QSsh {
struct SftpTransfer::SftpTransferPrivate
{
- SshProcess sftpProc;
+ QtcProcess sftpProc;
FilesToTransfer files;
Internal::FileTransferType transferType;
FileTransferErrorHandling errorHandlingMode;
@@ -109,6 +109,7 @@ SftpTransfer::SftpTransfer(const FilesToTransfer &files, Internal::FileTransferT
const QStringList &connectionArgs)
: d(new SftpTransferPrivate)
{
+ SshRemoteProcess::setupSshEnvironment(&d->sftpProc);
d->files = files;
d->transferType = type;
d->errorHandlingMode = errorHandlingMode;
diff --git a/src/libs/ssh/ssh.qbs b/src/libs/ssh/ssh.qbs
index 36c69c7ee7..0b940452c3 100644
--- a/src/libs/ssh/ssh.qbs
+++ b/src/libs/ssh/ssh.qbs
@@ -29,8 +29,6 @@ Project {
"sshkeycreationdialog.ui",
"sshlogging.cpp",
"sshlogging_p.h",
- "sshprocess.cpp",
- "sshprocess.h",
"sshremoteprocess.cpp",
"sshremoteprocess.h",
"sshremoteprocessrunner.cpp",
diff --git a/src/libs/ssh/sshconnection.cpp b/src/libs/ssh/sshconnection.cpp
index 8eebad4e2b..4e695cbbfc 100644
--- a/src/libs/ssh/sshconnection.cpp
+++ b/src/libs/ssh/sshconnection.cpp
@@ -28,7 +28,6 @@
#include "sftpsession.h"
#include "sftptransfer.h"
#include "sshlogging_p.h"
-#include "sshprocess.h"
#include "sshremoteprocess.h"
#include "sshsettings.h"
@@ -129,7 +128,10 @@ bool operator!=(const SshConnectionParameters &p1, const SshConnectionParameters
struct SshConnection::SshConnectionPrivate
{
SshConnectionPrivate(const SshConnectionParameters &sshParameters)
- : connParams(sshParameters) {}
+ : connParams(sshParameters)
+ {
+ SshRemoteProcess::setupSshEnvironment(&masterProcess);
+ }
QString fullProcessError()
{
@@ -166,7 +168,7 @@ struct SshConnection::SshConnectionPrivate
const SshConnectionParameters connParams;
SshConnectionInfo connInfo;
- SshProcess masterProcess;
+ QtcProcess masterProcess;
QString errorString;
std::unique_ptr<QTemporaryDir> masterSocketDir;
State state = Unconnected;
diff --git a/src/libs/ssh/sshprocess.cpp b/src/libs/ssh/sshprocess.cpp
deleted file mode 100644
index d3063dfcb3..0000000000
--- a/src/libs/ssh/sshprocess.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#include "sshprocess.h"
-
-#include "sshsettings.h"
-
-#include <utils/environment.h>
-
-namespace QSsh {
-
-SshProcess::SshProcess()
-{
- Utils::Environment env = Utils::Environment::systemEnvironment();
- if (SshSettings::askpassFilePath().exists()) {
- env.set("SSH_ASKPASS", SshSettings::askpassFilePath().toUserOutput());
-
- // OpenSSH only uses the askpass program if DISPLAY is set, regardless of the platform.
- if (!env.hasKey("DISPLAY"))
- env.set("DISPLAY", ":0");
- }
- setEnvironment(env);
-
- // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
- setDisableUnixTerminal();
-}
-
-} // namespace QSsh
diff --git a/src/libs/ssh/sshprocess.h b/src/libs/ssh/sshprocess.h
deleted file mode 100644
index afde29c538..0000000000
--- a/src/libs/ssh/sshprocess.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt Creator.
-**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-****************************************************************************/
-
-#pragma once
-
-#include "ssh_global.h"
-
-#include <utils/qtcprocess.h>
-
-namespace QSsh {
-
-class QSSH_EXPORT SshProcess : public Utils::QtcProcess
-{
-public:
- SshProcess();
-};
-
-} // namespace QSsh
diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp
index a3c2a11481..13b40ff72e 100644
--- a/src/libs/ssh/sshremoteprocess.cpp
+++ b/src/libs/ssh/sshremoteprocess.cpp
@@ -46,12 +46,14 @@
*/
using namespace QSsh::Internal;
+using namespace Utils;
namespace QSsh {
SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &connectionArgs)
- : SshProcess()
+ : QtcProcess()
{
+ setupSshEnvironment(this);
m_remoteCommand = command;
m_connectionArgs = connectionArgs;
@@ -70,9 +72,9 @@ SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &co
void SshRemoteProcess::start()
{
QTC_ASSERT(!isRunning(), return);
- const Utils::CommandLine cmd = fullLocalCommandLine();
+ const CommandLine cmd = fullLocalCommandLine();
if (!m_displayName.isEmpty()) {
- Utils::Environment env = environment();
+ Environment env = environment();
env.set("DISPLAY", m_displayName);
setEnvironment(env);
}
@@ -86,9 +88,9 @@ void SshRemoteProcess::requestX11Forwarding(const QString &displayName)
m_displayName = displayName;
}
-Utils::CommandLine SshRemoteProcess::fullLocalCommandLine(bool inTerminal) const
+CommandLine SshRemoteProcess::fullLocalCommandLine(bool inTerminal) const
{
- Utils::CommandLine cmd{SshSettings::sshFilePath()};
+ CommandLine cmd {SshSettings::sshFilePath()};
if (!m_displayName.isEmpty())
cmd.addArg("-X");
@@ -104,4 +106,23 @@ Utils::CommandLine SshRemoteProcess::fullLocalCommandLine(bool inTerminal) const
return cmd;
}
+bool SshRemoteProcess::setupSshEnvironment(QtcProcess *process)
+{
+ Environment env = process->hasEnvironment() ? process->environment()
+ : Environment::systemEnvironment();
+ const bool hasDisplay = env.hasKey("DISPLAY") && (env.value("DISPLAY") != QString(":0"));
+ if (SshSettings::askpassFilePath().exists()) {
+ env.set("SSH_ASKPASS", SshSettings::askpassFilePath().toUserOutput());
+
+ // OpenSSH only uses the askpass program if DISPLAY is set, regardless of the platform.
+ if (!env.hasKey("DISPLAY"))
+ env.set("DISPLAY", ":0");
+ }
+ process->setEnvironment(env);
+
+ // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
+ process->setDisableUnixTerminal();
+ return hasDisplay;
+}
+
} // namespace QSsh
diff --git a/src/libs/ssh/sshremoteprocess.h b/src/libs/ssh/sshremoteprocess.h
index c4a28680b2..5fbe2da930 100644
--- a/src/libs/ssh/sshremoteprocess.h
+++ b/src/libs/ssh/sshremoteprocess.h
@@ -26,13 +26,14 @@
#pragma once
#include "ssh_global.h"
-#include "sshprocess.h"
+
+#include <utils/qtcprocess.h>
namespace Utils { class CommandLine; }
namespace QSsh {
-class QSSH_EXPORT SshRemoteProcess : public SshProcess
+class QSSH_EXPORT SshRemoteProcess : public Utils::QtcProcess
{
Q_OBJECT
@@ -44,6 +45,8 @@ public:
Utils::CommandLine fullLocalCommandLine(bool inTerminal = false) const;
+ static bool setupSshEnvironment(Utils::QtcProcess *process);
+
signals:
void done(const QString &error);
diff --git a/src/plugins/remotelinux/linuxdevice.cpp b/src/plugins/remotelinux/linuxdevice.cpp
index f5cddad6c3..4c3aa4c7b9 100644
--- a/src/plugins/remotelinux/linuxdevice.cpp
+++ b/src/plugins/remotelinux/linuxdevice.cpp
@@ -466,21 +466,7 @@ void LinuxDevice::runProcess(QtcProcess &process) const
{
QTC_ASSERT(!process.isRunning(), return);
- Utils::Environment env = process.hasEnvironment() ? process.environment()
- : Utils::Environment::systemEnvironment();
- const bool hasDisplay = env.hasKey("DISPLAY") && (env.value("DISPLAY") != QString(":0"));
- if (SshSettings::askpassFilePath().exists()) {
- env.set("SSH_ASKPASS", SshSettings::askpassFilePath().toUserOutput());
-
- // OpenSSH only uses the askpass program if DISPLAY is set, regardless of the platform.
- if (!env.hasKey("DISPLAY"))
- env.set("DISPLAY", ":0");
- }
- process.setEnvironment(env);
-
- // Otherwise, ssh will ignore SSH_ASKPASS and read from /dev/tty directly.
- process.setDisableUnixTerminal();
-
+ const bool hasDisplay = SshRemoteProcess::setupSshEnvironment(&process);
process.setCommand(d->fullLocalCommandLine(process.commandLine(), process.terminalMode(),
hasDisplay));
process.start();
diff --git a/src/plugins/remotelinux/linuxdevicetester.cpp b/src/plugins/remotelinux/linuxdevicetester.cpp
index 1353d91764..a7e0975bca 100644
--- a/src/plugins/remotelinux/linuxdevicetester.cpp
+++ b/src/plugins/remotelinux/linuxdevicetester.cpp
@@ -55,7 +55,7 @@ public:
SshRemoteProcessPtr process;
DeviceUsedPortsGatherer portsGatherer;
SftpTransferPtr sftpTransfer;
- SshProcess rsyncProcess;
+ Utils::QtcProcess rsyncProcess;
State state = Inactive;
bool sftpWorks = false;
};
@@ -67,6 +67,7 @@ using namespace Internal;
GenericLinuxDeviceTester::GenericLinuxDeviceTester(QObject *parent)
: DeviceTester(parent), d(new GenericLinuxDeviceTesterPrivate)
{
+ SshRemoteProcess::setupSshEnvironment(&d->rsyncProcess);
}
GenericLinuxDeviceTester::~GenericLinuxDeviceTester()
diff --git a/src/plugins/remotelinux/rsyncdeploystep.cpp b/src/plugins/remotelinux/rsyncdeploystep.cpp
index 21981ba962..5d5accd20a 100644
--- a/src/plugins/remotelinux/rsyncdeploystep.cpp
+++ b/src/plugins/remotelinux/rsyncdeploystep.cpp
@@ -48,7 +48,8 @@ class RsyncDeployService : public AbstractRemoteLinuxDeployService
{
Q_OBJECT
public:
- RsyncDeployService(QObject *parent = nullptr) : AbstractRemoteLinuxDeployService(parent) {}
+ RsyncDeployService(QObject *parent = nullptr) : AbstractRemoteLinuxDeployService(parent)
+ { SshRemoteProcess::setupSshEnvironment(&m_rsync); }
void setDeployableFiles(const QList<DeployableFile> &files) { m_deployableFiles = files; }
void setIgnoreMissingFiles(bool ignore) { m_ignoreMissingFiles = ignore; }
@@ -69,7 +70,7 @@ private:
mutable QList<DeployableFile> m_deployableFiles;
bool m_ignoreMissingFiles = false;
QString m_flags;
- SshProcess m_rsync;
+ QtcProcess m_rsync;
SshRemoteProcessPtr m_mkdir;
};