Răsfoiți Sursa

Using !P pattern in PuTTY command implies that password should be remembered

Source commit: b2937603ef844987c71bbd5d13dca6c55ff13f2d
Martin Prikryl 9 ani în urmă
părinte
comite
40a8a89371
2 a modificat fișierele cu 25 adăugiri și 5 ștergeri
  1. 7 4
      source/forms/Preferences.cpp
  2. 18 1
      source/windows/GUIConfiguration.cpp

+ 7 - 4
source/forms/Preferences.cpp

@@ -1180,6 +1180,7 @@ void __fastcall TPreferencesDialog::UpdateControls()
     EnableControl(UpdatesProxyPortLabel, UpdatesProxyPortEdit->Enabled);
 
     bool IsSiteCommand = false;
+    bool IsPasswordCommand = false;
     try
     {
       TRemoteCustomCommand RemoteCustomCommand;
@@ -1187,17 +1188,19 @@ void __fastcall TPreferencesDialog::UpdateControls()
       UnicodeString PuttyPath = PuttyPathEdit->Text;
       PuttyPath = InteractiveCustomCommand.Complete(PuttyPath, false);
       IsSiteCommand = RemoteCustomCommand.IsSiteCommand(PuttyPath);
+      IsPasswordCommand = RemoteCustomCommand.IsPasswordCommand(PuttyPath);
     }
     catch (...)
     {
       // noop
     }
-    EnableControl(PuttyPasswordCheck2, !PuttyPathEdit->Text.IsEmpty());
-    EnableControl(AutoOpenInPuttyCheck, PuttyPasswordCheck2->Enabled);
+    bool AnyPuttyPath = !PuttyPathEdit->Text.IsEmpty();
+    EnableControl(PuttyPasswordCheck2, AnyPuttyPath && !IsPasswordCommand);
+    EnableControl(AutoOpenInPuttyCheck, AnyPuttyPath);
     EnableControl(TelnetForFtpInPuttyCheck,
-      PuttyPasswordCheck2->Enabled && !IsSiteCommand);
+      AnyPuttyPath && !IsSiteCommand);
     EnableControl(PuttyRegistryStorageKeyEdit,
-      PuttyPasswordCheck2->Enabled && !IsSiteCommand);
+      AnyPuttyPath && !IsSiteCommand);
     EnableControl(PuttyRegistryStorageKeyLabel, PuttyRegistryStorageKeyEdit->Enabled);
 
     EnableControl(SetMasterPasswordButton, WinConfiguration->UseMasterPassword);

+ 18 - 1
source/windows/GUIConfiguration.cpp

@@ -1107,7 +1107,24 @@ void __fastcall TGUIConfiguration::SetDefaultCopyParam(const TGUICopyParamType &
 //---------------------------------------------------------------------------
 bool __fastcall TGUIConfiguration::GetRememberPassword()
 {
-  return SessionRememberPassword || PuttyPassword;
+  bool Result = SessionRememberPassword || PuttyPassword;
+
+  if (!Result)
+  {
+    try
+    {
+      TRemoteCustomCommand RemoteCustomCommand;
+      TInteractiveCustomCommand InteractiveCustomCommand(&RemoteCustomCommand);
+      UnicodeString APuttyPath = InteractiveCustomCommand.Complete(PuttyPath, false);
+      Result = RemoteCustomCommand.IsPasswordCommand(PuttyPath);
+    }
+    catch (...)
+    {
+      // noop
+    }
+  }
+
+  return Result;
 }
 //---------------------------------------------------------------------------
 const TCopyParamList * __fastcall TGUIConfiguration::GetCopyParamList()