Archive Index
This month's Index
|
Subject: [ libssh2-Bugs-2788319 ] Problems with remote port forwarding
[ libssh2-Bugs-2788319 ] Problems with remote port forwarding
From: SourceForge.net <noreply_at_sourceforge.net>
Date: Tue, 12 May 2009 09:36:25 +0000
Bugs item #2788319, was opened at 2009-05-07 12:32
Please note that this message will contain a full copy of the comment thread,
Initial Comment:
ssh -nNT -R 5900:localhost:5900 user_at_host
This turned out to be a non-trivial task due to my little experience with libssh2 and sparse documentation. To explain my findings, let's call my end host A, and the remote end host B. I wish to connect from host A to host B, after which the ssh daemon in host B is to establish remote port forwarding back to host A.
I was successful, but it appears that there are some bugs in channel.c file, which I address in the attached patch file. The way I establish the remote port forwarding, 'tcpip-forward' channel is as follows:
(assume the connection and session are established and user authentication is successful)
listener = libssh2_channel_forward_listen(session, 5900);
1. as packet_queue_listener() in packet.c successfully allocates and queues the incoming connection from host B into a new channel, _libssh2_packet_add() in packet.c fails to add the incoming packets into the proper channel, as _libssh2_channel_locate() in channel.c fails to locate the previously allocate channel.
If I understand correctly, this is because _libssh2_channel_locate() tries to locate the channels only from the current session, whereas the channel it is looking for is in the queue of incoming connections.
I fixed this by changing _libssh2_packet_add() to iterate not only through the current session, but also through the queues contained in the listeners contained in the current session.
2. channel_forward_accept() in channel.c fails to break from the do-while loop because the condition to end the do-while loop is wrong. The condition (rc > 0) should read (rc < 0).
Please review my attached patch and if deemed correct, commit it into the tree.
Best regards,
Sami
----------------------------------------------------------------------
>Comment By: Daniel Stenberg (bagder)
Message:
I've just now committed what's basically your patch, just written slightly
Please update to latest CVS and see how your code runs now. I'll try to
----------------------------------------------------------------------
Comment By: SKujala (samikujala)
Message:
I have probably misunderstood something. Attached is the test code I use
sami$ ./ssh2_blocking
In the "remote end" I am just netcat'ing to port 6000, viz.
The libssh2 I use is snapshot version libssh2-1.1.1-20090507 with my patch
My operating system is macosx 10.4.11 on powerpc.
Libssh2 just won't break from the channel_forward_accept() loop.
Am I using the library wrong and if I am, I would appreciate any pointers
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Message:
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Message:
The PACKET_NONE is 0 and indicates that all is fine.
I figure the loop should then be (rc >= 0) so that it'll "drain" the
----------------------------------------------------------------------
Comment By: Neil Gierman (roadrunn)
Message:
----------------------------------------------------------------------
Comment By: SKujala (samikujala)
Message:
Sorry for the late reply.
According to the code documentation, _libssh2_transport_read() returns the
At least in my case I was not able to have channel_forward_accept() give
Now that I'm thinking about it more, maybe the condition to end the loop
Regards,
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Message:
Can you please tell me what that second part of the patch is supposed to
----------------------------------------------------------------------
You can respond by visiting:
------------------------------------------------------------------------------
|