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

*** empty log message ***

Rev: src/lsh.c:1.76
Rev: src/lsh_keygen.c:1.16
Rev: src/lshd.c:1.65
parent a959ed90
......@@ -71,39 +71,6 @@
/* Window size for the session channel */
#define WINDOW_SIZE (SSH_MAX_PACKET << 3)
#if 0
void usage(void) NORETURN;
void usage(void)
{
werror("lsh [options] host\n"
" -p, --port=PORT\n"
" -l, --user=NAME\n"
" -c, --crypto=ALGORITHM\n"
" -z, --compression=ALGORITHM\n"
" --mac=ALGORITHM\n"
#if WITH_PTY_SUPPORT
" -t, Request a remote pty\n"
" -nt, Don't request a remote tty\n"
" -g, Allow remote access to forwarded ports\n"
" -ng, Disallow remote access to forwarded ports (default)\n"
#endif /* WITH_PTY_SUPPORT */
" -q, --quiet\n"
" -v, --verbose\n"
" --debug\n"
#if WITH_TCP_FORWARD
" -L listen-port:host:port Forward local port\n"
" --forward-local-port listen-port:host:port\n"
#if 0
" -R, listen-port_host:port Forward remote port\n"
" --forward-remote-port listen-port_host:port\n"
#endif
#endif /* WITH_TCP_FORWARD */
" -N, --nop Don't start a remote shell\n"
);
exit(1);
}
#endif
/* GABA:
(class
......@@ -624,28 +591,6 @@ int main(int argc, char **argv)
{
struct lsh_options *options;
#if 0
char *host = NULL;
char *user = NULL;
char *port = "ssh";
int preferred_crypto = 0;
int preferred_compression = 0;
int preferred_mac = 0;
/* int term_width, term_height, term_width_pix, term_height_pix; */
int not;
struct object_queue actions;
int shell_flag = 1;
int forward_gateway = 0;
int remote_forward = 0;
int option;
struct address_info *remote;
struct command *get_pty = NULL;
#endif
int lsh_exit_code = 0;
struct randomness *r;
......@@ -696,233 +641,6 @@ int main(int argc, char **argv)
options = make_options(algorithms, backend, handler, &lsh_exit_code);
argp_parse(&main_argp, argc, argv, ARGP_IN_ORDER, NULL, options);
#if 0
not = 0;
object_queue_init(&actions);
for (;;)
{
struct option options[] =
{
{ "verbose", no_argument, NULL, 'v' },
{ "quiet", no_argument, NULL, 'q' },
{ "debug", no_argument, &debug_flag, 1},
{ "port", required_argument, NULL, 'p' },
{ "user", required_argument, NULL, 'l' },
{ "crypto", required_argument, NULL, 'c' },
{ "compression", optional_argument, NULL, 'z'},
{ "mac", required_argument, NULL, 'm' },
#if WITH_TCP_FORWARD
{ "forward-local-port", required_argument, NULL, 'L'},
{ "forward-remote-port", required_argument, NULL, 'R'},
#endif /* WITH_TCP_FORWARD */
{ "nop", no_argument, NULL, 'N' },
{ NULL, 0, NULL, 0 }
};
option = getopt_long(argc, argv, "+c:l:np:qgtvz:L:R:N", options, NULL);
switch(option)
{
case -1:
goto options_done;
case 0:
case 'n':
break;
case 'p':
port = optarg;
break;
case 'l':
user = optarg;
break;
case 'q':
quiet_flag = 1;
break;
case 't':
#if WITH_PTY_SUPPORT
use_pty = !not;
#endif /* WITH_PTY_SUPPORT */
break;
case 'g':
forward_gateway = !not;
break;
case 'v':
verbose_flag = 1;
break;
case 'c':
preferred_crypto = lookup_crypto(algorithms, optarg);
if (!preferred_crypto)
{
werror("lsh: Unknown crypto algorithm '%z'.\n", optarg);
return EXIT_FAILURE;
}
break;
case 'z':
if (!optarg)
optarg = "zlib";
preferred_compression = lookup_compression(algorithms, optarg);
if (!preferred_compression)
{
werror("lsh: Unknown compression algorithm '%z'.\n", optarg);
return EXIT_FAILURE;
}
break;
case 'm':
preferred_mac = lookup_mac(algorithms, optarg);
if (!preferred_mac)
{
werror("lsh: Unknown message authentication algorithm '%z'.\n",
optarg);
return EXIT_FAILURE;
}
break;
case 'L':
{
UINT32 listen_port;
struct address_info *target;
if (!parse_forward_arg(optarg, &listen_port, &target))
usage();
object_queue_add_tail(&actions,
&make_forward_local_port
(backend,
make_address_info((forward_gateway
? NULL
: ssh_format("%lz", "127.0.0.1")),
listen_port),
target)->super);
}
break;
case 'R':
{
UINT32 listen_port;
struct address_info *target;
if (!parse_forward_arg(optarg, &listen_port, &target))
usage();
object_queue_add_tail(&actions,
&make_forward_remote_port
(backend,
make_address_info((forward_gateway
/* FIXME: Is NULL an ok value? */
? ssh_format("%lz", "0.0.0.0")
: ssh_format("%lz", "127.0.0.1")),
listen_port),
target)->super);
remote_forward = 1;
}
break;
case 'N':
shell_flag = 0;
break;
case '?':
usage();
}
not = (option == 'n');
}
options_done:
if ( (argc - optind) < 1)
usage();
host = argv[optind];
if (!user)
user = getenv("LOGNAME");
if (!user)
{
werror("lsh: No user name.\n"
"Please use the -l option, or set LOGNAME in the environment\n");
return EXIT_FAILURE;
}
remote = make_address_info_c(host, port);
if (!remote)
{
werror("lsh: Invalid port or service\n");
return EXIT_FAILURE;
}
if (shell_flag)
{
int in;
int out;
int err;
struct object_list *session_requests;
#if WITH_PTY_SUPPORT
if (use_pty < 0)
use_pty = 1;
if (use_pty)
{
tty = open("/dev/tty", O_RDWR);
if (tty < 0)
{
werror("lsh: Failed to open tty (errno = %i): %z\n",
errno, STRERROR(errno));
use_pty = 0;
}
else
{
reset_tty = tty_getattr(tty, &tty_mode);
get_pty = make_pty_request(tty);
}
}
#endif /* WITH_PTY_SUPPORT */
/* FIXME: We need a non-varargs constructor for lists. */
#if WITH_PTY_SUPPORT
if (get_pty)
session_requests = make_object_list(2, get_pty, start_shell(), -1);
else
#endif
session_requests = make_object_list(1, start_shell(), -1);
in = STDIN_FILENO;
out = STDOUT_FILENO;
if ( (err = dup(STDERR_FILENO)) < 0)
{
werror("Can't dup stderr: %z\n", STRERROR(errno));
return EXIT_FAILURE;
}
set_error_stream(STDERR_FILENO, 1);
/* Exit code if no session is established */
lsh_exit_code = 17;
object_queue_add_tail
(&actions,
make_start_session
(make_open_session_command(make_client_session
(io_read(make_io_fd(backend, in, handler),
NULL, NULL),
io_write(make_io_fd(backend, out, handler),
BLOCK_SIZE, NULL),
io_write(make_io_fd(backend, err, handler),
BLOCK_SIZE, NULL),
WINDOW_SIZE,
&lsh_exit_code)),
session_requests));
}
#if WITH_TCP_FORWARD
if (remote_forward)
object_queue_add_tail
(&actions,
&make_install_fix_channel_open_handler
(ATOM_FORWARDED_TCPIP, &channel_open_forwarded_tcpip)->super);
#endif
#endif
make_kexinit
= make_simple_kexinit(r,
......@@ -962,11 +680,6 @@ int main(int argc, char **argv)
/* FIXME: Perhaps we have to reset the stdio file descriptors to
* blocking mode? */
#if 0 && WITH_PTY_SUPPORT
if (reset_tty)
tty_setattr(tty, &tty_mode);
#endif
return lsh_exit_code;
}
......@@ -59,7 +59,7 @@
(level . int)))
*/
struct lsh_keygen_options *
static struct lsh_keygen_options *
make_lsh_keygen_options(void)
{
NEW(lsh_keygen_options, self);
......@@ -144,15 +144,6 @@ main_argp =
NULL
};
#if 0
static void usage(void) NORETURN;
static void usage(void)
{
werror("Usage: lsh_keygen [-o style] [-l nist-level] [-a dsa] [-q] [-d] [-v]\n");
exit(1);
}
#endif
static void
do_lsh_keygen_handler(struct exception_handler *s UNUSED,
......@@ -179,66 +170,6 @@ int main(int argc, char **argv)
argp_parse(&main_argp, argc, argv, 0, NULL, options);
#if 0
while((option = getopt(argc, argv, "a:dl:o:qv")) != -1)
switch(option)
{
case 'l':
{
char *end;
l = strtol(optarg, &end, 0);
if (!*optarg || *end)
usage();
if ( (l<0) || (l > 8))
{
werror("lsh_keygen: nist-level should be in the range 0-8.\n");
usage();
}
break;
}
case 'a':
if (strcmp(optarg, "dsa"))
{
werror("lsh_keygen: Sorry, doesn't support any algorithm but dsa.\n");
usage();
}
break;
case 'o':
if (!strcmp(optarg, "transport"))
style = SEXP_TRANSPORT;
else if (!strcmp(optarg, "canonical"))
style = SEXP_CANONICAL;
else if (!strcmp(optarg, "advanced"))
style = SEXP_ADVANCED;
else if (!strcmp(optarg, "international"))
style = SEXP_INTERNATIONAL;
else
{
werror("lsh_keygen: Style must be one of\n"
" 'transport', 'canonical', 'advanced' or 'international'\n");
usage();
}
break;
case 'q':
quiet_flag = 1;
break;
case 'd':
debug_flag = 1;
break;
case 'v':
verbose_flag = 1;
break;
default:
usage();
}
if (argc != optind)
usage();
#endif
mpz_init(public.p);
mpz_init(public.q);
mpz_init(public.g);
......
......@@ -74,30 +74,6 @@
/* Block size for stdout and stderr buffers */
#define BLOCK_SIZE 32768
#if 0
void usage(void) NORETURN;
void usage(void)
{
werror("lshd [options]\n"
" -p, --port=PORT\n"
" -h, --hostkey=KEYFILE\n"
" -c, --crypto=ALGORITHM\n"
" -z, --compression[=ALGORITHM]\n"
" --mac=ALGORITHM\n"
" -q, --quiet\n"
#if WITH_TCP_FORWARD
" --no-forward\n"
#endif
#if WITH_SSH1_FALLBACK
" --ssh1-fallback=SSHD\n"
#endif
" -v, --verbose\n"
" --debug\n");
exit(1);
}
#endif
/* Option parsing */
......@@ -120,9 +96,10 @@ void usage(void)
(sshd1 object ssh1_fallback)))
*/
struct lshd_options *make_lshd_options(struct alist *algorithms)
static struct lshd_options *
make_lshd_options(struct alist *algorithms)
{
NEW(self, lshd_options);
NEW(lshd_options, self);
init_algorithms_options(&self->super, algorithms);
......@@ -226,6 +203,15 @@ main_argp_parser(int key, char *arg, struct argp_state *state)
return 0;
}
static const struct argp
main_argp =
{ main_options, main_argp_parser,
NULL,
"Server for the ssh-2 protocol.",
main_argp_children,
NULL
};
/* FIXME: We should have some more general functions for reading
* private keys. */
......@@ -405,21 +391,6 @@ static int read_host_key(const char *name,
int main(int argc, char **argv)
{
struct lshd_options *options;
#if 0
char *host = NULL; /* Interface to bind */
char *port = "ssh";
/* TODO: this should probably use sysconfdir */
char *hostkey = "/etc/lsh_host_key";
#if WITH_SSH1_FALLBACK
char *sshd1 = NULL;
#endif
#if WITH_TCP_FORWARD
int forward_flag = 1;
#endif
#endif
struct alist *keys;
......@@ -450,93 +421,8 @@ int main(int argc, char **argv)
-1);
options = make_lshd_options(algorithms);
argp_parse(&main_argp, argc, argv, options);
argp_parse(&main_argp, argc, argv, 0, NULL, options);
#if 0
for (;;)
{
struct option options[] =
{
{ "verbose", no_argument, NULL, 'v' },
{ "quiet", no_argument, NULL, 'q' },
{ "debug", no_argument, &debug_flag, 1},
{ "port", required_argument, NULL, 'p' },
{ "crypto", required_argument, NULL, 'c' },
{ "compression", optional_argument, NULL, 'z'},
{ "mac", required_argument, NULL, 'm' },
{ "hostkey", required_argument, NULL, 'h' },
#if WITH_TCP_FORWARD
{ "no-forward", no_argument, &forward_flag, 0 },
#endif
#if WITH_SSH1_FALLBACK
{ "ssh1-fallback", optional_argument, NULL, OPT_SSH1_FALLBACK},
#endif
{ NULL, 0, NULL, 0 }
};
option = getopt_long(argc, argv, "c:h:p:qvz::", options, NULL);
switch(option)
{
case -1:
goto options_done;
case 0:
break;
#if WITH_SSH1_FALLBACK
case OPT_SSH1_FALLBACK:
sshd1 = optarg ? optarg : SSHD1;
break;
#endif
case 'p':
port = optarg;
break;
case 'q':
quiet_flag = 1;
break;
case 'v':
verbose_flag = 1;
break;
case 'h':
hostkey = optarg;
break;
case 'c':
preferred_crypto = lookup_crypto(algorithms, optarg);
if (!preferred_crypto)
{
werror("lsh: Unknown crypto algorithm '%z'.\n", optarg);
exit(1);
}
break;
case 'z':
if (!optarg)
optarg = "zlib";
preferred_compression = lookup_compression(algorithms, optarg);
if (!preferred_compression)
{
werror("lsh: Unknown compression algorithm '%z'.\n", optarg);
exit(1);
}
break;
case 'm':
preferred_mac = lookup_mac(algorithms, optarg);
if (!preferred_mac)
{
werror("lsh: Unknown message authentication algorithm '%z'.\n",
optarg);
exit(1);
}
case '?':
usage();
}
}
options_done:
if ( (argc - optind) != 0)
usage();
#endif
/* Read the hostkey */
keys = make_alist(0, -1);
if (!read_host_key(options->hostkey, keys, r))
......@@ -587,9 +473,9 @@ int main(int argc, char **argv)
make_int_list(1, ATOM_DIFFIE_HELLMAN_GROUP1_SHA1,
-1),
make_int_list(1, ATOM_SSH_DSS, -1),
options->crypto_algorithms,
options->mac_algorithms,
options->compression_algorithms,
options->super.crypto_algorithms,
options->super.mac_algorithms,
options->super.compression_algorithms,
make_int_list(0, -1));
{
......@@ -648,7 +534,7 @@ int main(int argc, char **argv)
CAST_SUBTYPE(command, server_listen, o);
COMMAND_CALL(server_listen, local,
COMMAND_CALL(server_listen, options->local,
&discard_continuation, &default_exception_handler);
}
}
......
Supports Markdown
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