Browse Source

Bug 1434: GSSAPI authentication is not working in tunneled session

https://winscp.net/tracker/1434

Source commit: 11820c70e579899641a40df4e78ed1cb6a74a952
Martin Prikryl 9 years ago
parent
commit
cedf1e73d3
4 changed files with 19 additions and 0 deletions
  1. 3 0
      source/core/SecureShell.cpp
  2. 2 0
      source/core/SessionData.cpp
  3. 2 0
      source/core/SessionData.h
  4. 12 0
      source/putty/ssh.c

+ 3 - 0
source/core/SecureShell.cpp

@@ -353,6 +353,8 @@ Conf * __fastcall TSecureShell::StoreToConfig(TSessionData * Data, bool Simple)
   conf_set_int_int(conf, CONF_ssh_hklist, 4, HK_WARN);
   DebugAssert(HK_MAX == 5);
 
+  conf_set_str(conf, CONF_loghost, AnsiString(Data->LogicalHostName).c_str());
+
   return conf;
 }
 //---------------------------------------------------------------------------
@@ -2104,6 +2106,7 @@ void __fastcall TSecureShell::GetRealHost(UnicodeString & Host, int & Port)
 {
   if (FSessionData->Tunnel)
   {
+    // Not that we set the CONF_loghost, the hostname is correct already
     Host = FSessionData->OrigHostName;
     Port = FSessionData->OrigPortNumber;
   }

+ 2 - 0
source/core/SessionData.cpp

@@ -1808,6 +1808,7 @@ void __fastcall TSessionData::ConfigureTunnel(int APortNumber)
   PortNumber = APortNumber;
   // proxy settings is used for tunnel
   ProxyMethod = ::pmNone;
+  FLogicalHostName = FOrigHostName;
 }
 //---------------------------------------------------------------------
 void __fastcall TSessionData::RollbackTunnel()
@@ -1815,6 +1816,7 @@ void __fastcall TSessionData::RollbackTunnel()
   HostName = FOrigHostName;
   PortNumber = FOrigPortNumber;
   ProxyMethod = FOrigProxyMethod;
+  FLogicalHostName = L"";
 }
 //---------------------------------------------------------------------
 void __fastcall TSessionData::ExpandEnvironmentVariables()

+ 2 - 0
source/core/SessionData.h

@@ -205,6 +205,7 @@ private:
   TProxyMethod FOrigProxyMethod;
   TSessionSource FSource;
   bool FSaveOnly;
+  UnicodeString FLogicalHostName;
 
   void __fastcall SetHostName(UnicodeString value);
   UnicodeString __fastcall GetHostNameExpanded();
@@ -580,6 +581,7 @@ public:
   __property UnicodeString StorageKey = { read = GetStorageKey };
   __property UnicodeString SiteKey = { read = GetSiteKey };
   __property UnicodeString OrigHostName = { read = FOrigHostName };
+  __property UnicodeString LogicalHostName = { read = FLogicalHostName };
   __property int OrigPortNumber = { read = FOrigPortNumber };
   __property UnicodeString LocalName = { read = GetLocalName };
   __property UnicodeString FolderName = { read = GetFolderName };

+ 12 - 0
source/putty/ssh.c

@@ -10000,6 +10000,10 @@ static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
 		int micoffset, len;
 		char *data;
 		Ssh_gss_buf mic;
+#ifdef MPEXT
+		const char * fullhostname;
+		char *loghost;
+#endif
 		s->type = AUTH_TYPE_GSSAPI;
 		s->tried_gssapi = TRUE;
 		s->gotit = TRUE;
@@ -10079,6 +10083,14 @@ static void do_ssh2_authconn(Ssh ssh, const unsigned char *in, int inlen,
 		}
 
 		/* now start running */
+#ifdef MPEXT
+		fullhostname = ssh->fullhostname;
+		loghost = conf_get_str(ssh->conf, CONF_loghost);
+		if (loghost[0] != '\0')
+		{
+		  fullhostname = loghost;
+		}
+#endif
 		s->gss_stat = s->gsslib->import_name(s->gsslib,
 						     ssh->fullhostname,
 						     &s->gss_srv_name);