Attached is a patch to libssh2_userauth_password() to handle a failed login 
(i.e. bad username and/or password).  When a failed login occurs, the server 
responds with SSH_MSG_USERAUTH_FAILURE which isn't handled in 
libssh2_userauth_password() and it ends up dropping out with -1, but the error 
code given is LIBSSH2_ERROR_EAGAIN, which isn't correct.

The patch adds an error code, LIBSSH2_ERROR_AUTHORIZATION_FAILED (which is 
actually an alias for LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED, returned in 
libssh2_userauth_publickey_fromfile() to maintain backward compatibility) which 
is returned in the case of SSH_MSG_USERAUTH_FAILURE (this is the same as the 
logic in libssh2_userauth_publickey_fromfile() that handles an unrecognized 
public key).

NOTE: The changes from the previous version of this patch, based on feedback 
from Peter are as follows:

        * Shortened the patch description to 72 chars
        * Supplied as a diff rather than a git update (avoids issues with 
squashed commits)
        * Rather than use a new error code, make 
LIBSSH2_ERROR_AUTHORIZATION_FAILED be -19, the same as 
LIBSSH2_ERROR_PUBLICKEY_UNVERIFIED (for place for backward compatibility).

Please let me know if there are any issues.

Many thanks!


Attachment: LIBSSH2_ERROR_AUTHORIZATION_FAILED.diff
Description: Binary data


_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to