aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorJarek Kobus <[email protected]>2022-05-06 02:16:54 +0200
committerJarek Kobus <[email protected]>2022-05-09 07:42:02 +0000
commitd8ee25ec3db039368ac0440af647fd7afd80079b (patch)
treede55d7076c9902cfb11fa0ba447a14667cf52223 /src/libs
parent48d1bd0551243ed541068f0c52f72bac81041997 (diff)
Move setupSshEnvironment() into SshConnectionParameters
As we are going to remove SshRemoteProcess. Change-Id: I07cf246791f1adb6cfc454935d7e330c2f1d4dc7 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/ssh/sftptransfer.cpp5
-rw-r--r--src/libs/ssh/sshconnection.cpp22
-rw-r--r--src/libs/ssh/sshconnection.h4
-rw-r--r--src/libs/ssh/sshremoteprocess.cpp22
-rw-r--r--src/libs/ssh/sshremoteprocess.h2
5 files changed, 30 insertions, 25 deletions
diff --git a/src/libs/ssh/sftptransfer.cpp b/src/libs/ssh/sftptransfer.cpp
index 55b7489d4b7..2151bc0817e 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 "sshremoteprocess.h"
+#include "sshconnection.h"
#include "sshsettings.h"
#include <QDir>
@@ -37,6 +37,7 @@
#include <utils/algorithm.h>
#include <utils/commandline.h>
+#include <utils/qtcprocess.h>
using namespace Utils;
@@ -109,7 +110,7 @@ SftpTransfer::SftpTransfer(const FilesToTransfer &files, Internal::FileTransferT
const QStringList &connectionArgs)
: d(new SftpTransferPrivate)
{
- SshRemoteProcess::setupSshEnvironment(&d->sftpProc);
+ SshConnectionParameters::setupSshEnvironment(&d->sftpProc);
d->files = files;
d->transferType = type;
d->errorHandlingMode = errorHandlingMode;
diff --git a/src/libs/ssh/sshconnection.cpp b/src/libs/ssh/sshconnection.cpp
index 7d2d0d8f5c0..145a2f60bcd 100644
--- a/src/libs/ssh/sshconnection.cpp
+++ b/src/libs/ssh/sshconnection.cpp
@@ -104,6 +104,26 @@ QStringList SshConnectionParameters::connectionOptions(const FilePath &binary) c
return args;
}
+bool SshConnectionParameters::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;
+}
+
+
static inline bool equals(const SshConnectionParameters &p1, const SshConnectionParameters &p2)
{
return p1.url == p2.url
@@ -129,7 +149,7 @@ struct SshConnection::SshConnectionPrivate
SshConnectionPrivate(const SshConnectionParameters &sshParameters)
: connParams(sshParameters)
{
- SshRemoteProcess::setupSshEnvironment(&masterProcess);
+ SshConnectionParameters::setupSshEnvironment(&masterProcess);
}
QString fullProcessError()
diff --git a/src/libs/ssh/sshconnection.h b/src/libs/ssh/sshconnection.h
index 2e8a707c8fc..b2d2abc27ad 100644
--- a/src/libs/ssh/sshconnection.h
+++ b/src/libs/ssh/sshconnection.h
@@ -38,6 +38,8 @@
#include <memory>
+namespace Utils { class QtcProcess; }
+
namespace QSsh {
class SshRemoteProcess;
@@ -73,6 +75,8 @@ public:
int timeout = 0; // In seconds.
AuthenticationType authenticationType = AuthenticationTypeAll;
SshHostKeyCheckingMode hostKeyCheckingMode = SshHostKeyCheckingAllowNoMatch;
+
+ static bool setupSshEnvironment(Utils::QtcProcess *process);
};
QSSH_EXPORT bool operator==(const SshConnectionParameters &p1, const SshConnectionParameters &p2);
diff --git a/src/libs/ssh/sshremoteprocess.cpp b/src/libs/ssh/sshremoteprocess.cpp
index 7c4b089fd82..f0b52d5ff27 100644
--- a/src/libs/ssh/sshremoteprocess.cpp
+++ b/src/libs/ssh/sshremoteprocess.cpp
@@ -25,6 +25,7 @@
#include "sshremoteprocess.h"
+#include "sshconnection.h"
#include "sshlogging_p.h"
#include "sshsettings.h"
@@ -54,7 +55,7 @@ namespace QSsh {
SshRemoteProcess::SshRemoteProcess(const QString &command, const QStringList &connectionArgs)
: QtcProcess()
{
- setupSshEnvironment(this);
+ SshConnectionParameters::setupSshEnvironment(this);
m_remoteCommand = command;
m_connectionArgs = connectionArgs;
}
@@ -112,23 +113,4 @@ 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 9c011bfa64e..cfd6427c732 100644
--- a/src/libs/ssh/sshremoteprocess.h
+++ b/src/libs/ssh/sshremoteprocess.h
@@ -46,8 +46,6 @@ public:
Utils::CommandLine fullLocalCommandLine(bool inTerminal = false) const;
- static bool setupSshEnvironment(Utils::QtcProcess *process);
-
protected:
void emitFinished() override;