The tcp-forwarding features of the 0.1.2 snapshot didn't really work.
But after some more hacking, local forwarding (the -L options) finally
seems to work. I have managed to get lsh to forward an lsh connection
(lshd was about the only network server I had around ;-).

Remote forwarding, i.e. -R, doesn't quite work. And I think this bug is
somewhat interesting... It has to do with the unorthodox evaluation
order in the control language.

/* GABA:
   (expr
     (name forward_remote_port)
     (globals
       (remote_listen REMOTE_LISTEN)
       (connect_io TCPIP_CONNECT_IO))
     (params
       (connect object command)
       (remote object address_info))
     (expr
       (lambda (connection)
         (remote_listen (lambda (peer)
                          (connect_io ; peer
                                    ;; Here's the problem.
                                    (connect connection)))
                        remote
                        connection))))
*/

The compiler pushes arguments down into the function bodies. Each
subexpression is evaluated as soon as all it's arguments are
available. One might expect that the call of CONNECT above has to wait
until the value of PEER is available, i.e. until the function (lambda
(peer) ...) is invoked. But that is not the case... the function call
(connect connection) is performed as soon as the value of CONNECTION
is available.

And only _once_ for each call of (lambda (connection) ...), so the
_same_ connection will be used for all invocations of (lambda (peer)
...).

A fix is to make sure that the variable PEER is used somewhere inside
the (connect ...) subexpression, for instance by writing (connect (K
connection peer)). Remember that K is defined by (K x y) ==> x for all
y. Except that this use of K is optimized away by the compiler. Heh.

Before fixing this, I think I'd like to introduce an exception
mechanism. And another very important item on the todo list is the
known_hosts-database.

If anyone likes numbers, the tcpforwarding code, more precisely
tcpforward.c and tcpforward_commands.c, are currently about 1k lines
of code. Whatever that means.

As usual, you can get the snapshot at

  http://www.lysator.liu.se/~nisse/archive/lsh-0.1.3.tar.gz
  ftp://ftp.lysator.liu.se/pub/security/lsh/lsh-0.1.3.tar.gz

/Niels 
  • lsh-0.1.2 Niels M�ller
    • Niels M�ller

Reply via email to