summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--channels.c6
-rw-r--r--clientloop.c4
-rw-r--r--misc.c34
-rw-r--r--misc.h6
-rw-r--r--packet.c11
-rw-r--r--ssh-agent.c5
-rw-r--r--ssh-keyscan.c6
-rw-r--r--sshd.c8
9 files changed, 45 insertions, 41 deletions
diff --git a/ChangeLog b/ChangeLog
index 36aeb85bb..d1d45db79 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,6 +29,10 @@
29 [readconf.h scp.1 sftp.1 ssh.1 ssh.c ssh_config.5] 29 [readconf.h scp.1 sftp.1 ssh.1 ssh.c ssh_config.5]
30 implement session multiplexing in the client (the server has supported 30 implement session multiplexing in the client (the server has supported
31 this since 2.0); ok markus@ 31 this since 2.0); ok markus@
32 - djm@cvs.openbsd.org 2004/06/14 01:44:39
33 [channels.c clientloop.c misc.c misc.h packet.c ssh-agent.c ssh-keyscan.c]
34 [sshd.c]
35 set_nonblock() instead of fnctl(...,O_NONBLOCK); "looks sane" deraadt@
32 36
3320040603 3720040603
34 - (dtucker) [auth-pam.c] Don't use pam_* namespace for sshd's PAM functions. 38 - (dtucker) [auth-pam.c] Don't use pam_* namespace for sshd's PAM functions.
@@ -1213,4 +1217,4 @@
1213 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 1217 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
1214 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 1218 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
1215 1219
1216$Id: ChangeLog,v 1.3382 2004/06/15 00:34:08 djm Exp $ 1220$Id: ChangeLog,v 1.3383 2004/06/15 00:35:30 djm Exp $
diff --git a/channels.c b/channels.c
index 1fb1092c8..97c1fd31b 100644
--- a/channels.c
+++ b/channels.c
@@ -39,7 +39,7 @@
39 */ 39 */
40 40
41#include "includes.h" 41#include "includes.h"
42RCSID("$OpenBSD: channels.c,v 1.204 2004/06/13 15:03:02 djm Exp $"); 42RCSID("$OpenBSD: channels.c,v 1.205 2004/06/14 01:44:38 djm Exp $");
43 43
44#include "ssh.h" 44#include "ssh.h"
45#include "ssh1.h" 45#include "ssh1.h"
@@ -2509,8 +2509,8 @@ connect_to(const char *host, u_short port)
2509 verbose("socket: %.100s", strerror(errno)); 2509 verbose("socket: %.100s", strerror(errno));
2510 continue; 2510 continue;
2511 } 2511 }
2512 if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0) 2512 if (set_nonblock(sock) == -1)
2513 fatal("connect_to: F_SETFL: %s", strerror(errno)); 2513 fatal("%s: set_nonblock(%d)", __func__, sock);
2514 if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0 && 2514 if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0 &&
2515 errno != EINPROGRESS) { 2515 errno != EINPROGRESS) {
2516 error("connect_to %.100s port %s: %.100s", ntop, strport, 2516 error("connect_to %.100s port %s: %.100s", ntop, strport,
diff --git a/clientloop.c b/clientloop.c
index 6401588a9..eada56033 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.123 2004/06/13 15:03:02 djm Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.124 2004/06/14 01:44:38 djm Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -167,7 +167,7 @@ static void
167enter_non_blocking(void) 167enter_non_blocking(void)
168{ 168{
169 in_non_blocking_mode = 1; 169 in_non_blocking_mode = 1;
170 (void) fcntl(fileno(stdin), F_SETFL, O_NONBLOCK); 170 set_nonblock(fileno(stdin));
171} 171}
172 172
173/* 173/*
diff --git a/misc.c b/misc.c
index 1f320353e..1c43bc007 100644
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: misc.c,v 1.23 2003/10/28 09:08:06 markus Exp $"); 26RCSID("$OpenBSD: misc.c,v 1.24 2004/06/14 01:44:39 djm Exp $");
27 27
28#include "misc.h" 28#include "misc.h"
29#include "log.h" 29#include "log.h"
@@ -46,7 +46,7 @@ chop(char *s)
46} 46}
47 47
48/* set/unset filedescriptor to non-blocking */ 48/* set/unset filedescriptor to non-blocking */
49void 49int
50set_nonblock(int fd) 50set_nonblock(int fd)
51{ 51{
52 int val; 52 int val;
@@ -54,20 +54,23 @@ set_nonblock(int fd)
54 val = fcntl(fd, F_GETFL, 0); 54 val = fcntl(fd, F_GETFL, 0);
55 if (val < 0) { 55 if (val < 0) {
56 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); 56 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
57 return; 57 return (-1);
58 } 58 }
59 if (val & O_NONBLOCK) { 59 if (val & O_NONBLOCK) {
60 debug2("fd %d is O_NONBLOCK", fd); 60 debug3("fd %d is O_NONBLOCK", fd);
61 return; 61 return (0);
62 } 62 }
63 debug2("fd %d setting O_NONBLOCK", fd); 63 debug2("fd %d setting O_NONBLOCK", fd);
64 val |= O_NONBLOCK; 64 val |= O_NONBLOCK;
65 if (fcntl(fd, F_SETFL, val) == -1) 65 if (fcntl(fd, F_SETFL, val) == -1) {
66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", 66 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd,
67 fd, strerror(errno)); 67 strerror(errno));
68 return (-1);
69 }
70 return (0);
68} 71}
69 72
70void 73int
71unset_nonblock(int fd) 74unset_nonblock(int fd)
72{ 75{
73 int val; 76 int val;
@@ -75,17 +78,20 @@ unset_nonblock(int fd)
75 val = fcntl(fd, F_GETFL, 0); 78 val = fcntl(fd, F_GETFL, 0);
76 if (val < 0) { 79 if (val < 0) {
77 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno)); 80 error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
78 return; 81 return (-1);
79 } 82 }
80 if (!(val & O_NONBLOCK)) { 83 if (!(val & O_NONBLOCK)) {
81 debug2("fd %d is not O_NONBLOCK", fd); 84 debug3("fd %d is not O_NONBLOCK", fd);
82 return; 85 return (0);
83 } 86 }
84 debug("fd %d clearing O_NONBLOCK", fd); 87 debug("fd %d clearing O_NONBLOCK", fd);
85 val &= ~O_NONBLOCK; 88 val &= ~O_NONBLOCK;
86 if (fcntl(fd, F_SETFL, val) == -1) 89 if (fcntl(fd, F_SETFL, val) == -1) {
87 debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", 90 debug("fcntl(%d, F_SETFL, ~O_NONBLOCK): %s",
88 fd, strerror(errno)); 91 fd, strerror(errno));
92 return (-1);
93 }
94 return (0);
89} 95}
90 96
91/* disable nagle on socket */ 97/* disable nagle on socket */
diff --git a/misc.h b/misc.h
index d4a23cba3..6a4eff136 100644
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: misc.h,v 1.14 2004/05/08 00:21:31 djm Exp $ */ 1/* $OpenBSD: misc.h,v 1.15 2004/06/14 01:44:39 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -16,8 +16,8 @@
16 16
17char *chop(char *); 17char *chop(char *);
18char *strdelim(char **); 18char *strdelim(char **);
19void set_nonblock(int); 19int set_nonblock(int);
20void unset_nonblock(int); 20int unset_nonblock(int);
21void set_nodelay(int); 21void set_nodelay(int);
22int a2port(const char *); 22int a2port(const char *);
23char *cleanhostname(char *); 23char *cleanhostname(char *);
diff --git a/packet.c b/packet.c
index fe3eea094..fca0075e7 100644
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
37 */ 37 */
38 38
39#include "includes.h" 39#include "includes.h"
40RCSID("$OpenBSD: packet.c,v 1.113 2004/05/11 19:01:43 deraadt Exp $"); 40RCSID("$OpenBSD: packet.c,v 1.114 2004/06/14 01:44:39 djm Exp $");
41 41
42#include "openbsd-compat/sys-queue.h" 42#include "openbsd-compat/sys-queue.h"
43 43
@@ -319,13 +319,10 @@ void
319packet_set_nonblocking(void) 319packet_set_nonblocking(void)
320{ 320{
321 /* Set the socket into non-blocking mode. */ 321 /* Set the socket into non-blocking mode. */
322 if (fcntl(connection_in, F_SETFL, O_NONBLOCK) < 0) 322 set_nonblock(connection_in);
323 error("fcntl O_NONBLOCK: %.100s", strerror(errno));
324 323
325 if (connection_out != connection_in) { 324 if (connection_out != connection_in)
326 if (fcntl(connection_out, F_SETFL, O_NONBLOCK) < 0) 325 set_nonblock(connection_out);
327 error("fcntl O_NONBLOCK: %.100s", strerror(errno));
328 }
329} 326}
330 327
331/* Returns the socket used for reading. */ 328/* Returns the socket used for reading. */
diff --git a/ssh-agent.c b/ssh-agent.c
index a38322160..ea84f2196 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -35,7 +35,7 @@
35 35
36#include "includes.h" 36#include "includes.h"
37#include "openbsd-compat/sys-queue.h" 37#include "openbsd-compat/sys-queue.h"
38RCSID("$OpenBSD: ssh-agent.c,v 1.118 2004/05/08 00:21:31 djm Exp $"); 38RCSID("$OpenBSD: ssh-agent.c,v 1.119 2004/06/14 01:44:39 djm Exp $");
39 39
40#include <openssl/evp.h> 40#include <openssl/evp.h>
41#include <openssl/md5.h> 41#include <openssl/md5.h>
@@ -789,8 +789,7 @@ new_socket(sock_type type, int fd)
789{ 789{
790 u_int i, old_alloc, new_alloc; 790 u_int i, old_alloc, new_alloc;
791 791
792 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) 792 set_nonblock(fd);
793 error("fcntl O_NONBLOCK: %s", strerror(errno));
794 793
795 if (fd > max_fd) 794 if (fd > max_fd)
796 max_fd = fd; 795 max_fd = fd;
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index c4a2414b1..01615b5c3 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -7,7 +7,7 @@
7 */ 7 */
8 8
9#include "includes.h" 9#include "includes.h"
10RCSID("$OpenBSD: ssh-keyscan.c,v 1.48 2004/06/13 12:53:24 djm Exp $"); 10RCSID("$OpenBSD: ssh-keyscan.c,v 1.49 2004/06/14 01:44:39 djm Exp $");
11 11
12#include "openbsd-compat/sys-queue.h" 12#include "openbsd-compat/sys-queue.h"
13 13
@@ -397,8 +397,8 @@ tcpconnect(char *host)
397 error("socket: %s", strerror(errno)); 397 error("socket: %s", strerror(errno));
398 continue; 398 continue;
399 } 399 }
400 if (fcntl(s, F_SETFL, O_NONBLOCK) < 0) 400 if (set_nonblock(s) == -1)
401 fatal("F_SETFL: %s", strerror(errno)); 401 fatal("%s: set_nonblock(%d)", __func__, s);
402 if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 && 402 if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 &&
403 errno != EINPROGRESS) 403 errno != EINPROGRESS)
404 error("connect (`%s'): %s", host, strerror(errno)); 404 error("connect (`%s'): %s", host, strerror(errno));
diff --git a/sshd.c b/sshd.c
index 5f3878119..34379172f 100644
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
42 */ 42 */
43 43
44#include "includes.h" 44#include "includes.h"
45RCSID("$OpenBSD: sshd.c,v 1.292 2004/06/13 12:53:24 djm Exp $"); 45RCSID("$OpenBSD: sshd.c,v 1.293 2004/06/14 01:44:39 djm Exp $");
46 46
47#include <openssl/dh.h> 47#include <openssl/dh.h>
48#include <openssl/bn.h> 48#include <openssl/bn.h>
@@ -1140,8 +1140,7 @@ main(int ac, char **av)
1140 verbose("socket: %.100s", strerror(errno)); 1140 verbose("socket: %.100s", strerror(errno));
1141 continue; 1141 continue;
1142 } 1142 }
1143 if (fcntl(listen_sock, F_SETFL, O_NONBLOCK) < 0) { 1143 if (set_nonblock(listen_sock) == -1) {
1144 error("listen_sock O_NONBLOCK: %s", strerror(errno));
1145 close(listen_sock); 1144 close(listen_sock);
1146 continue; 1145 continue;
1147 } 1146 }
@@ -1284,8 +1283,7 @@ main(int ac, char **av)
1284 error("accept: %.100s", strerror(errno)); 1283 error("accept: %.100s", strerror(errno));
1285 continue; 1284 continue;
1286 } 1285 }
1287 if (fcntl(newsock, F_SETFL, 0) < 0) { 1286 if (unset_nonblock(newsock) == -1) {
1288 error("newsock del O_NONBLOCK: %s", strerror(errno));
1289 close(newsock); 1287 close(newsock);
1290 continue; 1288 continue;
1291 } 1289 }