Wait... looks like I fixed it. The problem was with line 2660 of a patched channels.c: if we comment host it works.
Code:
/*strcmp(c->path, host) == 0 &&*/
more details and complete fix a bit later.
I can't really guarantee this is going to work without memory leaks: I am not sure it really frees everything but it's made as in same rport function.
here is what it issues now(running
./ssh -vvv root@fs, port 80 on fs is nginx webserver):
Code:
<debug output skipped>
root@fs:~#
ssh> -L10222:127.0.0.1:80
debug3: channel_setup_fwd_listener: type 2 wildcard 0 addr NULL
debug1: Local forwarding listening on 127.0.0.1 port 10222.
debug2: fd 7 setting O_NONBLOCK
debug3: fd 7 is O_NONBLOCK
debug1: channel 1: new [port listener]
socket: Address family not supported by protocol
Forwarding port.
debug3: Wrote 48 bytes for a total of 2917
Testing forwarding to nginx with nc and simple request, manually entered:
Code:
afkhaxor@srvr:~$ nc 127.0.0.1 10222
GET / HTTP/1.0
Host: fs
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 03 Feb 2010 10:42:51 GMT
Content-Type: text/html; charset=utf-8
Connection: close
<html>
<head><title>Index of /</title></head>
<body bgcolor="white">
<h1>Index of /</h1><hr><pre><a href="../">../</a>
<a href="test.py">test.py</a> 10-Oct-2009 13:41 2866
</pre><hr></body>
</html>
Dropping port 10222 forward:
Code:
<debug output from forwarding skipped>
root@fs:~#
ssh> -KL10222
debug3: Attempting to remove local forwarding...
debug3: Total channels: 10
debug2: channel_cancel_lport_listener: close channel 1
debug1: channel 1: free: port listener, nchannels 2
debug3: channel 1: status: The following connections are open:
#0 client-session (t4 r0 i0/0 o0/0 fd 4/5 cfd -1)
debug3: channel 1: close_fds r 7 w 7 e -1 c -1
And ensuring port is gone:
Code:
afkhaxor@srvr:~$ nc 127.0.0.1 10222
(UNKNOWN) [127.0.0.1] 10222 (?) : Connection refused
Port is not listened anymore. I can also request yet another forwarding on the same port after I cancelled it again and it works.
No segfaults now.
I'll post full patches a bit later here and in
original question when I will finally get that to work.
--upd:
It also works well with cancellation of forwarding 10222 to 127.0.0.1:80 and reforwarding it then to 192.0.32.10:80 (example.org IP) and correctly addresses traffic to example.org after it.