www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples

Archive Index This month's Index

Subject: Re: [libssh2] #162: libssh2_userauth_password() returns undocument value

Re: [libssh2] #162: libssh2_userauth_password() returns undocument value

From: Dave McCaldon <davem_at_intersystems.com>
Date: Wed, 24 Feb 2010 10:35:36 -0500

On Feb 23, 2010, at 10:02 PM, libssh2 Trac wrote:

> #162: libssh2_userauth_password() returns undocument value
> ------------------------------------------------------------------------------------------------+
> Reporter: www.google.com/accounts/o8/id?id=AItOawmzs-3wPv9jSuaL5w4D_yhF_mGYz_Zks6c | Owner:
> Type: defect | Status: new
> Priority: normal | Milestone:
> Component: API | Version: 1.2.4
> Keywords: libssh2_userauth_password, libssh2_userauth_password_ex, LIBSSH2_ERROR_SOCKET_NONE | Blocking:
> Blockedby: |
> ------------------------------------------------------------------------------------------------+
> I think this is a bug.
>
> when I run the code below (the variable `password' is a wrong password and
> `username' is not empty), it outputs "1 - Authentication by password
> failed, rc = -1." this means libssh2_userauth_password() returns
> LIBSSH2_ERROR_SOCKET_NONE when authentication failed. But,
> LIBSSH2_ERROR_SOCKET_NONE is undocument on page
> http://www.libssh2.org/libssh2_userauth_password_ex.html ( there is
> another error on "Return Value" section on this page ):

Looking at userauth.c, all of the functions use libssh2_error() to store the error, but in fact return -1 on error. The docs for libssh2_userauth_password_ex() are actually not that clear about what it should return. It says:

"Return 0 on success or negative on failure. It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se."

And then lists possible error codes -- this implies that it returns these error codes, but in fact it'll only ever return -1 or LIBSSH2_ERROR_EAGAIN.

So the question is, is this a documentation issue, or should these functions really be returning the error code -- as is being discussed in the libssh2_error() thread that's going on right now.

Thanks.

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-02-24

the libssh2 team