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

* Removed lots of old #if:ed out code.

Rev: src/abstract_crypto.h:1.25
Rev: src/channel.c:1.78
Rev: src/channel.h:1.56
Rev: src/client.c:1.92
Rev: src/client_keyexchange.c:1.41
Rev: src/client_userauth.c:1.29
Rev: src/connection.c:1.51
Rev: src/connection.h:1.48
Rev: src/disconnect.c:1.17
Rev: src/disconnect.h:1.7
Rev: src/exception.h:1.17
Rev: src/io.c:1.99
Rev: src/io.h:1.59
Rev: src/io_commands.c:1.32
Rev: src/lsh.c:1.105
Rev: src/password.c:1.5
Rev: src/read_data.h:1.15
Rev: src/server_password.c:1.30
Rev: src/server_session.c:1.36
Rev: src/server_session.h:1.11
Rev: src/server_userauth.c:1.26
Rev: src/server_userauth.h:1.9
Rev: src/sexp_commands.c:1.10
Rev: src/sexp_streamed_parser.c:1.21
Rev: src/tcpforward.c:1.46
Rev: src/tcpforward.h:1.14
parent fbebe099
......@@ -178,10 +178,6 @@
#define MAKE_VERIFIER(a, i) \
((a)->make_verifier((a), (i)))
#if 0
#define MAKE_PUBLIC(a, i) \
((a)->private2public((a), (i)))
#endif
/* Combining block cryptos */
......
......@@ -685,29 +685,6 @@ do_global_request_failure(struct packet_handler *s UNUSED,
END(packet);
}
#if 0
static void
do_connection_sent(struct ssh_connection *connection,
UINT32 length UNUSED)
{
UINT32 i;
for (i = 0; i < connection->table->used_channels; i++)
{
if (connection->table->in_use[i] == CHANNEL_IN_USE)
{
struct ssh_channel *channel = connection->table->channels[i];
if (! (channel->flags & (CHANNEL_SENT_CLOSE | CHANNEL_SENT_EOF)))
{
if (channel->send_window_size && channel->send)
CHANNEL_SEND(channel, connection);
}
}
}
}
#endif
/* FIXME: Don't store the channel here, instead have it passed as the
* argument of the continuation. This might also allow some
* unification with the handling of global_requests. */
......
......@@ -329,12 +329,6 @@ void
channel_start_receive(struct ssh_channel *channel,
UINT32 initial_window_size);
#if 0
struct lsh_string *prepare_channel_open(struct ssh_connection *connection,
int type,
struct ssh_channel *channel,
const char *format, ...);
#endif
struct lsh_string *
format_channel_open(int type, UINT32 local_channel_number,
struct ssh_channel *channel,
......
......@@ -196,10 +196,6 @@ do_client_session_eof(struct ssh_channel *c)
CAST(client_session, session, c);
close_fd(session->in, 0);
#if 0
close_fd(session->out, 0);
close_fd(session->err, 0);
#endif
}
static void
......
......@@ -34,12 +34,6 @@
#include <assert.h>
#if 0
#define GABA_DEFINE
#include "client_keyexchange.h.x"
#undef GABA_DEFINE
#endif
#include "client_keyexchange.c.x"
/* GABA:
......
......@@ -351,18 +351,6 @@ do_userauth_banner(struct packet_handler *self UNUSED,
static struct packet_handler userauth_banner_handler =
{ STATIC_HEADER, do_userauth_banner };
#if 0
/* FIXME: Could use a static object instead. */
static struct packet_handler *
make_banner_handler(void)
{
NEW(packet_handler, self);
self->handler = do_userauth_banner;
return self;
}
#endif
/* GABA:
(class
......
......@@ -143,17 +143,6 @@ do_fail(struct packet_handler *closure UNUSED,
PROTOCOL_ERROR(connection->e, NULL);
}
#if 0
/* FIXME: Could use a static object instead. */
struct packet_handler *make_fail_handler(void)
{
NEW(packet_handler, res);
res->handler = do_fail;
return res;
}
#endif
static struct packet_handler fail_handler =
{ STATIC_HEADER, do_fail };
......@@ -175,17 +164,6 @@ do_unimplemented(struct packet_handler *closure UNUSED,
lsh_string_free(packet);
}
#if 0
/* FIXME: Could use a static object instead. */
struct packet_handler *make_unimplemented_handler(void)
{
NEW(packet_handler, res);
res->handler = do_unimplemented;
return res;
}
#endif
static struct packet_handler unimplemented_handler =
{ STATIC_HEADER, do_unimplemented };
......@@ -215,17 +193,7 @@ do_exc_protocol_handler(struct exception_handler *s,
EXCEPTION_RAISE(self->super.parent, &finish_read_exception);
}
break;
#if 0
case EXC_CONNECTION_LOCK:
assert(!self->connection->busy);
self->connection->busy = 1;
break;
case EXC_CONNECTION_UNLOCK:
assert(self->connection->busy);
self->connection->busy = 0;
break;
#endif
default:
EXCEPTION_RAISE(self->super.parent, e);
}
......
......@@ -160,11 +160,6 @@ void connection_init_io(struct ssh_connection *connection,
struct abstract_write *raw,
struct randomness *r);
#if 0
struct packet_handler *make_fail_handler(void);
struct packet_handler *make_unimplemented_handler(void);
#endif
/* Serialization */
void connection_lock(struct ssh_connection *self);
void connection_unlock(struct ssh_connection *self);
......
......@@ -77,13 +77,3 @@ do_disconnect(struct packet_handler *closure UNUSED,
struct packet_handler disconnect_handler =
{ STATIC_HEADER, do_disconnect };
#if 0
struct packet_handler *make_disconnect_handler(void)
{
NEW(packet_handler, res);
res->handler = do_disconnect;
return res;
}
#endif
......@@ -31,8 +31,4 @@ struct lsh_string *format_disconnect(int code, const char *msg,
extern struct packet_handler disconnect_handler;
#if 0
struct packet_handler *make_disconnect_handler(void);
#endif
#endif /* LSH_DISCONNECT_H_INCLUDED */
......@@ -135,13 +135,6 @@ void exception_raise(struct exception_handler *e,
/* Unexpected or unsupported expression type */
#define EXC_SPKI_TYPE 0x80001
#if 0
/* Serialization */
#define EXC_CONNECTION_SERIALIZE 0x100000
#define EXC_CONNECTION_LOCK 0x100001
#define EXC_CONNECTION_UNLOCK 0x100002
#endif
#define EXC_ALL (~0)
extern struct exception_handler default_exception_handler;
......
......@@ -1225,19 +1225,6 @@ address_info2sockaddr(socklen_t *length,
#endif /* !HAVE_GETADDRINFO */
}
#if 0
int address_info2sockaddr(struct sockaddr_in *sin,
struct address_info *a)
{
if (a->ip)
return tcp_addr(sin,
a->ip->length, a->ip->data,
a->port);
else
return tcp_addr(sin, 0, NULL, a->port);
}
#endif
void io_set_nonblocking(int fd)
{
......@@ -1376,59 +1363,9 @@ io_listen(struct io_backend *b,
return fd;
}
#if 0
struct lsh_fd *
io_listen(struct io_backend *b,
struct sockaddr_in *local,
struct io_callback *callback,
struct exception_handler *e)
{
assert(local->sin_family == AF_INET);
return io_listen_sockaddr(b, (struct sockaddr *) local, sizeof(*local), callback, e);
#if 0
int s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct lsh_fd *fd;
if (s<0)
return NULL;
trace("io.c: Listening on fd %i\n", s);
io_init_fd(s);
{
int yes = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char*)&yes, sizeof yes);
}
if (bind(s, (struct sockaddr *)local, sizeof *local) < 0)
{
close(s);
return NULL;
}
if (listen(s, 256) < 0)
{
close(s);
return NULL;
}
/* FIXME: What handler to use? */
fd = make_lsh_fd(b, s, e);
fd->want_read = 1;
fd->read = callback;
return fd;
#endif
}
#endif
/* AF_LOCAL sockets */
/* This isn't needed if we have fchdir */
#if 0
#define HAVE_GNU_GETCWD 1
......
......@@ -242,17 +242,6 @@ void io_run(struct io_backend *b);
int blocking_read(int fd, struct read_handler *r);
#if 0
int get_inaddr(struct sockaddr_in * addr,
const char * host,
const char * service,
const char * protocol);
int tcp_addr(struct sockaddr_in *sin,
UINT32 length,
UINT8 *addr,
UINT32 port);
#endif
int get_portno(const char *service, const char *protocol);
struct address_info *
......@@ -307,14 +296,6 @@ io_listen(struct io_backend *b,
struct io_callback *callback,
struct exception_handler *e);
#if 0
struct lsh_fd *
io_listen(struct io_backend *b,
struct sockaddr_in *local,
struct io_callback *callback,
struct exception_handler *e);
#endif
struct lsh_fd *
io_listen_local(struct io_backend *b,
struct lsh_string *directory,
......
......@@ -116,42 +116,6 @@ void do_io_read_fd(struct command *s,
struct io_read_fd io_read_stdin
= STATIC_IO_READ_FD(STDIN_FILENO);
#if 0
/* ;; GABA:
(class
(name listen_command_callback)
(super fd_listen_callback)
(vars
(backend object io_backend)
(c object command_continuation)
(e object exception_handler)))
*/
static void
do_listen_continue(struct fd_listen_callback *s, int fd,
struct address_info *peer)
{
CAST(listen_command_callback, self, s);
COMMAND_RETURN(self->c,
make_listen_value(make_lsh_fd(self->backend, fd, self->e),
peer));
}
static struct fd_listen_callback *
make_listen_command_callback(struct io_backend *backend,
struct command_continuation *c,
struct exception_handler *e)
{
NEW(listen_command_callback, closure);
closure->backend = backend;
closure->c = c;
closure->e = e;
closure->super.f = do_listen_continue;
return &closure->super;
}
#endif
/* GABA:
(class
......@@ -268,34 +232,6 @@ do_listen_with_callback(struct command *s,
c,
make_apply(self->callback,
&discard_continuation, e), e);
#if 0
struct sockaddr *addr;
socklen_t addr_length;
/* Doesn't do any dns lookups. */
addr = address_info2sockaddr(&addr_length, address, NULL, 0);
if (!addr)
{
EXCEPTION_RAISE(e, &resolve_exception);
return;
}
/* FIXME: Asyncronous dns lookups should go here */
fd = io_listen(self->backend,
addr, addr_length,
make_listen_callback
(self->backend,
make_apply(self->callback,
&discard_continuation, e), e), e);
lsh_space_free(addr);
if (fd)
COMMAND_RETURN(c, fd);
else
EXCEPTION_RAISE(e,
make_io_exception(EXC_IO_LISTEN, NULL,
errno, NULL));
#endif
}
struct command *
......@@ -397,46 +333,6 @@ struct collect_info_1 listen_with_connection =
STATIC_COLLECT_1(&collect_info_listen_connection_2);
#if 0
/* FIXME: This could perhaps be merged with io_connect in io.c? */
/* ;; GABA:
(class
(name connect_command_callback)
(super fd_callback)
(vars
(backend object io_backend)
(c object command_continuation)
(e object exception_handler)))
*/
/* FIXME: The new fd object should be added to the same resource list
* as the old one. Perhaps the connection code in io.c should reuse
* the fd object in some way? */
static void
do_connect_continue(struct fd_callback **s, int fd)
{
CAST(connect_command_callback, self, *s);
assert(fd >= 0);
COMMAND_RETURN(self->c, make_lsh_fd(self->backend, fd, self->e));
}
static struct fd_callback *
make_connect_command_callback(struct io_backend *backend,
struct command_continuation *c,
struct exception_handler *e)
{
NEW(connect_command_callback, closure);
closure->backend = backend;
closure->c = c;
closure->e = e;
closure->super.f = do_connect_continue;
return &closure->super;
}
#endif
/* GABA:
(class
(name connect_continuation)
......
......@@ -994,48 +994,6 @@ main_argp_parser(int key, char *arg, struct argp_state *state)
/* Add shell action */
if (object_queue_is_empty(&self->actions) && self->start_shell)
lsh_add_action(self, lsh_shell_session(self));
#if 0
{
struct object_list *session_requests;
#if WITH_PTY_SUPPORT
if (self->with_pty)
{
if (tty_fd < 0)
{
werror("lsh: No tty available.\n");
}
else
{
if (! (remember_tty(tty_fd)
&& (get_pty = make_pty_request(tty_fd))))
{
werror("lsh: Can't use tty (probably getattr or atexit() failed.\n");
}
}
}
/* FIXME: We need a non-varargs constructor for lists. */
if (get_pty)
session_requests
= make_object_list(2,
/* Ignore EXC_CHANNEL_REQUEST for the pty allocation call. */
make_catch_apply
(make_catch_handler_info(EXC_ALL, EXC_CHANNEL_REQUEST,
0, NULL),
get_pty),
start_shell(), -1);
else
#endif /* WITH_PTY_SUPPORT */
session_requests = make_object_list(1, start_shell(), -1);
object_queue_add_tail
(&self->actions,
make_start_session
(make_open_session_command(make_lsh_session(self)),
session_requests));
}
#endif
if (object_queue_is_empty(&self->actions))
{
......@@ -1195,10 +1153,6 @@ do_lsh_default_handler(struct exception_handler *s,
if (e->type & EXC_IO)
{
CAST_SUBTYPE(io_exception, exc, e);
#if 0
if (exc->fd)
close_fd_nicely(exc->fd);
#endif
*self->status = EXIT_FAILURE;
werror("lsh: %z, (errno = %i)\n", e->msg, exc->error);
......
......@@ -24,13 +24,3 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if 0
#include "password.h"
#include "xalloc.h"
#define GABA_DEFINE
#include "password.h.x"
#undef GABA_DEFINE
#endif
......@@ -32,11 +32,4 @@ struct io_callback *
make_read_data(struct ssh_channel *channel,
struct abstract_write *write);
#if 0
struct exception_handler *
make_exc_read_eof_channel_handler(struct ssh_channel *channel,
struct exception_handler *e,
const char *context);
#endif
#endif /* LSH_READ_DATA_H_INCLUDED */
......@@ -138,93 +138,3 @@ make_userauth_password(struct user_db *db)
return &self->super;
}
#if 0
struct userauth unix_userauth =
{ STATIC_HEADER, do_authenticate };
struct setuid_service
{
struct ssh_service super;
struct unix_user *user;
/* Service to start once we have changed to the correct uid. */
struct ssh_service *service;
};
/* NOTE: This is used only if early forking (i.e., for directly after
* user autentication) is enabled. */
static int do_setuid(struct ssh_service *c,
struct ssh_connection *connection)
{
CAST(setuid_service, closure, c);
uid_t server_uid = getuid();
int res = 0;
if (server_uid != closure->user->uid)
{
if (server_uid)
/* Not root */
return LSH_AUTH_FAILED;
switch(fork())
{
case -1:
/* Error */
werror("fork failed: %z\n", STRERROR(errno));
return LSH_FAIL | LSH_DIE;
case 0:
/* Child */
if (!change_uid(closure->user))
return LSH_FAIL | LSH_DIE | LSH_KILL_OTHERS;;
res |= LSH_KILL_OTHERS;
break;
default:
/* Parent */
return LSH_OK | LSH_DIE;
}
}
/* Change to user's home directory. FIXME: If the server is running
* as the same user, perhaps it's better to use $HOME? */
if (!change_dir(closure->user))
fatal("can't chdir: giving up\n");
/* Initialize environment, somehow. In particular, the HOME and
* LOGNAME variables */
return res | LOGIN(closure->service, closure->user); connection);
}
/* FIXME: This function is not quite adequate, as it does not pass the
* user struct on to the started service. */
static struct ssh_service *do_login(struct login_method *closure,
struct unix_user *user,
struct ssh_service *service)
{
struct setuid_service *res;
MDEBUG(closure);
NEW(res);
res->super.init = do_setuid;
res->user = user;
res->service = service;
return &res->super;
}
struct login_method *make_unix_login(void)
{
struct login_method *self;
NEW(self);
self->login = do_login;
return self;
}
#endif
......@@ -40,9 +40,6 @@
/* For debug */
#if 0
#include <signal.h>
#endif
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
......@@ -51,17 +48,6 @@
#include <sys/types.h>
#include <sys/socket.h>
#if 0
#if WITH_UTMP
#if HAVE_UTMP_H
#include <utmp.h>
#endif
#if HAVE_UTMPX_H
#include <utmpx.h>
#endif
#endif /* WITH_UTMP */