Browse Source

Issue 2335 – Tunneled session password is not remembered

https://winscp.net/tracker/2335

Source commit: ce6d0598ef31e1871eaecd8d67c9b0f6a81b7d39
Martin Prikryl 11 months ago
parent
commit
ff0a744b58
2 changed files with 5 additions and 2 deletions
  1. 4 2
      source/core/Terminal.cpp
  2. 1 0
      source/core/Terminal.h

+ 4 - 2
source/core/Terminal.cpp

@@ -1208,6 +1208,8 @@ __fastcall TTerminal::TTerminal(TSessionData * SessionData, TConfiguration * Con
   FConfiguration = Configuration;
   FConfiguration = Configuration;
   FSessionData = new TSessionData(L"");
   FSessionData = new TSessionData(L"");
   FSessionData->Assign(SessionData);
   FSessionData->Assign(SessionData);
+  // Cache it, in case it changes (particularly by ConfigureTunnel)
+  FPasswordEncryptionKey = SessionData->GetSessionPasswordEncryptionKey();
   TDateTime Started = Now(); // use the same time for session and XML log
   TDateTime Started = Now(); // use the same time for session and XML log
   FLog = new TSessionLog(this, Started, FSessionData, Configuration);
   FLog = new TSessionLog(this, Started, FSessionData, Configuration);
   if (ActionLog != NULL)
   if (ActionLog != NULL)
@@ -1345,7 +1347,7 @@ void __fastcall TTerminal::Idle()
 //---------------------------------------------------------------------
 //---------------------------------------------------------------------
 RawByteString __fastcall TTerminal::EncryptPassword(const UnicodeString & Password)
 RawByteString __fastcall TTerminal::EncryptPassword(const UnicodeString & Password)
 {
 {
-  return Configuration->EncryptPassword(Password, SessionData->GetSessionPasswordEncryptionKey());
+  return Configuration->EncryptPassword(Password, FPasswordEncryptionKey);
 }
 }
 //---------------------------------------------------------------------
 //---------------------------------------------------------------------
 UnicodeString __fastcall TTerminal::DecryptPassword(const RawByteString & Password)
 UnicodeString __fastcall TTerminal::DecryptPassword(const RawByteString & Password)
@@ -1353,7 +1355,7 @@ UnicodeString __fastcall TTerminal::DecryptPassword(const RawByteString & Passwo
   UnicodeString Result;
   UnicodeString Result;
   try
   try
   {
   {
-    Result = Configuration->DecryptPassword(Password, SessionData->GetSessionPasswordEncryptionKey());
+    Result = Configuration->DecryptPassword(Password, FPasswordEncryptionKey);
   }
   }
   catch(EAbort &)
   catch(EAbort &)
   {
   {

+ 1 - 0
source/core/Terminal.h

@@ -162,6 +162,7 @@ friend class TParallelOperation;
 
 
 private:
 private:
   TSessionData * FSessionData;
   TSessionData * FSessionData;
+  UnicodeString FPasswordEncryptionKey;
   TSessionLog * FLog;
   TSessionLog * FLog;
   TActionLog * FActionLog;
   TActionLog * FActionLog;
   bool FActionLogOwned;
   bool FActionLogOwned;