]> andersk Git - openssh.git/blobdiff - serverloop.c
- markus@cvs.openbsd.org 2001/04/04 14:34:58
[openssh.git] / serverloop.c
index 8fc94db4501a603a4adcf0f7e6853c4d9403fa00..4ae02fd1007d28ddb238a4e5fe1e37f339e637c7 100644 (file)
@@ -11,7 +11,7 @@
  * 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"
@@ -53,9 +53,13 @@ RCSID("$OpenBSD: serverloop.c,v 1.47 2001/02/08 23:11:42 dugsong Exp $");
 #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. */
@@ -70,6 +74,7 @@ static long fdout_bytes = 0;  /* Number of stdout bytes read from program. */
 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. */
@@ -244,7 +249,7 @@ retry_select:
                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);
@@ -338,12 +343,13 @@ process_output(fd_set * writeset)
                        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. */
@@ -389,7 +395,7 @@ drain_output(void)
 void
 process_buffered_input_packets(void)
 {
-       dispatch_run(DISPATCH_NONBLOCK, NULL, NULL);
+       dispatch_run(DISPATCH_NONBLOCK, NULL, compat20 ? xxx_kex : NULL);
 }
 
 /*
@@ -418,7 +424,6 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_arg)
        child_pid = pid;
        child_terminated = 0;
        signal(SIGCHLD, sigchld_handler);
-       signal(SIGPIPE, SIG_IGN);
 
        /* Initialize our global variables. */
        fdin = fdin_arg;
@@ -432,6 +437,9 @@ server_loop(pid_t pid, int fdin_arg, int fdout_arg, int fderr_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();
 
@@ -650,7 +658,6 @@ server_loop2(void)
        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();
@@ -751,11 +758,6 @@ server_request_direct_tcpip(char *ctype)
           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);
@@ -853,6 +855,7 @@ server_input_global_request(int type, int plen, void *ctxt)
        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;
@@ -906,6 +909,9 @@ server_init_dispatch_20(void)
        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)
This page took 0.304836 seconds and 4 git commands to generate.