auth.c: Add termination when server disconnects during authentication

When the server is reaches MaxAuthTries it sends disconnect immediately
which was not correctly handled in the libssh client and hanged.
Solves #11

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Norbert Pocs
2023-05-25 15:27:00 +02:00
parent f7a9c07de3
commit 6424971a98

View File

@@ -78,6 +78,8 @@ SSH_PACKET_CALLBACK(ssh_packet_disconnect_callback){
ssh_socket_close(session->socket);
session->alive = 0;
session->session_state = SSH_SESSION_STATE_ERROR;
/* correctly handle disconnect during authorization */
session->auth.state = SSH_AUTH_STATE_FAILED;
/* TODO: handle a graceful disconnect */
return SSH_PACKET_USED;
}