Commit 0785617e authored by Niels Möller's avatar Niels Möller
Browse files

* src/lshd.c: Use the "hook"-mechanism to install handlers on the

connection.

Rev: src/lshd.c:1.54
parent 6d2ded9a
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "alist.h" #include "alist.h"
#include "atoms.h" #include "atoms.h"
#include "channel.h" #include "channel.h"
#include "channel_commands.h"
#include "charset.h" #include "charset.h"
#include "connection_commands.h" #include "connection_commands.h"
#include "crypto.h" #include "crypto.h"
...@@ -41,12 +42,14 @@ ...@@ -41,12 +42,14 @@
#include "server_keyexchange.h" #include "server_keyexchange.h"
#include "sexp.h" #include "sexp.h"
#include "ssh.h" #include "ssh.h"
#include "tcpforward_commands.h"
#include "userauth.h" #include "userauth.h"
#include "werror.h" #include "werror.h"
#include "xalloc.h" #include "xalloc.h"
#include "compress.h" #include "compress.h"
#include "server_pty.h" #include "server_pty.h"
#include "tcpforward.h" #include "tcpforward.h"
#include "tcpforward_commands.h"
#include "getopt.h" #include "getopt.h"
...@@ -240,28 +243,42 @@ static int read_host_key(const char *name, ...@@ -240,28 +243,42 @@ static int read_host_key(const char *name,
} }
} }
/* GABA:
(expr
(name lshd_listen)
(globals
(log "&io_log_peer_command.super.super"))
(params
(listen object command)
(handshake object command)
(services object command) )
(expr (lambda (port)
(services (handshake (log (listen port)))))))
*/
/* Invoked when the client requests the userauth service. */ /* Invoked when the client requests the userauth service. */
/* GABA: /* GABA:
(expr (expr
(name lshd_services) (name lshd_services)
(params (params
(userauth object command) ) (userauth object command))
(expr (expr
(lambda (connection) (lambda (connection)
((userauth connection) connection)))) ((userauth connection) connection))))
*/ */
/* Invoked when starting the ssh-connection service */
/* GABA: /* GABA:
(expr (expr
(name lshd_listen) (name lshd_connection_service)
(globals (globals
(log "&io_log_peer_command.super.super")) (progn "&progn_command.super.super"))
(params (params
(listen object command) (login object command)
(handshake object command) (hooks object object_list))
(services object command) ) (expr
(expr (lambda (port) (lambda (user connection)
(services (handshake (log (listen port))))))) ((progn hooks) (login user connection)))))
*/ */
int main(int argc, char **argv) int main(int argc, char **argv)
...@@ -449,17 +466,21 @@ int main(int argc, char **argv) ...@@ -449,17 +466,21 @@ int main(int argc, char **argv)
make_int_list(0, -1)); make_int_list(0, -1));
{ {
struct alist *global_requests; /* Commands to be invoked on the connection */
struct object_list *connection_hooks;
#if WITH_TCP_FORWARD #if WITH_TCP_FORWARD
if (forward_flag) if (forward_flag)
global_requests = make_alist(2, connection_hooks = make_object_list
ATOM_TCPIP_FORWARD, make_tcpip_forward_request(backend), (3,
ATOM_CANCEL_TCPIP_FORWARD, make_cancel_tcpip_forward_request(), tcpip_forward_hook(backend),
-1); make_install_fix_global_request_handler
(ATOM_CANCEL_TCPIP_FORWARD, &tcpip_cancel_forward),
make_direct_tcpip_hook(backend),
-1);
else else
#endif #endif
global_requests = make_alist(0, -1); connection_hooks = make_object_list(0, -1);
{ {
struct lsh_object *o = lshd_listen struct lsh_object *o = lshd_listen
(make_simple_listen(backend, NULL), (make_simple_listen(backend, NULL),
...@@ -481,18 +502,19 @@ int main(int argc, char **argv) ...@@ -481,18 +502,19 @@ int main(int argc, char **argv)
make_alist(1, ATOM_PASSWORD, make_alist(1, ATOM_PASSWORD,
&unix_userauth.super, -1), &unix_userauth.super, -1),
make_alist(1, ATOM_SSH_CONNECTION, make_alist(1, ATOM_SSH_CONNECTION,
make_server_connection_service lshd_connection_service
(global_requests, (make_server_connection_service
make_alist (make_alist
(1 (1
#if WITH_PTY_SUPPORT #if WITH_PTY_SUPPORT
+1, ATOM_PTY_REQ, make_pty_handler() +1, ATOM_PTY_REQ, make_pty_handler()
#endif /* WITH_PTY_SUPPORT */ #endif /* WITH_PTY_SUPPORT */
, ATOM_SHELL, , ATOM_SHELL,
make_shell_handler(backend, make_shell_handler(backend,
reaper), reaper),
-1), -1),
backend), backend),
connection_hooks),
-1))), -1))),
-1))); -1)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment