summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--atomicio.c8
-rw-r--r--channels.c19
-rw-r--r--clientloop.c12
-rw-r--r--defines.h6
-rw-r--r--includes.h2
-rw-r--r--packet.c8
-rw-r--r--scp.c2
-rw-r--r--serverloop.c14
-rw-r--r--sftp-client.c3
-rw-r--r--ssh-agent.c6
-rw-r--r--ssh-keyscan.c2
-rw-r--r--sshd.c3
13 files changed, 57 insertions, 37 deletions
diff --git a/ChangeLog b/ChangeLog
index c985a7ba5..984c17008 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,7 +30,12 @@
30 explicitly disable conch options that could interfere with the test 30 explicitly disable conch options that could interfere with the test
31 - (dtucker) [sftp-server.c] Bug #1447: fall back to racy rename if link 31 - (dtucker) [sftp-server.c] Bug #1447: fall back to racy rename if link
32 returns EXDEV. Patch from Mike Garrison, ok djm@ 32 returns EXDEV. Patch from Mike Garrison, ok djm@
33h 33 - (djm) [atomicio.c channels.c clientloop.c defines.h includes.h]
34 [packet.c scp.c serverloop.c sftp-client.c ssh-agent.c ssh-keyscan.c]
35 [sshd.c] Explicitly handle EWOULDBLOCK wherever we handle EAGAIN, on
36 some platforms (HP nonstop) it is a distinct errno;
37 bz#1467 reported by sconeu AT yahoo.com; ok dtucker@
38
3420080702 3920080702
35 - (dtucker) OpenBSD CVS Sync 40 - (dtucker) OpenBSD CVS Sync
36 - djm@cvs.openbsd.org 2008/06/30 08:05:59 41 - djm@cvs.openbsd.org 2008/06/30 08:05:59
@@ -4565,4 +4570,4 @@ h
4565 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4570 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4566 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4571 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4567 4572
4568$Id: ChangeLog,v 1.5057 2008/07/04 07:11:30 dtucker Exp $ 4573$Id: ChangeLog,v 1.5058 2008/07/04 13:10:49 djm Exp $
diff --git a/atomicio.c b/atomicio.c
index 575bf8900..bb44c3230 100644
--- a/atomicio.c
+++ b/atomicio.c
@@ -63,11 +63,7 @@ atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)
63 case -1: 63 case -1:
64 if (errno == EINTR) 64 if (errno == EINTR)
65 continue; 65 continue;
66#ifdef EWOULDBLOCK
67 if (errno == EAGAIN || errno == EWOULDBLOCK) { 66 if (errno == EAGAIN || errno == EWOULDBLOCK) {
68#else
69 if (errno == EAGAIN) {
70#endif
71 (void)poll(&pfd, 1, -1); 67 (void)poll(&pfd, 1, -1);
72 continue; 68 continue;
73 } 69 }
@@ -109,11 +105,7 @@ atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,
109 case -1: 105 case -1:
110 if (errno == EINTR) 106 if (errno == EINTR)
111 continue; 107 continue;
112#ifdef EWOULDBLOCK
113 if (errno == EAGAIN || errno == EWOULDBLOCK) { 108 if (errno == EAGAIN || errno == EWOULDBLOCK) {
114#else
115 if (errno == EAGAIN) {
116#endif
117 (void)poll(&pfd, 1, -1); 109 (void)poll(&pfd, 1, -1);
118 continue; 110 continue;
119 } 111 }
diff --git a/channels.c b/channels.c
index 7f0aaadf6..ac5134b5b 100644
--- a/channels.c
+++ b/channels.c
@@ -1494,7 +1494,8 @@ channel_handle_rfd(Channel *c, fd_set *readset, fd_set *writeset)
1494 if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) { 1494 if (c->rfd != -1 && (force || FD_ISSET(c->rfd, readset))) {
1495 errno = 0; 1495 errno = 0;
1496 len = read(c->rfd, buf, sizeof(buf)); 1496 len = read(c->rfd, buf, sizeof(buf));
1497 if (len < 0 && (errno == EINTR || (errno == EAGAIN && !force))) 1497 if (len < 0 && (errno == EINTR ||
1498 ((errno == EAGAIN || errno == EWOULDBLOCK) && !force)))
1498 return 1; 1499 return 1;
1499#ifndef PTY_ZEROREAD 1500#ifndef PTY_ZEROREAD
1500 if (len <= 0) { 1501 if (len <= 0) {
@@ -1565,7 +1566,8 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
1565 c->local_consumed += dlen + 4; 1566 c->local_consumed += dlen + 4;
1566 len = write(c->wfd, buf, dlen); 1567 len = write(c->wfd, buf, dlen);
1567 xfree(data); 1568 xfree(data);
1568 if (len < 0 && (errno == EINTR || errno == EAGAIN)) 1569 if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1570 errno == EWOULDBLOCK))
1569 return 1; 1571 return 1;
1570 if (len <= 0) { 1572 if (len <= 0) {
1571 if (c->type != SSH_CHANNEL_OPEN) 1573 if (c->type != SSH_CHANNEL_OPEN)
@@ -1583,7 +1585,8 @@ channel_handle_wfd(Channel *c, fd_set *readset, fd_set *writeset)
1583#endif 1585#endif
1584 1586
1585 len = write(c->wfd, buf, dlen); 1587 len = write(c->wfd, buf, dlen);
1586 if (len < 0 && (errno == EINTR || errno == EAGAIN)) 1588 if (len < 0 &&
1589 (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1587 return 1; 1590 return 1;
1588 if (len <= 0) { 1591 if (len <= 0) {
1589 if (c->type != SSH_CHANNEL_OPEN) { 1592 if (c->type != SSH_CHANNEL_OPEN) {
@@ -1635,7 +1638,8 @@ channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset)
1635 buffer_len(&c->extended)); 1638 buffer_len(&c->extended));
1636 debug2("channel %d: written %d to efd %d", 1639 debug2("channel %d: written %d to efd %d",
1637 c->self, len, c->efd); 1640 c->self, len, c->efd);
1638 if (len < 0 && (errno == EINTR || errno == EAGAIN)) 1641 if (len < 0 && (errno == EINTR || errno == EAGAIN ||
1642 errno == EWOULDBLOCK))
1639 return 1; 1643 return 1;
1640 if (len <= 0) { 1644 if (len <= 0) {
1641 debug2("channel %d: closing write-efd %d", 1645 debug2("channel %d: closing write-efd %d",
@@ -1650,8 +1654,8 @@ channel_handle_efd(Channel *c, fd_set *readset, fd_set *writeset)
1650 len = read(c->efd, buf, sizeof(buf)); 1654 len = read(c->efd, buf, sizeof(buf));
1651 debug2("channel %d: read %d from efd %d", 1655 debug2("channel %d: read %d from efd %d",
1652 c->self, len, c->efd); 1656 c->self, len, c->efd);
1653 if (len < 0 && (errno == EINTR || 1657 if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
1654 (errno == EAGAIN && !c->detach_close))) 1658 errno == EWOULDBLOCK) && !c->detach_close)))
1655 return 1; 1659 return 1;
1656 if (len <= 0) { 1660 if (len <= 0) {
1657 debug2("channel %d: closing read-efd %d", 1661 debug2("channel %d: closing read-efd %d",
@@ -1675,7 +1679,8 @@ channel_handle_ctl(Channel *c, fd_set *readset, fd_set *writeset)
1675 /* Monitor control fd to detect if the slave client exits */ 1679 /* Monitor control fd to detect if the slave client exits */
1676 if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) { 1680 if (c->ctl_fd != -1 && FD_ISSET(c->ctl_fd, readset)) {
1677 len = read(c->ctl_fd, buf, sizeof(buf)); 1681 len = read(c->ctl_fd, buf, sizeof(buf));
1678 if (len < 0 && (errno == EINTR || errno == EAGAIN)) 1682 if (len < 0 &&
1683 (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK))
1679 return 1; 1684 return 1;
1680 if (len <= 0) { 1685 if (len <= 0) {
1681 debug2("channel %d: ctl read<=0", c->self); 1686 debug2("channel %d: ctl read<=0", c->self);
diff --git a/clientloop.c b/clientloop.c
index 6dc870881..ba2f0b79e 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -663,7 +663,8 @@ client_process_net_input(fd_set *readset)
663 * There is a kernel bug on Solaris that causes select to 663 * There is a kernel bug on Solaris that causes select to
664 * sometimes wake up even though there is no data available. 664 * sometimes wake up even though there is no data available.
665 */ 665 */
666 if (len < 0 && (errno == EAGAIN || errno == EINTR)) 666 if (len < 0 &&
667 (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
667 len = 0; 668 len = 0;
668 669
669 if (len < 0) { 670 if (len < 0) {
@@ -1129,7 +1130,8 @@ client_process_input(fd_set *readset)
1129 if (FD_ISSET(fileno(stdin), readset)) { 1130 if (FD_ISSET(fileno(stdin), readset)) {
1130 /* Read as much as possible. */ 1131 /* Read as much as possible. */
1131 len = read(fileno(stdin), buf, sizeof(buf)); 1132 len = read(fileno(stdin), buf, sizeof(buf));
1132 if (len < 0 && (errno == EAGAIN || errno == EINTR)) 1133 if (len < 0 &&
1134 (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
1133 return; /* we'll try again later */ 1135 return; /* we'll try again later */
1134 if (len <= 0) { 1136 if (len <= 0) {
1135 /* 1137 /*
@@ -1186,7 +1188,8 @@ client_process_output(fd_set *writeset)
1186 len = write(fileno(stdout), buffer_ptr(&stdout_buffer), 1188 len = write(fileno(stdout), buffer_ptr(&stdout_buffer),
1187 buffer_len(&stdout_buffer)); 1189 buffer_len(&stdout_buffer));
1188 if (len <= 0) { 1190 if (len <= 0) {
1189 if (errno == EINTR || errno == EAGAIN) 1191 if (errno == EINTR || errno == EAGAIN ||
1192 errno == EWOULDBLOCK)
1190 len = 0; 1193 len = 0;
1191 else { 1194 else {
1192 /* 1195 /*
@@ -1210,7 +1213,8 @@ client_process_output(fd_set *writeset)
1210 len = write(fileno(stderr), buffer_ptr(&stderr_buffer), 1213 len = write(fileno(stderr), buffer_ptr(&stderr_buffer),
1211 buffer_len(&stderr_buffer)); 1214 buffer_len(&stderr_buffer));
1212 if (len <= 0) { 1215 if (len <= 0) {
1213 if (errno == EINTR || errno == EAGAIN) 1216 if (errno == EINTR || errno == EAGAIN ||
1217 errno == EWOULDBLOCK)
1214 len = 0; 1218 len = 0;
1215 else { 1219 else {
1216 /* 1220 /*
diff --git a/defines.h b/defines.h
index a2fda9969..a8203ebbb 100644
--- a/defines.h
+++ b/defines.h
@@ -25,7 +25,7 @@
25#ifndef _DEFINES_H 25#ifndef _DEFINES_H
26#define _DEFINES_H 26#define _DEFINES_H
27 27
28/* $Id: defines.h,v 1.150 2008/06/13 00:28:57 dtucker Exp $ */ 28/* $Id: defines.h,v 1.151 2008/07/04 13:10:49 djm Exp $ */
29 29
30 30
31/* Constants */ 31/* Constants */
@@ -734,4 +734,8 @@ struct winsize {
734# endif 734# endif
735#endif 735#endif
736 736
737#ifndef EWOULDBLOCK
738# define EWOULDBLOCK EAGAIN
739#endif
740
737#endif /* _DEFINES_H */ 741#endif /* _DEFINES_H */
diff --git a/includes.h b/includes.h
index 9fcf1b023..f1b47f666 100644
--- a/includes.h
+++ b/includes.h
@@ -149,6 +149,8 @@
149# include <sys/syslog.h> 149# include <sys/syslog.h>
150#endif 150#endif
151 151
152#include <errno.h>
153
152/* 154/*
153 * On HP-UX 11.11, shadow.h and prot.h provide conflicting declarations 155 * On HP-UX 11.11, shadow.h and prot.h provide conflicting declarations
154 * of getspnam when _INCLUDE__STDC__ is defined, so we unset it here. 156 * of getspnam when _INCLUDE__STDC__ is defined, so we unset it here.
diff --git a/packet.c b/packet.c
index 90ad5ff67..ff22be68f 100644
--- a/packet.c
+++ b/packet.c
@@ -956,7 +956,8 @@ packet_read_seqnr(u_int32_t *seqnr_p)
956 if ((ret = select(connection_in + 1, setp, NULL, 956 if ((ret = select(connection_in + 1, setp, NULL,
957 NULL, timeoutp)) >= 0) 957 NULL, timeoutp)) >= 0)
958 break; 958 break;
959 if (errno != EAGAIN && errno != EINTR) 959 if (errno != EAGAIN && errno != EINTR &&
960 errno != EWOULDBLOCK)
960 break; 961 break;
961 if (packet_timeout_ms == -1) 962 if (packet_timeout_ms == -1)
962 continue; 963 continue;
@@ -1475,7 +1476,7 @@ packet_write_poll(void)
1475 if (len > 0) { 1476 if (len > 0) {
1476 len = write(connection_out, buffer_ptr(&output), len); 1477 len = write(connection_out, buffer_ptr(&output), len);
1477 if (len <= 0) { 1478 if (len <= 0) {
1478 if (errno == EAGAIN) 1479 if (errno == EAGAIN || errno == EWOULDBLOCK)
1479 return; 1480 return;
1480 else 1481 else
1481 fatal("Write failed: %.100s", strerror(errno)); 1482 fatal("Write failed: %.100s", strerror(errno));
@@ -1516,7 +1517,8 @@ packet_write_wait(void)
1516 if ((ret = select(connection_out + 1, NULL, setp, 1517 if ((ret = select(connection_out + 1, NULL, setp,
1517 NULL, timeoutp)) >= 0) 1518 NULL, timeoutp)) >= 0)
1518 break; 1519 break;
1519 if (errno != EAGAIN && errno != EINTR) 1520 if (errno != EAGAIN && errno != EINTR &&
1521 errno != EWOULDBLOCK)
1520 break; 1522 break;
1521 if (packet_timeout_ms == -1) 1523 if (packet_timeout_ms == -1)
1522 continue; 1524 continue;
diff --git a/scp.c b/scp.c
index 46433a638..9f8b7a192 100644
--- a/scp.c
+++ b/scp.c
@@ -474,7 +474,7 @@ scpio(ssize_t (*f)(int, void *, size_t), int fd, void *_p, size_t l, off_t *c)
474 if (r < 0) { 474 if (r < 0) {
475 if (errno == EINTR) 475 if (errno == EINTR)
476 continue; 476 continue;
477 if (errno == EAGAIN) { 477 if (errno == EAGAIN || errno == EWOULDBLOCK) {
478 (void)poll(&pfd, 1, -1); /* Ignore errors */ 478 (void)poll(&pfd, 1, -1); /* Ignore errors */
479 continue; 479 continue;
480 } 480 }
diff --git a/serverloop.c b/serverloop.c
index bd6f82dc1..77d9dee75 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -400,7 +400,8 @@ process_input(fd_set *readset)
400 return; 400 return;
401 cleanup_exit(255); 401 cleanup_exit(255);
402 } else if (len < 0) { 402 } else if (len < 0) {
403 if (errno != EINTR && errno != EAGAIN) { 403 if (errno != EINTR && errno != EAGAIN &&
404 errno != EWOULDBLOCK) {
404 verbose("Read error from remote host " 405 verbose("Read error from remote host "
405 "%.100s: %.100s", 406 "%.100s: %.100s",
406 get_remote_ipaddr(), strerror(errno)); 407 get_remote_ipaddr(), strerror(errno));
@@ -418,8 +419,8 @@ process_input(fd_set *readset)
418 if (!fdout_eof && FD_ISSET(fdout, readset)) { 419 if (!fdout_eof && FD_ISSET(fdout, readset)) {
419 errno = 0; 420 errno = 0;
420 len = read(fdout, buf, sizeof(buf)); 421 len = read(fdout, buf, sizeof(buf));
421 if (len < 0 && (errno == EINTR || 422 if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
422 (errno == EAGAIN && !child_terminated))) { 423 errno == EWOULDBLOCK) && !child_terminated))) {
423 /* do nothing */ 424 /* do nothing */
424#ifndef PTY_ZEROREAD 425#ifndef PTY_ZEROREAD
425 } else if (len <= 0) { 426 } else if (len <= 0) {
@@ -437,8 +438,8 @@ process_input(fd_set *readset)
437 if (!fderr_eof && FD_ISSET(fderr, readset)) { 438 if (!fderr_eof && FD_ISSET(fderr, readset)) {
438 errno = 0; 439 errno = 0;
439 len = read(fderr, buf, sizeof(buf)); 440 len = read(fderr, buf, sizeof(buf));
440 if (len < 0 && (errno == EINTR || 441 if (len < 0 && (errno == EINTR || ((errno == EAGAIN ||
441 (errno == EAGAIN && !child_terminated))) { 442 errno == EWOULDBLOCK) && !child_terminated))) {
442 /* do nothing */ 443 /* do nothing */
443#ifndef PTY_ZEROREAD 444#ifndef PTY_ZEROREAD
444 } else if (len <= 0) { 445 } else if (len <= 0) {
@@ -469,7 +470,8 @@ process_output(fd_set *writeset)
469 data = buffer_ptr(&stdin_buffer); 470 data = buffer_ptr(&stdin_buffer);
470 dlen = buffer_len(&stdin_buffer); 471 dlen = buffer_len(&stdin_buffer);
471 len = write(fdin, data, dlen); 472 len = write(fdin, data, dlen);
472 if (len < 0 && (errno == EINTR || errno == EAGAIN)) { 473 if (len < 0 &&
474 (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)) {
473 /* do nothing */ 475 /* do nothing */
474 } else if (len <= 0) { 476 } else if (len <= 0) {
475 if (fdin != fdout) 477 if (fdin != fdout)
diff --git a/sftp-client.c b/sftp-client.c
index 42bf0c813..5e39aa7d2 100644
--- a/sftp-client.c
+++ b/sftp-client.c
@@ -1223,7 +1223,8 @@ do_upload(struct sftp_conn *conn, char *local_path, char *remote_path,
1223 len = 0; 1223 len = 0;
1224 else do 1224 else do
1225 len = read(local_fd, data, conn->transfer_buflen); 1225 len = read(local_fd, data, conn->transfer_buflen);
1226 while ((len == -1) && (errno == EINTR || errno == EAGAIN)); 1226 while ((len == -1) &&
1227 (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
1227 1228
1228 if (len == -1) 1229 if (len == -1)
1229 fatal("Couldn't read from \"%s\": %s", local_path, 1230 fatal("Couldn't read from \"%s\": %s", local_path,
diff --git a/ssh-agent.c b/ssh-agent.c
index b1c65fab6..9123cfe6b 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -961,7 +961,8 @@ after_select(fd_set *readset, fd_set *writeset)
961 buffer_ptr(&sockets[i].output), 961 buffer_ptr(&sockets[i].output),
962 buffer_len(&sockets[i].output)); 962 buffer_len(&sockets[i].output));
963 if (len == -1 && (errno == EAGAIN || 963 if (len == -1 && (errno == EAGAIN ||
964 errno == EINTR)) 964 errno == EINTR ||
965 errno == EWOULDBLOCK))
965 continue; 966 continue;
966 break; 967 break;
967 } while (1); 968 } while (1);
@@ -975,7 +976,8 @@ after_select(fd_set *readset, fd_set *writeset)
975 do { 976 do {
976 len = read(sockets[i].fd, buf, sizeof(buf)); 977 len = read(sockets[i].fd, buf, sizeof(buf));
977 if (len == -1 && (errno == EAGAIN || 978 if (len == -1 && (errno == EAGAIN ||
978 errno == EINTR)) 979 errno == EINTR ||
980 errno == EWOULDBLOCK))
979 continue; 981 continue;
980 break; 982 break;
981 } while (1); 983 } while (1);
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 304fcfde8..d81077764 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -656,7 +656,7 @@ conloop(void)
656 memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask)); 656 memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask));
657 657
658 while (select(maxfd, r, NULL, e, &seltime) == -1 && 658 while (select(maxfd, r, NULL, e, &seltime) == -1 &&
659 (errno == EAGAIN || errno == EINTR)) 659 (errno == EAGAIN || errno == EINTR || errno == EWOULDBLOCK))
660 ; 660 ;
661 661
662 for (i = 0; i < maxfd; i++) { 662 for (i = 0; i < maxfd; i++) {
diff --git a/sshd.c b/sshd.c
index c952f7ad2..a6620a05a 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1096,7 +1096,8 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
1096 *newsock = accept(listen_socks[i], 1096 *newsock = accept(listen_socks[i],
1097 (struct sockaddr *)&from, &fromlen); 1097 (struct sockaddr *)&from, &fromlen);
1098 if (*newsock < 0) { 1098 if (*newsock < 0) {
1099 if (errno != EINTR && errno != EWOULDBLOCK) 1099 if (errno != EINTR && errno != EAGAIN &&
1100 errno != EWOULDBLOCK)
1100 error("accept: %.100s", strerror(errno)); 1101 error("accept: %.100s", strerror(errno));
1101 continue; 1102 continue;
1102 } 1103 }