Fix "password" authentication with retries and error dialogs

This commit is contained in:
Brendan Shanks 2019-08-05 00:10:48 -07:00
parent 3c2acd81c8
commit 8b4b98515a
1 changed files with 27 additions and 5 deletions

View File

@ -1573,13 +1573,35 @@ static Boolean ssh2_authentication_successful(LIBSSH2_SESSION *session, WindRec
return true; return true;
} }
if (strstr(userauthlist, "password") != NULL) { if (strstr(userauthlist, "password") != NULL) {
//SSH2LoginDialog(theScreen->sshdata.host, theScreen->sshdata.login, theScreen->sshdata.password); while (1) {
// TODO: add pwd change callback int result;
if (libssh2_userauth_password_ex(session, &(w->sshdata.login[1]), w->sshdata.login[0], &(w->sshdata.password[1]), w->sshdata.password[0], NULL) == 0) // TODO: add pwd change callback
return true; result = libssh2_userauth_password_ex(session, &(w->sshdata.login[1]), w->sshdata.login[0], &(w->sshdata.password[1]), w->sshdata.password[0], NULL);
// TODO: allow re-entering password on LIBSSH2_ERROR_AUTHENTICATION_FAILED switch (result) {
case 0:
syslog( 0, "password authentication succeeded\n" );
return true;
case LIBSSH2_ERROR_AUTHENTICATION_FAILED:
syslog( 0, "password authentication failed\n" );
// TODO: use dialog with "authentication failed" prompt
if (SSH2LoginDialog(w->sshdata.host, w->sshdata.login, w->sshdata.password) == true) {
continue;
} else {
syslog( 0, "password dialog cancelled\n" );
return false;
}
case LIBSSH2_ERROR_SOCKET_DISCONNECT:
syslog( 0, "remote host closed connection\n", result );
SSH2ErrorDialog("Authentication failed; remote host closed connection");
return false;
default:
syslog( 0, "libssh2_userauth_password_ex() returned %d, failing authentication\n", result );
return false;
}
}
} }
syslog( 0, "No supported authentication method found\n"); syslog( 0, "No supported authentication method found\n");
SSH2ErrorDialog("No supported authentication method found");
return false; return false;
} }