]> andersk Git - openssh.git/blobdiff - serverloop.c
- millert@cvs.openbsd.org 2001/03/04 17:42:28
[openssh.git] / serverloop.c
index c8187ab20ed6d2103e922ceaf7d99ea8a61a3dfd..8b1ee99190cb82a12fa8164454f18facc62ed181 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.46 2001/02/08 19:30:52 itojun Exp $");
+RCSID("$OpenBSD: serverloop.c,v 1.54 2001/03/04 01:46:30 djm 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"
@@ -70,6 +70,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 +245,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);
@@ -317,6 +318,7 @@ process_input(fd_set * readset)
 void
 process_output(fd_set * writeset)
 {
+       struct termios tio;
        int len;
 
        /* Write buffered data to program stdin. */
@@ -336,7 +338,17 @@ process_output(fd_set * writeset)
 #endif
                        fdin = -1;
                } else {
-                       /* Successful write.  Consume the data from the buffer. */
+                       /* Successful write. */
+                       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. */
                        buffer_consume(&stdin_buffer, len);
                        /* Update the count of bytes written to the program. */
                        stdin_bytes += len;
@@ -422,6 +434,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();
 
This page took 0.033982 seconds and 4 git commands to generate.