[Libssh] Anticipating ssh messages
Matt Lawson
lawson08 at yahoo.com
Fri Apr 25 18:49:21 CEST 2008
Hi,
I'm having a little trouble anticipating which
"messages" to expect when acting as the server, and
finding a combination that works with all clients
(both a libssh client as well as a regular openssh
command line)
Specifically, I get problems over the last 2 things
the client tries to do during the connection process,
the pty request and the shell request. If I remove
these last 2 steps I can get everyone working
together, but I shouldn't have to take those steps
out.
I (as the server) need to know how to "safely" check
to see if there are additional messages to be read or
not.
On one hand, I might read too many messages, example:
If I (as the server) call ssh_message_get(session) and
the client was NOT sending any kind of message, then I
get the expected NULL, but it also sends an "unhandled
packet type 0" back to the client, which will crash an
openssh client.
On the other hand, I might stop reading messages too
soon, example:
During the connection phase, as the server, Instead of
waiting until ssh_message_get() returns NULL, I might
stop looking for messsages as soon as the channel has
established. This works with the openssh client,
however, if the libssh client then goes on to do
channel_request_pty() and/or channel_request_shell()
it will block because the server is not tryiing to
read any more messages.
To summarize:
1. Do the messages only come at the beginning, or can
they be interleaved at any time?
2. As the server, how can I accomodate different
clients when I don't know exactly how many, which, or
in what order the messages might come?
Thanks.
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
More information about the Libssh
mailing list