소스 검색

Bug 1688: Use remembered private key passphrase in generated script/code

https://winscp.net/tracker/1688
(cherry picked from commit 57b441bcb311d7804e1e6ccfa5a37ebfced36067)

# Conflicts:
#	source/forms/CustomScpExplorer.cpp
#	source/windows/TerminalManager.h

Source commit: a2a84396096105f7c242a40e1e257beabbbca52c
Martin Prikryl 7 년 전
부모
커밋
0ef010743e
5개의 변경된 파일14개의 추가작업 그리고 9개의 파일을 삭제
  1. 11 0
      source/core/Terminal.cpp
  2. 1 0
      source/core/Terminal.h
  3. 1 1
      source/forms/CustomScpExplorer.cpp
  4. 1 7
      source/windows/TerminalManager.cpp
  5. 0 1
      source/windows/TerminalManager.h

+ 11 - 0
source/core/Terminal.cpp

@@ -1071,6 +1071,7 @@ __fastcall TTerminal::TTerminal(TSessionData * SessionData,
   FTunnelOpening = false;
   FCallbackGuard = NULL;
   FNesting = 0;
+  FRememberedPasswordKind = TPromptKind(-1);
 }
 //---------------------------------------------------------------------------
 __fastcall TTerminal::~TTerminal()
@@ -4779,6 +4780,16 @@ void __fastcall TTerminal::FillSessionDataForCode(TSessionData * Data)
   }
 }
 //---------------------------------------------------------------------------
+void __fastcall TTerminal::UpdateSessionCredentials(TSessionData * Data)
+{
+  Data->UserName = UserName;
+  Data->Password = Password;
+  if (!FRememberedPassword.IsEmpty() && (FRememberedPasswordKind == pkPassphrase))
+  {
+    Data->Passphrase = GetRememberedPassword();
+  }
+}
+//---------------------------------------------------------------------------
 TTerminal * __fastcall TTerminal::GetCommandSession()
 {
   if ((FCommandSession != NULL) && !FCommandSession->Active)

+ 1 - 0
source/core/Terminal.h

@@ -558,6 +558,7 @@ public:
   bool __fastcall IsThisOrChild(TTerminal * Terminal);
   TTerminal * __fastcall CreateSecondarySession(const UnicodeString & Name, TSessionData * SessionData);
   void __fastcall FillSessionDataForCode(TSessionData * Data);
+  void __fastcall UpdateSessionCredentials(TSessionData * Data);
 
   const TSessionInfo & __fastcall GetSessionInfo();
   const TFileSystemInfo & __fastcall GetFileSystemInfo(bool Retrieve = false);

+ 1 - 1
source/forms/CustomScpExplorer.cpp

@@ -5374,7 +5374,7 @@ TSessionData * __fastcall TCustomScpExplorerForm::CloneCurrentSessionData()
   std::unique_ptr<TSessionData> SessionData(new TSessionData(L""));
   SessionData->Assign(Terminal->SessionData);
   UpdateSessionData(SessionData.get());
-  TTerminalManager::Instance()->UpdateSessionCredentials(SessionData.get());
+  Terminal->UpdateSessionCredentials(SessionData.get());
   if (Terminal->SessionData->IsWorkspace)
   {
     // Have to reset the "Workspace/XXX" name which would become user-visible

+ 1 - 7
source/windows/TerminalManager.cpp

@@ -1331,12 +1331,6 @@ bool __fastcall TTerminalManager::CanOpenInPutty()
   return (ActiveTerminal != NULL) && !GUIConfiguration->PuttyPath.Trim().IsEmpty();
 }
 //---------------------------------------------------------------------------
-void __fastcall TTerminalManager::UpdateSessionCredentials(TSessionData * Data)
-{
-  Data->UserName = ActiveTerminal->UserName;
-  Data->Password = ActiveTerminal->Password;
-}
-//---------------------------------------------------------------------------
 void __fastcall TTerminalManager::OpenInPutty()
 {
   Configuration->Usage->Inc(L"OpenInPutty");
@@ -1355,7 +1349,7 @@ void __fastcall TTerminalManager::OpenInPutty()
       Data = new TSessionData(L"");
       DebugAssert(ActiveTerminal != NULL);
       Data->Assign(ActiveTerminal->SessionData);
-      UpdateSessionCredentials(Data);
+      ActiveTerminal->UpdateSessionCredentials(Data);
     }
 
     // putty does not support resolving environment variables in session settings

+ 0 - 1
source/windows/TerminalManager.h

@@ -60,7 +60,6 @@ public:
   void __fastcall QueueStatusUpdated();
   TTerminal * __fastcall FindActiveTerminalForSite(TSessionData * Data);
   TTerminalQueue * __fastcall FindQueueForTerminal(TTerminal * Terminal);
-  void __fastcall UpdateSessionCredentials(TSessionData * Data);
   void __fastcall DoConnectTerminal(TTerminal * Terminal, bool Reopen);
 
   __property TCustomScpExplorerForm * ScpExplorer = { read = FScpExplorer, write = SetScpExplorer };