openssh 7.2p2: tty sometimes left in raw mode after a connection timeout

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



I'm running FreeBSD 9 and openssh 7.2p2:

    ice 1040 % uname -a
    FreeBSD ice.ee.lbl.gov 9.3-RELEASE FreeBSD 9.3-RELEASE #1 r21: Fri
Mar  4 10:42:36 PST 2016     leres@xxxxxxxxxxxxxx:/sys/amd64/compile/LBL
 amd64
    ice 1041 % ssh -V
    OpenSSH_7.2p2, OpenSSL 1.0.2g  1 Mar 2016

Occasionally when a connection times out, ssh leaves my shell in raw mode:

    packet_write_wait: Connection to UNKNOWN port 0: Broken pipe
    tcsetattr: Interrupted system call

I think the problem is that a signal can interrupt tcsetattr() in
leave_raw_mode() causing it to fail with EINTR. When this happens, the
terminal is left in raw mode.

The attached (untested) patch retries the tcsetattr() if it fails with
EINTR.

		Craig
--- sshtty.c.orig	2016-04-22 11:02:05.000000000 -0700
+++ sshtty.c	2016-04-22 11:12:58.000000000 -0700
@@ -41,6 +41,7 @@
 #include <stdio.h>
 #include <termios.h>
 #include <pwd.h>
+#include <errno.h>
 
 #include "sshpty.h"
 
@@ -58,11 +59,14 @@
 {
 	if (!_in_raw_mode)
 		return;
-	if (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) {
+	while (tcsetattr(fileno(stdin), TCSADRAIN, &_saved_tio) == -1) {
 		if (!quiet)
 			perror("tcsetattr");
-	} else
-		_in_raw_mode = 0;
+		if (errno == EINTR)
+			continue;
+		return;
+	}
+	_in_raw_mode = 0;
 }
 
 void
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux