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

Removed old #if:ed out code

Rev: src/algorithms.h:1.8
Rev: src/client.h:1.34
Rev: src/client_keyexchange.c:1.55
Rev: src/client_userauth.c:1.44
Rev: src/connection.c:1.61
Rev: src/format.h:1.32
Rev: src/interact.c:1.5
Rev: src/interact.h:1.5
Rev: src/io.c:1.119
Rev: src/io.h:1.69
Rev: src/lsh-writekey.c:1.9
Rev: src/lsh.c:1.126
Rev: src/lshd.c:1.104
Rev: src/reaper.c:1.16
Rev: src/reaper.h:1.9
Rev: src/server_session.c:1.53
Rev: src/spki.c:1.27
Rev: src/spki_commands.c:1.13
Rev: src/srp-gen.c:1.7
Rev: src/tty.c:1.11
Rev: src/tty.h:1.11
parent f25efba6
......@@ -53,28 +53,6 @@ int lookup_hash(struct alist *algorithms, const char *name,
struct hash_algorithm **ap,
int none_is_valid);
#if 0
struct int_list *default_crypto_algorithms(void);
struct int_list *all_crypto_algorithms(void);
struct int_list *default_mac_algorithms(void);
struct int_list *default_compression_algorithms(void);
struct int_list *prefer_compression_algorithms(void);
#endif
#if 0
void
vlist_algorithms(const struct argp_state *state,
struct alist *algorithms,
unsigned n,
va_list args);
void
list_algorithms(const struct argp_state *state,
struct alist *algorithms,
char *prefix,
unsigned n, ...);
#endif
void
list_crypto_algorithms(const struct argp_state *state,
struct alist *algorithms);
......
......@@ -34,18 +34,6 @@
#include "client.h.x"
#undef GABA_DECLARE
#if 0
struct fd_callback *
make_client_callback(struct io_backend *b,
const char *comment,
UINT32 block_size,
struct randomness *random,
struct make_kexinit *init,
struct packet_handler *kexinit_handler);
struct read_handler *make_client_read_line(struct ssh_connection *c);
struct lsh_callback *make_client_close_handler(void);
#endif
struct packet_handler *
make_accept_service_handler(UINT32 service,
......
......@@ -29,9 +29,6 @@
#include "dsa.h"
#include "format.h"
#include "lookup_verifier.h"
#if 0
#include "password.h"
#endif
#include "srp.h"
#include "ssh.h"
......
......@@ -27,9 +27,6 @@
#include "command.h"
#include "format.h"
#include "parse.h"
#if 0
#include "password.h"
#endif
#include "publickey_crypto.h"
#include "ssh.h"
#include "werror.h"
......
......@@ -305,18 +305,6 @@ make_ssh_connection(UINT32 flags,
connection->literal_kexinits[CONNECTION_CLIENT]
= connection->literal_kexinits[CONNECTION_SERVER] = NULL;
#if 0
connection->newkeys = NULL;
#endif
#if 0
/* Initialize dispatch */
connection->ignore = &connection_ignore_handler;
connection->unimplemented = &unimplemented_handler;
connection->fail = &fail_handler;
connection->forward = &forward_handler;
#endif
for (i = 0; i < 0x100; i++)
connection->dispatch[i] = &connection_unimplemented_handler;
......
......@@ -97,12 +97,6 @@ struct lsh_string *ssh_cformat(const char *format, ...);
/* FIXME: The names of these three functions are not quite intuitive.
* Perhaps they should be renamed or deleted. */
#if 0
#define format_cstring(s) (ssh_cformat("%lz", (s)))
#define make_cstring_l(l, s) (ssh_cformat("%ls", (l), (s)))
#define make_cstring(s, f) (ssh_cformat((f) ? "%lfS" : "%lS", (s)))
#endif
struct lsh_string *
format_cstring(const char *s);
......
......@@ -41,123 +41,3 @@
#define GABA_DEFINE
#include "interact.h.x"
#undef GABA_DEFINE
#if 0
int tty_fd = -1;
int lsh_open_tty(void)
{
#if HAVE_STDTTY_FILENO
tty_fd = STDTTY_FILENO;
return 1;
#else /* !HAVE_STDTTY_FILENO */
int fd = open("/dev/tty", O_RDWR);
if (fd < 0)
return 0;
tty_fd = fd;
return 1;
#endif /* !HAVE_STDTTY_FILENO */
}
/* Depends on the tty being line buffered */
int tty_read_line(UINT32 size, UINT8 *buffer)
{
UINT32 i = 0;
while (i < size)
{
int res = read(tty_fd, buffer + i, size - i);
if (!res)
/* User pressed EOF (^D) */
return i;
else if (res < 0)
switch(errno)
{
case EAGAIN:
case EINTR:
break;
default:
/* I/O error */
werror("tty_read_line: %z (errno = %i)\n",
errno, STRERROR(errno));
return 0;
}
else
{
UINT32 j;
for (j = 0; j < (unsigned) res; j++, i++)
if (buffer[i] == '\n')
return i;
}
}
/* We have filled our buffer already; continue reading until end of line */
#define BUFSIZE 512
for (;;)
{
UINT8 b[BUFSIZE];
int res = read(tty_fd, b, BUFSIZE);
if (!res)
/* EOF */
return size;
else if (res < 0)
switch(errno)
{
case EAGAIN:
case EINTR:
break;
default:
/* I/O error */
werror("tty_read_line: %z (errno = %i)\n",
errno, strerror(errno));
return 0;
}
else
{
UINT32 j;
for (j = 0; j < (unsigned) res; j++)
if (b[j] == '\n')
return res;
}
}
#undef BUFSIZE
}
#define TTY_BUFSIZE 10
int yes_or_no(struct lsh_string *s, int def, int free)
{
UINT8 buffer[TTY_BUFSIZE];
const struct exception *e;
if ( (tty_fd < 0) || quiet_flag)
{
if (free)
lsh_string_free(s);
return def;
}
e = write_raw(tty_fd, s->length, s->data);
if (free)
lsh_string_free(s);
if (e)
return def;
if (!tty_read_line(TTY_BUFSIZE, buffer))
return def;
switch (buffer[0])
{
case 'y':
case 'Y':
return 1;
default:
return 0;
}
}
#endif
......@@ -104,14 +104,6 @@ struct terminal_dimensions
#define INTERACT_WINDOW_SUBSCRIBE(i, c) \
((i)->window_change_subscribe((i), (c)))
#if 0
extern int tty_fd;
int lsh_open_tty(void);
int tty_read_line(UINT32 size, UINT8 *buffer);
int yes_or_no(struct lsh_string *s, int def, int free);
#endif
struct interact *
make_unix_interact(struct io_backend *backend);
......
......@@ -1702,94 +1702,6 @@ io_read_file(struct io_backend *backend,
return make_lsh_fd(backend, fd, e);
}
#if 0
static const struct exception *
check_user_permissions(struct stat *sbuf, const char *fname,
uid_t uid, int secret)
{
mode_t bad = secret ? (S_IRWXG | S_IRWXO) : (S_IWGRP | S_IWOTH);
if (!S_ISREG(sbuf->st_mode))
{
werror("io.c: %z is not a regular file.\n",
fname);
return make_io_exception(EXC_IO_OPEN_READ, NULL, 0, "Not a regular file");
}
if (sbuf->st_uid != uid)
{
werror("io.c: %z not owned by the right user (%i)\n",
fname, uid);
return make_io_exception(EXC_IO_OPEN_READ, NULL, 0, "Bad owner");
}
if (sbuf->st_mode & bad)
{
werror("io.c: Permissions on %z too loose.\n",
fname);
return make_io_exception(EXC_IO_OPEN_READ, NULL, 0, "Bad permissions");
}
return NULL;
}
/* Open a file, but first check that it is owned by the right user and
* has proper permissions, and change uid before opening the file.
* Doesn't check permissions on parent directory. Also, doesn't try to
* forbid symlinks. */
struct lsh_fd *
io_read_user_file(struct io_backend *backend,
const char *fname,
uid_t uid, int secret,
const struct exception **x,
struct exception_handler *e)
{
int fd;
struct stat sbuf;
if (stat(fname, &sbuf) < 0)
{
if (errno != ENOENT)
werror("io_read_user_file: Failed to stat %z (errno = %i): %z\n",
fname, errno, STRERROR(errno));
*x = make_io_exception(EXC_IO_OPEN_READ, NULL, errno, NULL);
return NULL;
}
*x = check_user_permissions(&sbuf, fname, uid, secret);
if (*x)
return NULL;
fd = open(fname, O_RDONLY);
if (fd < 0)
{
*x = make_io_exception(EXC_IO_OPEN_READ, NULL, errno, NULL);
return NULL;
}
if (fstat(fd, &sbuf) < 0)
{
werror("io_read_user_file: Failed to stat %z (errno = %i): %z\n",
fname, errno, STRERROR(errno));
close(fd);
*x = make_io_exception(EXC_IO_OPEN_READ, NULL, errno, NULL);
return NULL;
}
*x = check_user_permissions(&sbuf, fname, uid, secret);
if (*x)
{
close(fd);
return NULL;
}
return make_lsh_fd(backend, fd, e);
}
#endif
void kill_fd(struct lsh_fd *fd)
{
fd->super.alive = 0;
......
......@@ -218,9 +218,6 @@ extern const struct exception finish_io_exception;
struct io_backend *
make_io_backend(void);
#if 0
void init_backend(struct io_backend *b);
#endif
int io_iter(struct io_backend *b);
void io_run(struct io_backend *b);
......@@ -351,15 +348,6 @@ io_read_file(struct io_backend *backend,
const char *fname,
struct exception_handler *e);
#if 0
struct lsh_fd *
io_read_user_file(struct io_backend *backend,
const char *fname,
uid_t uid, int secret,
const struct exception **x,
struct exception_handler *e);
#endif
int
lsh_make_pipe(int *fds);
......
......@@ -29,10 +29,6 @@
#include "format.h"
#include "io_commands.h"
#include "interact.h"
#if 0
/* For read_password() */
#include "password.h"
#endif
#include "rsa.h"
#include "sexp_commands.h"
#include "spki_commands.h"
......
......@@ -719,32 +719,6 @@ parse_forward_arg(char *arg,
return 1;
}
#if 0
/* FIXME: Resetting the tty should really be done by the corresponding
* channel. */
#if WITH_PTY_SUPPORT
/* Global variable, because we use atexit() rather than on_exit() */
struct tty_state
{
struct termios mode;
int fd;
} old_tty;
static void reset_tty(void)
{
tty_setattr(old_tty.fd, &old_tty.mode);
}
static int remember_tty(int fd)
{
old_tty.fd = fd;
return (tty_getattr(fd, &old_tty.mode)
&& !atexit(reset_tty));
}
#endif /* WITH_PTY_SUPPORT */
#endif
/* Option parsing */
......
......@@ -88,11 +88,6 @@ struct command_simple options2signature_algorithms;
#include <unistd.h>
#endif
#if 0
/* Block size for stdout and stderr buffers */
#define BLOCK_SIZE 32768
#endif
/* Option parsing */
const char *argp_program_version
......
......@@ -190,37 +190,3 @@ make_reaper(struct io_backend *b)
return &self->super;
}
#if 0
void
reaper_run(struct reap *r, struct io_backend *b)
{
CAST(reaper, self, r);
struct sigaction pipe;
struct sigaction chld;
memset(&pipe, 0, sizeof(pipe));
memset(&chld, 0, sizeof(chld));
pipe.sa_handler = SIG_IGN;
sigemptyset(&pipe.sa_mask);
pipe.sa_flags = 0;
chld.sa_handler = child_handler;
sigemptyset(&chld.sa_mask);
chld.sa_flags = SA_NOCLDSTOP;
halloween = 0;
if (sigaction(SIGPIPE, &pipe, NULL) < 0)
fatal("Failed to ignore SIGPIPE.\n");
if (sigaction(SIGCHLD, &chld, NULL) < 0)
fatal("Failed to install handler for SIGCHLD.\n");
while(io_iter(b))
if (halloween)
reap(self);
}
#endif
......@@ -54,8 +54,4 @@
struct reap *make_reaper(struct io_backend *b);
#if 0
void reaper_run(struct reap *r, struct io_backend *b);
#endif
#endif /* LSH_REAPER_H_INCLUDED */
......@@ -306,44 +306,6 @@ make_exit_shell(struct server_session *session)
(reaper object reap)))
*/
#if 0
/* Creates a one-way socket connection. Returns 1 on success, 0 on
* failure. fds[0] is for reading, fds[1] for writing (like for the
* pipe() system call). */
static int
make_pipe(int *fds)
{
if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0)
{
werror("socketpair() failed: %z\n", STRERROR(errno));
return 0;
}
debug("Created socket pair. Using fd:s %i <-- %i\n", fds[0], fds[1]);
if (SHUTDOWN(fds[0], SHUT_WR) < 0)
{
werror("shutdown(%i, SEND) failed: %z\n", fds[0], STRERROR(errno));
goto fail;
}
if (SHUTDOWN(fds[1], SHUT_RD) < 0)
{
werror("shutdown(%i, REC) failed: %z\n", fds[0], STRERROR(errno));
fail:
{
int saved_errno = errno;
close(fds[0]);
close(fds[1]);
errno = saved_errno;
return 0;
}
}
return 1;
}
#endif
static int
make_pipes(int *in, int *out, int *err)
{
......
......@@ -40,14 +40,6 @@
#include <assert.h>
#include <string.h>
#if 0
#include <sys/types.h>
#include <fcntl.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
#define GABA_DEFINE
#include "spki.h.x"
#undef GABA_DEFINE
......
......@@ -542,9 +542,6 @@ do_spki_encrypt(struct command *s,
CAST_SUBTYPE(sexp, expr, a);
struct lsh_string *iv = NULL;
#if 0
UINT8 noiv[1] = { 0 };
#endif
if (self->algorithm->iv_size)
{
......
......@@ -29,10 +29,6 @@
#include "format.h"
#include "interact.h"
#include "io.h"
#if 0
/* For read_password() */
#include "password.h"
#endif
#include "randomness.h"
#include "sexp.h"
#include "srp.h"
......
......@@ -50,20 +50,6 @@ tty_setattr(int fd, struct termios *ios)
return tcsetattr(fd, TCSADRAIN, ios) != -1 ? 1 : 0;
}
#if 0
int tty_makeraw(int fd)
{
struct termios ios;
if (tty_getattr(fd, &ios))
{
CFMAKERAW(&ios);
return tty_setattr(fd, &ios);
}
return 0;
}
#endif
int
tty_getwinsize(int fd, UINT32 *w, UINT32 *h, UINT32 *wp, UINT32 *hp)
{
......
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