1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00

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

Source commit: 0baede813ab5af5ffc34120b006aae70cbd9773b
This commit is contained in:
Martin Prikryl
2017-06-12 16:26:18 +00:00
parent 62979354ad
commit bf9594fd11
3 changed files with 9 additions and 8 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;