* called by a name other than "ssh" or "Secure Shell".
*
* SSH2 support by Markus Friedl.
- * Copyright (c) 2000 Markus Friedl. All rights reserved.
+ * Copyright (c) 2000 Markus Friedl. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
*/
#include "includes.h"
-RCSID("$OpenBSD: serverloop.c,v 1.47 2001/02/08 23:11:42 dugsong Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.56 2001/04/04 14:34:58 markus Exp $");
#include "xmalloc.h"
#include "packet.h"
#include "buffer.h"
#include "log.h"
#include "servconf.h"
-#include "pty.h"
+#include "sshpty.h"
#include "channels.h"
#include "compat.h"
#include "ssh1.h"
#include "auth-options.h"
#include "serverloop.h"
#include "misc.h"
+#include "kex.h"
extern ServerOptions options;
+/* XXX */
+extern Kex *xxx_kex;
+
static Buffer stdin_buffer; /* Buffer for stdin data. */
static Buffer stdout_buffer; /* Buffer for stdout data. */
static Buffer stderr_buffer; /* Buffer for stderr data. */
static int stdin_eof = 0; /* EOF message received from client. */
static int fdout_eof = 0; /* EOF encountered reading from fdout. */
static int fderr_eof = 0; /* EOF encountered readung from fderr. */
+static int fdin_is_tty = 0; /* fdin points to a tty. */
static int connection_in; /* Connection to client (input). */
static int connection_out; /* Connection to client (output). */
static u_int buffer_high;/* "Soft" max buffer size. */
tvp = &tv;
}
if (tvp!=NULL)
- debug2("tvp!=NULL kid %d mili %d", child_terminated, max_time_milliseconds);
+ debug3("tvp!=NULL kid %d mili %d", child_terminated, max_time_milliseconds);
/* Wait for something to happen, or the timeout to expire. */
ret = select((*maxfdp)+1, *readsetp, *writesetp, NULL, tvp);
fdin = -1;
} else {
/* Successful write. */
- if (tcgetattr(fdin, &tio) == 0 &&
- !(tio.c_lflag & ECHO)) {
- /* Simulate echo to reduce the impact of traffic analysis. */
- packet_start(SSH_MSG_IGNORE);
- memset(buffer_ptr(&stdin_buffer), 0, len);
- packet_put_string(buffer_ptr(&stdin_buffer), len);
+ if (fdin_is_tty && tcgetattr(fdin, &tio) == 0 &&
+ !(tio.c_lflag & ECHO) && (tio.c_lflag & ICANON)) {
+ /*
+ * Simulate echo to reduce the impact of
+ * traffic analysis
+ */
+ packet_send_ignore(len);
packet_send();
}
/* Consume the data from the buffer. */
void
process_buffered_input_packets(void)
{
- dispatch_run(DISPATCH_NONBLOCK, NULL, NULL);
+ dispatch_run(DISPATCH_NONBLOCK, NULL, compat20 ? xxx_kex : NULL);
}
/*
child_pid = pid;
child_terminated = 0;
signal(SIGCHLD, sigchld_handler);
- signal(SIGPIPE, SIG_IGN);
/* Initialize our global variables. */
fdin = fdin_arg;
if (fderr != -1)
set_nonblock(fderr);
+ if (!(datafellows & SSH_BUG_IGNOREMSG) && isatty(fdin))
+ fdin_is_tty = 1;
+
connection_in = packet_get_connection_in();
connection_out = packet_get_connection_out();
debug("Entering interactive session for SSH2.");
mysignal(SIGCHLD, sigchld_handler2);
- signal(SIGPIPE, SIG_IGN);
child_terminated = 0;
connection_in = packet_get_connection_in();
connection_out = packet_get_connection_out();
originator, originator_port, target, target_port);
/* XXX check permission */
- if (no_port_forwarding_flag || !options.allow_tcp_forwarding) {
- xfree(target);
- xfree(originator);
- return NULL;
- }
sock = channel_connect_to(target, target_port);
xfree(target);
xfree(originator);
want_reply = packet_get_char();
debug("server_input_global_request: rtype %s want_reply %d", rtype, want_reply);
+ /* -R style forwarding */
if (strcmp(rtype, "tcpip-forward") == 0) {
struct passwd *pw;
char *listen_address;
dispatch_set(SSH2_MSG_CHANNEL_REQUEST, &channel_input_channel_request);
dispatch_set(SSH2_MSG_CHANNEL_WINDOW_ADJUST, &channel_input_window_adjust);
dispatch_set(SSH2_MSG_GLOBAL_REQUEST, &server_input_global_request);
+
+ /* rekeying */
+ dispatch_set(SSH2_MSG_KEXINIT, &kex_input_kexinit);
}
void
server_init_dispatch_13(void)