summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2006-06-23 21:24:12 +1000
committerDarren Tucker <dtucker@zip.com.au>2006-06-23 21:24:12 +1000
commit9afe115f0ac738204d4edb66b9353a765826ae46 (patch)
treed7ba646ed3ae0c4ff86e95542fa4174f6d43f45d
parent3eb4834489426bd796da90299b2f8174b744dddd (diff)
- (dtucker) [channels.c configure.ac serverloop.c] Bug #1102: Around AIX
4.3.3 ML3 or so, the AIX pty layer starting passing zero-length writes on the pty slave as zero-length reads on the pty master, which sshd interprets as the descriptor closing. Since most things don't do zero length writes this rarely matters, but occasionally it happens, and when it does the SSH pty session appears to hang, so we add a special case for this condition. ok djm@
-rw-r--r--ChangeLog9
-rw-r--r--channels.c5
-rw-r--r--configure.ac5
-rw-r--r--serverloop.c10
4 files changed, 26 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 327fec1d6..dfaa46795 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,13 @@
2 - (dtucker) [README.platform configure.ac openbsd-compat/port-tun.c] Add 2 - (dtucker) [README.platform configure.ac openbsd-compat/port-tun.c] Add
3 tunnel support for Mac OS X/Darwin via a third-party tun driver. Patch 3 tunnel support for Mac OS X/Darwin via a third-party tun driver. Patch
4 from reyk@, tested by anil@ 4 from reyk@, tested by anil@
5 - (dtucker) [channels.c configure.ac serverloop.c] Bug #1102: Around AIX
6 4.3.3 ML3 or so, the AIX pty layer starting passing zero-length writes
7 on the pty slave as zero-length reads on the pty master, which sshd
8 interprets as the descriptor closing. Since most things don't do zero
9 length writes this rarely matters, but occasionally it happens, and when
10 it does the SSH pty session appears to hang, so we add a special case for
11 this condition. ok djm@
5 12
620060613 1320060613
7 - (djm) [getput.h] This file has been replaced by functions in misc.c 14 - (djm) [getput.h] This file has been replaced by functions in misc.c
@@ -4690,4 +4697,4 @@
4690 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 4697 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
4691 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 4698 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
4692 4699
4693$Id: ChangeLog,v 1.4345 2006/06/23 11:05:12 dtucker Exp $ 4700$Id: ChangeLog,v 1.4346 2006/06/23 11:24:12 dtucker Exp $
diff --git a/channels.c b/channels.c
index 2fa997edc..239e9dd83 100644
--- a/channels.c
+++ b/channels.c
@@ -1415,10 +1415,15 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset)
1415 1415
1416 if (c->rfd != -1 && 1416 if (c->rfd != -1 &&
1417 FD_ISSET(c->rfd, readset)) { 1417 FD_ISSET(c->rfd, readset)) {
1418 errno = 0;
1418 len = read(c->rfd, buf, sizeof(buf)); 1419 len = read(c->rfd, buf, sizeof(buf));
1419 if (len < 0 && (errno == EINTR || errno == EAGAIN)) 1420 if (len < 0 && (errno == EINTR || errno == EAGAIN))
1420 return 1; 1421 return 1;
1422#ifndef PTY_ZEROREAD
1421 if (len <= 0) { 1423 if (len <= 0) {
1424#else
1425 if (len < 0 || (len == 0 && errno != 0)) {
1426#endif
1422 debug2("channel %d: read<=0 rfd %d len %d", 1427 debug2("channel %d: read<=0 rfd %d len %d",
1423 c->self, c->rfd, len); 1428 c->self, c->rfd, len);
1424 if (c->type != SSH_CHANNEL_OPEN) { 1429 if (c->type != SSH_CHANNEL_OPEN) {
diff --git a/configure.ac b/configure.ac
index c3cb68f28..259b5c288 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.340 2006/06/23 11:05:13 dtucker Exp $ 1# $Id: configure.ac,v 1.341 2006/06/23 11:24:13 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) 17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18AC_REVISION($Revision: 1.340 $) 18AC_REVISION($Revision: 1.341 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20 20
21AC_CONFIG_HEADER(config.h) 21AC_CONFIG_HEADER(config.h)
@@ -190,6 +190,7 @@ case "$host" in
190 supported by bsd-setproctitle.c]) 190 supported by bsd-setproctitle.c])
191 AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID, 1, 191 AC_DEFINE(SSHPAM_CHAUTHTOK_NEEDS_RUID, 1,
192 [AIX 5.2 and 5.3 (and presumably newer) require this]) 192 [AIX 5.2 and 5.3 (and presumably newer) require this])
193 AC_DEFINE(PTY_ZEROREAD, 1, [read(1) can return 0 for a non-closed fd])
193 ;; 194 ;;
194*-*-cygwin*) 195*-*-cygwin*)
195 check_for_libcrypt_later=1 196 check_for_libcrypt_later=1
diff --git a/serverloop.c b/serverloop.c
index 021ba68c0..c1eb28853 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -387,10 +387,15 @@ process_input(fd_set *readset)
387 387
388 /* Read and buffer any available stdout data from the program. */ 388 /* Read and buffer any available stdout data from the program. */
389 if (!fdout_eof && FD_ISSET(fdout, readset)) { 389 if (!fdout_eof && FD_ISSET(fdout, readset)) {
390 errno = 0;
390 len = read(fdout, buf, sizeof(buf)); 391 len = read(fdout, buf, sizeof(buf));
391 if (len < 0 && (errno == EINTR || errno == EAGAIN)) { 392 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
392 /* do nothing */ 393 /* do nothing */
394#ifdef PTY_ZEROREAD
393 } else if (len <= 0) { 395 } else if (len <= 0) {
396#else
397 } else if (len < 0 || (len == 0 && errno != 0)) {
398#endif
394 fdout_eof = 1; 399 fdout_eof = 1;
395 } else { 400 } else {
396 buffer_append(&stdout_buffer, buf, len); 401 buffer_append(&stdout_buffer, buf, len);
@@ -399,10 +404,15 @@ process_input(fd_set *readset)
399 } 404 }
400 /* Read and buffer any available stderr data from the program. */ 405 /* Read and buffer any available stderr data from the program. */
401 if (!fderr_eof && FD_ISSET(fderr, readset)) { 406 if (!fderr_eof && FD_ISSET(fderr, readset)) {
407 errno = 0;
402 len = read(fderr, buf, sizeof(buf)); 408 len = read(fderr, buf, sizeof(buf));
403 if (len < 0 && (errno == EINTR || errno == EAGAIN)) { 409 if (len < 0 && (errno == EINTR || errno == EAGAIN)) {
404 /* do nothing */ 410 /* do nothing */
411#ifdef PTY_ZEROREAD
405 } else if (len <= 0) { 412 } else if (len <= 0) {
413#else
414 } else if (len < 0 || (len == 0 && errno != 0)) {
415#endif
406 fderr_eof = 1; 416 fderr_eof = 1;
407 } else { 417 } else {
408 buffer_append(&stderr_buffer, buf, len); 418 buffer_append(&stderr_buffer, buf, len);