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

* src/channel.c, src/channel.h, src/client.c, src/client.h,

src/client_pty.c, src/client_pty.c, src/command.h,
src/connection.c, src/keyexchange.c, src/lsh.c, src/lshd.c,
src/queue.c, src/resource.c, src/server.h, src/server_password.c,
src/server_pty.h, src/server_session.c, src/service.c,
src/service.h, src/session.c, src/tcpforward.c,
src/write_buffer.c, src/zlib.c: Removed old #if:ed out code.

Rev: src/channel.c:1.37
Rev: src/channel.h:1.32
Rev: src/client.c:1.64
Rev: src/client.h:1.23
Rev: src/client_pty.c:1.7
Rev: src/client_pty.h:1.3
Rev: src/command.h:1.22
Rev: src/connection.c:1.32
Rev: src/keyexchange.c:1.49
Rev: src/lsh.c:1.53
Rev: src/lshd.c:1.48
Rev: src/queue.c:1.4
Rev: src/resource.c:1.9
Rev: src/server.h:1.18
Rev: src/server_password.c:1.19
Rev: src/server_pty.h:1.9
Rev: src/server_session.c:1.4
Rev: src/service.c:1.17
Rev: src/service.h:1.16
Rev: src/session.c:1.9
Rev: src/tcpforward.c:1.8
Rev: src/write_buffer.c:1.17
Rev: src/zlib.c:1.18
parent 91666088
......@@ -345,7 +345,6 @@ static int do_global_request(struct packet_handler *c,
END (packet);
}
#if 1
/* Callback given to the CHANNEL_OPEN method */
static int do_channel_open_response(struct channel_open_callback *c,
struct ssh_channel *channel,
......@@ -412,7 +411,7 @@ make_channel_open_response(struct ssh_connection* connection,
return closure;
}
#endif
#if 0
/* ;;GABA:
......@@ -1183,11 +1182,6 @@ void init_channel(struct ssh_channel *channel)
channel->open_continuation = NULL;
object_queue_init(&channel->pending_requests);
#if 0
channel->channel_success = NULL;
channel->channel_failure = NULL;
#endif
}
struct lsh_string *channel_transmit_data(struct ssh_channel *channel,
......
......@@ -135,13 +135,6 @@
#define CHANNEL_OPEN_FAILURE(s) \
((s)->open_failure((s)))
#if 0
#define CHANNEL_SUCCESS(s) \
((s)->channel_success((s)))
#define CHANNEL_FAILURE(s) \
((s)->channel_failure((s)))
#endif
/* FIXME: Perhaps, this information is better kept in the connection
* object? */
......
......@@ -195,19 +195,6 @@ static int do_client_session_close(struct ssh_channel *c UNUSED)
return LSH_CHANNEL_PENDING_CLOSE;
}
#if 0
static int client_session_die(struct ssh_channel *c)
{
CAST(client_session, closure, c);
/* FIXME: Don't die this hard. */
if ( (closure->super.flags & (CHANNEL_SENT_CLOSE | CHANNEL_RECEIVED_CLOSE))
== (CHANNEL_SENT_CLOSE | CHANNEL_RECEIVED_CLOSE))
exit(EXIT_SUCCESS);
exit(EXIT_FAILURE);
}
#endif
/* GABA:
(class
......@@ -296,9 +283,6 @@ static int do_exit_signal(struct channel_request *c,
return channel_eof(channel);
return LSH_OK | LSH_GOON;
#if 0
return close_client_session(channel);
#endif
}
/* Invalid request */
......@@ -394,97 +378,6 @@ static int do_client_io(struct command *s UNUSED,
struct command client_io =
{ STATIC_HEADER, do_client_io };
#if 0
static struct request_info *skip_silent_requests(struct request_info *req)
{
while (req && !req->want_reply)
req = req->next;
return req;
}
static int do_channel_success(struct ssh_channel *c);
static int do_channel_failure(struct ssh_channel *c);
static void install_request_handler(struct client_session *session,
struct request_info *req)
{
session->requests = skip_silent_requests(req);
if (session->requests)
{
session->super.channel_success = do_channel_success;
session->super.channel_failure = do_channel_failure;
}
else
session->super.channel_success = session->super.channel_failure = NULL;
}
static int do_channel_success(struct ssh_channel *c)
{
CAST(client_session, closure, c);
int res = LSH_OK | LSH_GOON;
assert(closure->requests);
assert(closure->requests->want_reply);
if (closure->requests->result)
res = REQUEST_RESULT(closure->requests, c, 1);
if (!LSH_FAILUREP(res))
install_request_handler(closure, closure->requests->next);
return res;
}
static int do_channel_failure(struct ssh_channel *c)
{
CAST(client_session, closure, c);
int res = 0;
struct request_info *req = closure->requests;
assert(req);
assert(req->want_reply);
if (req->result)
res = REQUEST_RESULT(req, c, 0);
if (!LSH_FAILUREP(res))
install_request_handler(closure, req->next);
if (req->essential)
res |= LSH_CHANNEL_CLOSE;
return res;
}
/* We have opened a channel of type "session" */
static int do_open_confirm(struct ssh_channel *c)
{
CAST(client_session, closure, c);
struct request_info *req;
int res = 0;
closure->super.open_confirm = NULL;
closure->super.open_failure = NULL;
/* tty_makeraw(0); */
for (req = closure->requests; req; req = req->next)
{
assert(req->want_reply == (req->essential || req->result));
res |= A_WRITE(closure->super.write,
REQUEST_FORMAT(req, c));
if (LSH_CLOSEDP(res))
return res;
}
install_request_handler(closure, closure->requests);
return res;
}
#endif
struct ssh_channel *make_client_session(struct io_fd *in,
struct io_fd *out,
......@@ -561,182 +454,6 @@ struct command *make_open_session_command(struct ssh_channel *session)
return &self->super.super;
}
#if 0
/* ;; GABA:
(class
(name client_startup)
(super connection_startup)
(vars
(session object ssh_channel)
; Exec or shell request.
;; (final_request simple int)
;; (args string)
; To access stdio
;; (in object io_fd)
;; (out object io_fd)
;; (err object io_fd)
))
*/
static int do_client_startup(struct connection_startup *c,
struct ssh_connection *connection)
{
CAST(client_startup, closure, c);
struct lsh_string *s;
closure->session->write = connection->write;
closure->session->open_confirm = do_open_confirm;
closure->session->open_failure = client_session_die;
s = prepare_channel_open(connection->channels, ATOM_SESSION,
closure->session, "");
if (!s)
fatal("Couldn't allocate a channel number!\n");
/* Close connetion when the last channel is closed. */
connection->channels->pending_close = 1;
return A_WRITE(connection->write, s);
}
#define WINDOW_SIZE (SSH_MAX_PACKET << 3)
/* Request opening a session. */
struct connection_startup *make_client_startup(struct io_fd *in,
struct io_fd *out,
struct io_fd *err,
struct request_info *requests,
int *exit_status)
{
NEW(client_startup, closure);
closure->super.start = do_client_startup;
closure->session = make_client_session(in, out, err,
WINDOW_SIZE,
requests,
exit_status);
return &closure->super;
}
#endif
#if 0
/* FIXME: This should probably move to client_pty */
/* ;; GABA:
(class
(name pty_request)
(super request_info)
(vars
; An open fd connected to a tty (most likely, /dev/tty opened by main).
(tty . int)
(ios simple "struct termios")
(term string)
(width . UINT32)
(height . UINT32)
(width_p . UINT32)
(height_p . UINT32)
(modes string)))
*/
#if WITH_PTY_SUPPORT
static struct lsh_string *do_pty_format(struct request_info *r,
struct ssh_channel *channel)
{
CAST(pty_request, req, r);
verbose("lsh: Requesting a remote pty.\n");
return format_channel_request(ATOM_PTY_REQ, channel, req->super.want_reply,
"%S%i%i%i%i%S",
req->term,
req->width, req->height,
req->width_p, req->height_p,
req->modes);
}
static int do_pty_result(struct request_info *r,
struct ssh_channel *ignored UNUSED,
int res)
{
CAST(pty_request, req, r);
verbose("lsh: pty request %z.\n", res ? "successful" : "failed");
if (res)
{
if (!tty_setattr(req->tty, &req->ios))
werror("do_pty_result: "
"Setting the attributes of the local terminal failed.\n");
}
return LSH_OK | LSH_GOON;
}
struct request_info *make_pty_request(int fd, int essential, int raw,
struct request_info *next)
{
NEW(pty_request, req);
char *term = getenv("TERM");
req->super.next = next;
req->super.want_reply = 1;
req->super.essential = essential;
req->super.format = do_pty_format;
req->tty = fd;
req->term = term ? format_cstring(term) : ssh_format("");
if (tty_getattr(fd, &req->ios)
&& tty_getwinsize(fd, &req->width, &req->height,
&req->width_p, &req->height_p))
{
req->modes = tty_encode_term_mode(&req->ios);
if (raw)
CFMAKERAW(&req->ios);
req->super.result = do_pty_result;
}
else
req->super.result = NULL;
return &req->super;
}
#endif / !WITH_PTY_SUPPORT */
#endif
#if 0
static struct lsh_string *do_shell_format(struct request_info *req,
struct ssh_channel *channel)
{
return format_channel_request(ATOM_SHELL, channel, req->want_reply, "");
}
static int do_shell_result(struct request_info *ignored UNUSED,
struct ssh_channel *channel,
int res)
{
if (res)
return do_io(channel);
werror("do_shell_result: Starting shell failed.\n");
return LSH_OK | LSH_GOON;
}
struct request_info *make_shell_request(struct request_info *next)
{
NEW(request_info, req);
req->next = next;
req->essential = 1;
req->want_reply = 1;
req->format = do_shell_format;
req->result = do_shell_result;
return req;
}
#endif
static struct lsh_string *
do_format_shell_request(struct channel_request_command *s UNUSED,
......
......@@ -52,21 +52,8 @@ struct command *make_request_service(int service);
struct channel_request *make_handle_exit_status(int *exit_code);
struct channel_request *make_handle_exit_signal(int *exit_code);
#if 0
struct connection_startup *make_client_startup(struct io_fd *in,
struct io_fd *out,
struct io_fd *err,
struct request_info *requests,
int *exit_status);
#endif
struct command *make_open_session_command(struct ssh_channel *session);
#if 0
struct request_info *make_shell_request(struct request_info *next);
struct request_info *make_pty_request(int fd, int essential, int raw,
struct request_info *next);
#endif
extern struct channel_request_command request_shell;
extern struct command client_io;
......@@ -77,13 +64,5 @@ struct ssh_channel *make_client_session(struct io_fd *in,
UINT32 max_window,
int *exit_status);
#if 0
struct lsh_object *make_channel_request(int request, struct lsh_string *args);
#define request_shell() make_channel_request(ATOM_SHELL, ssh_format(""))
#define request_pty(term, w, h, wp, hp, modes) \
make_channel_request(ATOM_PTY_REQ, ssh_format("%z%i%i%i%i%fS", term, w, h, wp, hp, modes))
#endif
#endif /* LSH_CLIENT_H_INCLUDED */
......@@ -129,21 +129,3 @@ struct command *make_pty_request(int tty)
return &req->super.super;
}
#if 0
struct lsh_string *
format_pty_req(struct ssh_channel *channel, int want_reply,
UINT8 *term, UINT32 width, UINT32 height, UINT32 width_p,
UINT32 height_p, struct lsh_string *term_modes)
{
return format_channel_request(ATOM_PTY_REQ, channel, want_reply,
"%s%i%i%i%i%S",
strlen(term),
term,
width, height,
width_p, height_p,
term_modes);
}
#endif
......@@ -29,12 +29,5 @@
struct command *make_pty_request(int tty);
#if 0
struct lsh_string *
format_pty_req(struct ssh_channel *channel, int want_reply,
UINT8 *term, UINT32 width, UINT32 height, UINT32 width_p,
UINT32 height_p, struct lsh_string *term_modes);
#endif
#endif /* LSH_CLIENT_PTY_H_INCLUDED */
......@@ -291,15 +291,5 @@ collect_Cp_3(struct collect_info_3 *info,
(make_collect_state_2(&collect_info_Cp_2, (c), (f)))
#define GABA_APPLY_Cp_3(c, f, y) (collect_Cp_3(NULL, (c), (f), (y)))
#if 0
/* (lambda (x) (f (g x))) */
struct command *command_compose(struct command *f, struct command *g);
/* (lambda (x) (and (f1 x) (f2 x) ...)) */
struct command *command_andl(struct object_list *args);
/* (lambda (x) (or (f1 x) (f2 x) ...)) */
struct command *command_orl(struct object_list *args);
#endif
#endif /* LSH_COMMAND_H_INCLUDED */
......@@ -201,9 +201,6 @@ struct ssh_connection *make_ssh_connection(struct command_continuation *c)
connection->dispatch[SSH_MSG_DEBUG] = make_rec_debug_handler();
#if 0
connection->dispatch[SSH_MSG_KEXINIT] = kex_handler;
#endif
/* Make all other known message types terminate the connection */
......
......@@ -634,29 +634,6 @@ struct make_kexinit *make_simple_kexinit(struct randomness *r,
return &res->super;
}
#if 0
/* FIXME: This function should be replaced by something more
* configurable. Perhaps creating the algorithm alist should be
* handled by the same function. */
struct make_kexinit *make_test_kexinit(struct randomness *r)
{
return make_simple_kexinit
(r,
make_int_list(1, ATOM_DIFFIE_HELLMAN_GROUP1_SHA1, -1),
make_int_list(1, ATOM_SSH_DSS, -1),
make_int_list(2, ATOM_ARCFOUR, ATOM_NONE, -1),
make_int_list(2, ATOM_HMAC_SHA1, ATOM_HMAC_MD5, -1),
#if WITH_ZLIB
make_int_list(2, ATOM_ZLIB, ATOM_NONE, -1),
#else /* !WITH_ZLIB */
make_int_list(1, ATOM_NONE, -1),
#endif/* !WITH_ZLIB */
make_int_list(0, -1));
}
#endif
/* GABA:
(class
......
......@@ -357,39 +357,6 @@ int main(int argc, char **argv)
? make_int_list(1, preferred_compression, -1)
: default_compression_algorithms()),
make_int_list(0, -1));
#if 0
service = make_connection_service
(make_alist(0, -1),
make_alist(0, -1),
make_client_startup(io_read(backend, in, NULL, NULL),
io_write(backend, out, BLOCK_SIZE, NULL),
io_write(backend, err, BLOCK_SIZE, NULL),
requests,
&lsh_exit_code));
kexinit_handler = make_kexinit_handler
(CONNECTION_CLIENT,
make_kexinit, algorithms,
/* FIXME: Make request_service a command */
request_service(ATOM_SSH_USERAUTH,
make_client_userauth(ssh_format("%lz", user),
ATOM_SSH_CONNECTION,
service)));
#endif
#if 0
if (!io_connect(backend, &remote, NULL,
make_client_callback(backend,
"lsh - a free ssh",
SSH_MAX_PACKET,
r, make_kexinit,
kexinit_handler)))
{
werror("lsh: Connection failed: %z\n", strerror(errno));
return EXIT_FAILURE;
}
#endif
/* Exit code if no session is established */
......
......@@ -400,14 +400,6 @@ int main(int argc, char **argv)
werror("lshd: Invalid port or service\n");
exit (EXIT_FAILURE);
}
#if 0
if (!get_inaddr(&local, host, port, "tcp"))
{
werror("lshd: No such host or service.\n");
return EXIT_FAILURE;
}
#endif
#if 0
#if HAVE_SYSLOG
......@@ -445,32 +437,6 @@ int main(int argc, char **argv)
? make_int_list(1, preferred_compression, -1)
: default_compression_algorithms()),
make_int_list(0, -1));
#if 0
kexinit_handler = make_kexinit_handler
(CONNECTION_SERVER,
make_kexinit, algorithms,
make_meta_service
(make_alist
(1, ATOM_SSH_USERAUTH,
make_userauth_service
(make_int_list(1, ATOM_PASSWORD, -1),
make_alist(1, ATOM_PASSWORD,
make_unix_userauth
(make_alist(1,
ATOM_SSH_CONNECTION,
make_server_connection_service
(make_alist(0, -1),
make_alist(1
#if WITH_PTY_SUPPORT
+1, ATOM_PTY_REQ, make_pty_handler()
#endif /* WITH_PTY_SUPPORT */
, ATOM_SHELL, make_shell_handler(backend, reaper),
-1),
backend),
-1)),
-1)),
-1)));
#endif
{
struct lsh_object *o = lshd_listen
......@@ -521,23 +487,6 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
}
#if 0
if (!io_listen(backend, &local,
make_server_callback(backend,
"lsh - a free ssh",
#if WITH_SSH1_FALLBACK
sshd1 ? make_ssh1_fallback (sshd1) :
#endif /* WITH_SSH1_FALLBACK */
NULL,
SSH_MAX_PACKET,
r, make_kexinit,
kexinit_handler)))
{
werror("lshd: listen() failed: (errno = %i): %z\n",
errno, strerror(errno));
return 1;
}
#endif
reaper_run(reaper, backend);
......
......@@ -155,12 +155,6 @@ struct object_queue_node
struct lsh_object *o;
};
#if 0
void object_queue_init(struct object_queue *q)
{
lsh_queue_init(&q->q);
}
#endif
static struct object_queue_node *
make_object_queue_node(struct lsh_object *o)
......
......@@ -31,12 +31,6 @@
#include "xalloc.h"
/* Prototypes */
#if 0
void do_mark_resources(struct lsh_queue *q,
void (*mark)(struct lsh_object *o));
void do_free_resources(struct lsh_queue *q);
#endif
void dont_free_live_resource(int alive);
......@@ -44,20 +38,6 @@ void dont_free_live_resource(int alive);
#include "resource.h.x"
#undef GABA_DEFINE
#if 0
void do_mark_resources(struct lsh_queue *q,
void (*mark)(struct lsh_object *o))
{
FOR_QUEUE(q, struct resource_node *, n)
mark(&n->resource->super);
}
void do_free_resources(struct lsh_queue *q)
{
FOR_QUEUE(q, struct resource_node *, n)
lsh_space_free(n);
}
#endif
void dont_free_live_resource(int alive)
{
......@@ -79,12 +59,6 @@ static void do_kill_all(struct resource_list *self)
CAST_SUBTYPE(resource, r, object_queue_remove_head(&self->q));
KILL_RESOURCE(r);
}
#if 0
/* FIXME: Doesn't deallocate any nodes (but gc should do that
* later). */
FOR_QUEUE(&self->q, struct resource_node *, n)
KILL_RESOURCE(n->resource);
#endif
}
struct resource_list *empty_resource_list(void)
......
......@@ -24,26 +24,8 @@