Dave McCaldon
2009-10-20 01:40:47 UTC
I've noticed that there doesn't seem to be an error code for "login
failed", in fact if I intentionally pass an incorrect username or
password to libssh2_userauth_password(), it seems to always fail with
-37 (LIBSSH2_ERROR_EAGAIN), calling libssh2_session_last_error() gives
me the following error text:
$1 = 0x1015bc8f8 "Would block exchanging encryption keys"
I've tried both setting non-blocking at the socket level and also via
libssh2_session_set_blocking() (which I assume does the same thing),
but it doesn't seem to do anything. I wonder if the
LIBSSH2_ERROR_EAGAIN is actually a red herring here.
So I looked in userauth.c and there seems to be a bunch of logic that
goes through handling changing a password etc. but I just don't see a
case where it checks for the reply code SSH_MSG_USERAUTH_FAILURE --
I'd expect it to map that into a "LIBSSH2_ERROR_LOGINFAILED" (or
similar error). I think it's just falling out of the bottom of
userauth_password(), with whatever previous error (usually
LIBSSH2_ERROR_EAGAIN) left over in it's error state.
Also in userauth.c, for libssh2_userauth_publickey_fromfile() there is
a case in the userauth_publickey_fromfile() logic that maps
SSH_MSG_USERAUTH_FAILURE to LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED.
Have I just missed something here? Or is the SSH_MSG_USERAUTH_FAILURE
case not handled for libssh2_userauth_password() as it seems.
BTW: I'm looking at libssh2-1.2.
Thanks!
failed", in fact if I intentionally pass an incorrect username or
password to libssh2_userauth_password(), it seems to always fail with
-37 (LIBSSH2_ERROR_EAGAIN), calling libssh2_session_last_error() gives
me the following error text:
$1 = 0x1015bc8f8 "Would block exchanging encryption keys"
I've tried both setting non-blocking at the socket level and also via
libssh2_session_set_blocking() (which I assume does the same thing),
but it doesn't seem to do anything. I wonder if the
LIBSSH2_ERROR_EAGAIN is actually a red herring here.
So I looked in userauth.c and there seems to be a bunch of logic that
goes through handling changing a password etc. but I just don't see a
case where it checks for the reply code SSH_MSG_USERAUTH_FAILURE --
I'd expect it to map that into a "LIBSSH2_ERROR_LOGINFAILED" (or
similar error). I think it's just falling out of the bottom of
userauth_password(), with whatever previous error (usually
LIBSSH2_ERROR_EAGAIN) left over in it's error state.
Also in userauth.c, for libssh2_userauth_publickey_fromfile() there is
a case in the userauth_publickey_fromfile() logic that maps
SSH_MSG_USERAUTH_FAILURE to LIBSSH2_ERROR_PUBLICKEY_UNRECOGNIZED.
Have I just missed something here? Or is the SSH_MSG_USERAUTH_FAILURE
case not handled for libssh2_userauth_password() as it seems.
BTW: I'm looking at libssh2-1.2.
Thanks!