mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
FIX: FTP - Show error when authentication failed
ADD: FTP - Show error when only one key configured
This commit is contained in:
parent
3dc144d2e2
commit
c6c812fa85
3 changed files with 29 additions and 4 deletions
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Wfx plugin for working with File Transfer Protocol
|
||||
|
||||
Copyright (C) 2009-2018 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2009-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -449,6 +449,17 @@ begin
|
|||
Data:= SendDlgMsg(pDlg, 'fnePrivateKey', DM_GETTEXT, 0, 0);
|
||||
gConnection.PrivateKey:= PAnsiChar(Data);
|
||||
|
||||
if gConnection.OpenSSH then
|
||||
begin
|
||||
if (Length(gConnection.PublicKey) > 0) and (Length(gConnection.PrivateKey) = 0) or
|
||||
(Length(gConnection.PublicKey) = 0) and (Length(gConnection.PrivateKey) > 0) then
|
||||
begin
|
||||
gStartupInfo.MessageBox('You must enter the location of the public/private key pair!',
|
||||
nil, MB_OK or MB_ICONERROR);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
if gConnection.FullSSL and (InitSSLInterface = False) then
|
||||
begin;
|
||||
ShowWarningSSL;
|
||||
|
|
|
|||
|
|
@ -221,6 +221,7 @@ var
|
|||
libssh2_session_last_error: function(session: PLIBSSH2_SESSION; errmsg: PPAnsiChar;
|
||||
errmsg_len: pcint; want_buf: cint): cint; cdecl;
|
||||
//* Userauth API */
|
||||
libssh2_userauth_authenticated: function(session: PLIBSSH2_SESSION): cint; cdecl;
|
||||
libssh2_userauth_list: function(session: PLIBSSH2_SESSION;
|
||||
const username: PAnsiChar; username_len: cuint): PAnsiChar; cdecl;
|
||||
libssh2_userauth_password_ex: function(session: PLIBSSH2_SESSION;
|
||||
|
|
@ -540,6 +541,7 @@ begin
|
|||
//* Userauth API */
|
||||
libssh2_userauth_list:= SafeGetProcAddress(libssh2, 'libssh2_userauth_list');
|
||||
libssh2_userauth_password_ex:= SafeGetProcAddress(libssh2, 'libssh2_userauth_password_ex');
|
||||
libssh2_userauth_authenticated:= SafeGetProcAddress(libssh2, 'libssh2_userauth_authenticated');
|
||||
libssh2_userauth_keyboard_interactive_ex:= SafeGetProcAddress(libssh2, 'libssh2_userauth_keyboard_interactive_ex');
|
||||
libssh2_userauth_publickey_fromfile_ex:= SafeGetProcAddress(libssh2, 'libssh2_userauth_publickey_fromfile_ex');
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Wfx plugin for working with File Transfer Protocol
|
||||
|
||||
Copyright (C) 2013-2022 Alexander Koblov (alexx2000@mail.ru)
|
||||
Copyright (C) 2013-2023 Alexander Koblov (alexx2000@mail.ru)
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
|
|
@ -421,9 +421,15 @@ begin
|
|||
//* check what authentication methods are available */
|
||||
userauthlist := libssh2_userauth_list(FSession, PAnsiChar(FUserName), Length(FUserName));
|
||||
|
||||
if (strpos(userauthlist, 'publickey') <> nil) and (FPublicKey <> '') and (FPrivateKey <> '') then
|
||||
DoStatus(False, 'Authentication methods: ' + userauthlist);
|
||||
|
||||
if (libssh2_userauth_authenticated(FSession) <> 0) then
|
||||
begin
|
||||
DoStatus(False, 'Auth via public key for user: ' + FUserName);
|
||||
DoStatus(False, 'Username authentication');
|
||||
end
|
||||
else if (strpos(userauthlist, 'publickey') <> nil) and (FPublicKey <> '') and (FPrivateKey <> '') then
|
||||
begin
|
||||
DoStatus(False, 'Public key authentication');
|
||||
if not AuthKey then begin
|
||||
LogProc(PluginNumber, msgtype_importanterror, 'Authentication by publickey failed');
|
||||
Exit(False);
|
||||
|
|
@ -431,6 +437,7 @@ begin
|
|||
end
|
||||
else if (strpos(userauthlist, 'password') <> nil) then
|
||||
begin
|
||||
DoStatus(False, 'Password authentication');
|
||||
I:= libssh2_userauth_password(FSession, PAnsiChar(FUserName), PAnsiChar(FPassword));
|
||||
if I <> 0 then begin
|
||||
LogProc(PluginNumber, msgtype_importanterror, 'Authentication by password failed');
|
||||
|
|
@ -441,12 +448,17 @@ begin
|
|||
begin
|
||||
FSavedPassword:= False;
|
||||
libssh2_session_set_timeout(FSession, 0);
|
||||
DoStatus(False, 'Keyboard interactive authentication');
|
||||
I:= libssh2_userauth_keyboard_interactive(FSession, PAnsiChar(FUserName), @userauth_kbdint);
|
||||
if I <> 0 then begin
|
||||
LogProc(PluginNumber, msgtype_importanterror, 'Authentication by keyboard-interactive failed');
|
||||
Exit(False);
|
||||
end;
|
||||
libssh2_session_set_timeout(FSession, FTimeout);
|
||||
end
|
||||
else begin
|
||||
LogProc(PluginNumber, msgtype_importanterror, 'Authentication failed');
|
||||
Exit(False);
|
||||
end;
|
||||
|
||||
DoStatus(False, 'Authentication succeeded');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue