소스 검색

Cached host keys can be imported from PuTTY/FileZilla even when using INI file as configuration storage

Source commit: 0baede813ab5af5ffc34120b006aae70cbd9773b
Martin Prikryl 8 년 전
부모
커밋
bf9594fd11
3개의 변경된 파일9개의 추가작업 그리고 8개의 파일을 삭제
  1. 6 4
      source/core/SessionData.cpp
  2. 1 1
      source/core/SessionData.h
  3. 2 3
      source/forms/ImportSessions.cpp

+ 6 - 4
source/core/SessionData.cpp

@@ -4263,22 +4263,24 @@ void __fastcall TStoredSessionList::SetDefaultSettings(TSessionData * value)
   }
 }
 //---------------------------------------------------------------------------
-void __fastcall TStoredSessionList::ImportHostKeys(const UnicodeString TargetKey,
+void __fastcall TStoredSessionList::ImportHostKeys(
   const UnicodeString SourceKey, TStoredSessionList * Sessions,
   bool OnlySelected)
 {
+  bool SessionList = false;
   TRegistryStorage * SourceStorage = NULL;
-  TRegistryStorage * TargetStorage = NULL;
+  THierarchicalStorage * TargetStorage = Configuration->CreateScpStorage(SessionList);
   TStringList * KeyList = NULL;
   try
   {
     SourceStorage = new TRegistryStorage(SourceKey);
-    TargetStorage = new TRegistryStorage(TargetKey);
+    TargetStorage->Explicit = true;
     TargetStorage->AccessMode = smReadWrite;
     KeyList = new TStringList();
 
     if (SourceStorage->OpenRootKey(false) &&
-        TargetStorage->OpenRootKey(true))
+        TargetStorage->OpenRootKey(true) &&
+        TargetStorage->OpenSubKey(Configuration->SshHostKeysSubKey, true))
     {
       SourceStorage->GetValueNames(KeyList);
 

+ 1 - 1
source/core/SessionData.h

@@ -654,7 +654,7 @@ public:
   __property TSessionData * Sessions[int Index]  = { read=AtSession };
   __property TSessionData * DefaultSettings  = { read=FDefaultSettings, write=SetDefaultSettings };
 
-  static void __fastcall ImportHostKeys(const UnicodeString TargetKey,
+  static void __fastcall ImportHostKeys(
     const UnicodeString SourceKey, TStoredSessionList * Sessions,
     bool OnlySelected);
 

+ 2 - 3
source/forms/ImportSessions.cpp

@@ -50,13 +50,12 @@ bool __fastcall DoImportSessionsDialog(TList * Imported)
 
     if (ImportKeys)
     {
-      UnicodeString TargetKey = Configuration->RegistryStorageKey + L"\\" + Configuration->SshHostKeysSubKey;
       UnicodeString SourceKey = Configuration->PuttyRegistryStorageKey + L"\\" + Configuration->SshHostKeysSubKey;
 
-      TStoredSessionList::ImportHostKeys(TargetKey, SourceKey, PuttyImportSessionList.get(), true);
+      TStoredSessionList::ImportHostKeys(SourceKey, PuttyImportSessionList.get(), true);
 
       // Filezilla uses PuTTY's host key store
-      TStoredSessionList::ImportHostKeys(TargetKey, SourceKey, FilezillaImportSessionList.get(), true);
+      TStoredSessionList::ImportHostKeys(SourceKey, FilezillaImportSessionList.get(), true);
     }
   }
   return Result;