From 673120c953805e93cdf1e0d8b10492d482773493 Mon Sep 17 00:00:00 2001
From: Ulrich Sibiller <uli42@gmx.de>
Date: Fri, 17 May 2019 22:28:19 +0200
Subject: [PATCH 1/2] Skip checkLogin() if hostname starts with "!"

Some special ssh proxies will not allow arbitrary
commands. checkLogin() will break these sessions because it tries to
run the echo command on the proxy.

By specifying a "!" as the first character of the (proxy) hostname you
can instruct x2goclient ot skip the checkLogin() call altogether. Note
that this will break proxies that require you to cjhange you password
or some other type of interaction.

As this is added to SshMasterConnection it is also valid to specify
that for the server hostname although this is not very useful.
---
 src/sshmasterconnection.cpp | 17 +++++++++++++++++
 src/sshmasterconnection.h   |  1 +
 2 files changed, 18 insertions(+)

diff --git a/src/sshmasterconnection.cpp b/src/sshmasterconnection.cpp
index 6a1bc86..141de4c 100644
--- a/src/sshmasterconnection.cpp
+++ b/src/sshmasterconnection.cpp
@@ -169,6 +169,16 @@ SshMasterConnection::SshMasterConnection (QObject* parent, QString host, int por
               << "; useproxy " << useproxy << "; proxyserver " << proxyserver
               << "; proxyport " << proxyport;
     this->host=host;
+    // If the hostname starts with "!" do not perform loginCheck() for this connection
+    if (this->host.indexOf("!") == 0)
+    {
+        this->loginCheck=false;
+        this->host.remove(0, 1);
+    }
+    else
+    {
+        this->loginCheck=true;
+    }
     this->port=port;
     this->user=user;
     this->pass=pass;
@@ -670,7 +680,14 @@ void SshMasterConnection::run()
         x2goDebug<<"User authentication OK.";
         // checkLogin() is currently specific to libssh.
         if(kerberos)
+        {
             emit connectionOk(host);
+        }
+        else if(this->loginCheck == false)
+        {
+            x2goDebug<<"Skipping Login Check as requested by configuration";
+            emit connectionOk(host);
+        }
         else
         {
             if(checkLogin())
diff --git a/src/sshmasterconnection.h b/src/sshmasterconnection.h
index 69bfa0d..ec66619 100644
--- a/src/sshmasterconnection.h
+++ b/src/sshmasterconnection.h
@@ -213,6 +213,7 @@ private:
     SshMasterConnection* sshProxy;
     bool sshProxyReady;
     bool breakLoop;
+    bool loginCheck;
 
     bool challengeAuthPasswordAccepted;
     QString challengeAuthVerificationCode;
-- 
2.11.0

