Subject: [libssh2] userauth_keyboard_interactive problem

[libssh2] userauth_keyboard_interactive problem

From: Paul Thomas <thomaspu_at_gmail.com>
Date: Fri, 14 Dec 2007 23:51:47 -0500

Developers,

I've got a problem that I've been battling with for a few days now and
I just can not find a good way around it. Here's my scenario...

I'm wrapping up the libssh2 library into a c++ class for use in my
application. Now my program will primarily use keyboard interactive
authentication. So when I'm using the library, my class has to have a
static member function so that it can be passed into you library as a
function pointer. Unfortunately a non-static member function can not
be passed into the library. This is all and good for a single-threaded
c++ application, but the problem comes about when using multiple
threads.

For instance, let's say we have two threads that contain a C++ class
that have the libssh2 library wrapped up. Because of the C callback
function that's rquired, the C++ class must hold a static function
that has the password. Since static functions can only access static
data, the password must be stored in a static variable. Remember,
static variables only have one instance among multiple instances of
the same class. So those two threads will each change the static
password variable and if the first thread changes it, the 2nd thread
changes it and then the 1st thread tries to login, the 1st thread now
tries to login with the 2nd thread's password. So if I use C++ then
there's no way that I can use the libssh2 library with keyboard
interactive authentication with threads.

I hope that example was able to demonstrate what I'm running into.

So I have two questions:
1) How come the library forces its users to use a callback function?

>From my point of view, it severely limits the users ability of what
they can do in C++ because of having to use static member functions.

2) Is there any possibility that a future version of libssh2 will give
the ability to just do something as simple as:

libssh2_userauth_keyboard_interactive( session, username, password)

Then if someone like me is using C++, then we aren't stuck only using
static functions with keyboard interactive auth.

Ideas? Thoughts? Advice?
I could use it.

Paul Thomas

-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
libssh2-devel mailing list
libssh2-devel_at_lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Received on 2007-12-15