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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user