Selaa lähdekoodia

Bug 1654: Pass private key to PuTTY when installed from Microsoft Store + Passing also other options that PuTTY can accept on its command-line, like "Attempt authentication using Pageant", "Allow agent forwarding", "Enable compression", "SSH protocol version", "Logical name of remote host" and "Internal protocol version"

Source commit: 7c3470f6848b2d87ddb70403135fc7b29efbd34e
Martin Prikryl 7 vuotta sitten
vanhempi
sitoutus
724f7488c6
1 muutettua tiedostoa jossa 35 lisäystä ja 2 poistoa
  1. 35 2
      source/windows/GUITools.cpp

+ 35 - 2
source/windows/GUITools.cpp

@@ -94,9 +94,10 @@ void __fastcall OpenSessionInPutty(const UnicodeString PuttyPath,
 
     if (!RemoteCustomCommand.IsSiteCommand(AParams))
     {
-      if (IsUWP())
+      if (true/*IsUWP()*/)
       {
-        if ((SessionData->FSProtocol == fsFTP) && GUIConfiguration->TelnetForFtpInPutty)
+        bool Telnet = (SessionData->FSProtocol == fsFTP) && GUIConfiguration->TelnetForFtpInPutty;
+        if (Telnet)
         {
           AddToList(PuttyParams, L"-telnet", L" ");
           // PuTTY  does not allow -pw for telnet
@@ -111,6 +112,38 @@ void __fastcall OpenSessionInPutty(const UnicodeString PuttyPath,
         {
           AddToList(PuttyParams, FORMAT(L"-P %d", (SessionData->PortNumber)), L" ");
         }
+
+        if (!Telnet)
+        {
+          if (!SessionData->PublicKeyFile.IsEmpty())
+          {
+            AddToList(PuttyParams, FORMAT(L"-i \"%s\"", (SessionData->PublicKeyFile)), L" ");
+          }
+          AddToList(PuttyParams, (SessionData->TryAgent ? L"-agent" : L"-noagent"), L" ");
+          if (SessionData->TryAgent)
+          {
+            AddToList(PuttyParams, (SessionData->AgentFwd ? L"-A" : L"-a"), L" ");
+          }
+          if (SessionData->Compression)
+          {
+            AddToList(PuttyParams, L"-C", L" ");
+          }
+          AddToList(PuttyParams,
+            ((SessionData->SshProt == ssh1only || SessionData->SshProt == ssh1deprecated) ? L"-1" : L"-2"), L" ");
+          if (!SessionData->LogicalHostName.IsEmpty())
+          {
+            AddToList(PuttyParams, FORMAT(L"-loghost \"%s\"", (SessionData->LogicalHostName)), L" ");
+          }
+        }
+
+        if (SessionData->AddressFamily == afIPv4)
+        {
+          AddToList(PuttyParams, L"-4", L" ");
+        }
+        else if (SessionData->AddressFamily == afIPv6)
+        {
+          AddToList(PuttyParams, L"-6", L" ");
+        }
       }
       else
       {