]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2004/06/14 01:44:39
authordjm <djm>
Tue, 15 Jun 2004 00:35:30 +0000 (00:35 +0000)
committerdjm <djm>
Tue, 15 Jun 2004 00:35:30 +0000 (00:35 +0000)
     [channels.c clientloop.c misc.c misc.h packet.c ssh-agent.c ssh-keyscan.c]
     [sshd.c]
     set_nonblock() instead of fnctl(...,O_NONBLOCK); "looks sane" deraadt@

ChangeLog
channels.c
clientloop.c
misc.c
misc.h
packet.c
ssh-agent.c
ssh-keyscan.c
sshd.c

index b8cafaa78e626d4a4a8d247b297237b36e0fef4a..1f6222c64631bde693cf8da52aad2558e025b1a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      [readconf.h scp.1 sftp.1 ssh.1 ssh.c ssh_config.5]
      implement session multiplexing in the client (the server has supported 
      this since 2.0); ok markus@
+   - djm@cvs.openbsd.org 2004/06/14 01:44:39
+     [channels.c clientloop.c misc.c misc.h packet.c ssh-agent.c ssh-keyscan.c]
+     [sshd.c]
+     set_nonblock() instead of fnctl(...,O_NONBLOCK); "looks sane" deraadt@
 
 20040603
  - (dtucker) [auth-pam.c] Don't use pam_* namespace for sshd's PAM functions.
index 1fb1092c87aee1dc9a82247ac39f35364a64e975..97c1fd31b948b51ba470585812bdc63a9832aed0 100644 (file)
@@ -39,7 +39,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: channels.c,v 1.204 2004/06/13 15:03:02 djm Exp $");
+RCSID("$OpenBSD: channels.c,v 1.205 2004/06/14 01:44:38 djm Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -2509,8 +2509,8 @@ connect_to(const char *host, u_short port)
                                verbose("socket: %.100s", strerror(errno));
                        continue;
                }
-               if (fcntl(sock, F_SETFL, O_NONBLOCK) < 0)
-                       fatal("connect_to: F_SETFL: %s", strerror(errno));
+               if (set_nonblock(sock) == -1)
+                       fatal("%s: set_nonblock(%d)", __func__, sock);
                if (connect(sock, ai->ai_addr, ai->ai_addrlen) < 0 &&
                    errno != EINPROGRESS) {
                        error("connect_to %.100s port %s: %.100s", ntop, strport,
index 6401588a92cd170bd8955408ad97ae440dd929fa..eada56033a17f771863a3bfb8979469d85847f3e 100644 (file)
@@ -59,7 +59,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: clientloop.c,v 1.123 2004/06/13 15:03:02 djm Exp $");
+RCSID("$OpenBSD: clientloop.c,v 1.124 2004/06/14 01:44:38 djm Exp $");
 
 #include "ssh.h"
 #include "ssh1.h"
@@ -167,7 +167,7 @@ static void
 enter_non_blocking(void)
 {
        in_non_blocking_mode = 1;
-       (void) fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
+       set_nonblock(fileno(stdin));
 }
 
 /*
diff --git a/misc.c b/misc.c
index 1f320353ef16a9803ba4dd53f9ba722b491c42ce..1c43bc007d7c01904bbe875e3814ef2061adb1c0 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -23,7 +23,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: misc.c,v 1.23 2003/10/28 09:08:06 markus Exp $");
+RCSID("$OpenBSD: misc.c,v 1.24 2004/06/14 01:44:39 djm Exp $");
 
 #include "misc.h"
 #include "log.h"
@@ -46,7 +46,7 @@ chop(char *s)
 }
 
 /* set/unset filedescriptor to non-blocking */
-void
+int
 set_nonblock(int fd)
 {
        int val;
@@ -54,20 +54,23 @@ set_nonblock(int fd)
        val = fcntl(fd, F_GETFL, 0);
        if (val < 0) {
                error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
-               return;
+               return (-1);
        }
        if (val & O_NONBLOCK) {
-               debug2("fd %d is O_NONBLOCK", fd);
-               return;
+               debug3("fd %d is O_NONBLOCK", fd);
+               return (0);
        }
        debug2("fd %d setting O_NONBLOCK", fd);
        val |= O_NONBLOCK;
-       if (fcntl(fd, F_SETFL, val) == -1)
-               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
-                   fd, strerror(errno));
+       if (fcntl(fd, F_SETFL, val) == -1) {
+               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s", fd,
+                   strerror(errno));
+               return (-1);
+       }
+       return (0);
 }
 
-void
+int
 unset_nonblock(int fd)
 {
        int val;
@@ -75,17 +78,20 @@ unset_nonblock(int fd)
        val = fcntl(fd, F_GETFL, 0);
        if (val < 0) {
                error("fcntl(%d, F_GETFL, 0): %s", fd, strerror(errno));
-               return;
+               return (-1);
        }
        if (!(val & O_NONBLOCK)) {
-               debug2("fd %d is not O_NONBLOCK", fd);
-               return;
+               debug3("fd %d is not O_NONBLOCK", fd);
+               return (0);
        }
        debug("fd %d clearing O_NONBLOCK", fd);
        val &= ~O_NONBLOCK;
-       if (fcntl(fd, F_SETFL, val) == -1)
-               debug("fcntl(%d, F_SETFL, O_NONBLOCK): %s",
+       if (fcntl(fd, F_SETFL, val) == -1) {
+               debug("fcntl(%d, F_SETFL, ~O_NONBLOCK): %s",
                    fd, strerror(errno));
+               return (-1);
+       }
+       return (0);
 }
 
 /* disable nagle on socket */
diff --git a/misc.h b/misc.h
index d4a23cba317b30f0a1b0a9340d92e2fdf98b82eb..6a4eff1369722f0490acb44196ad5bb699da40cf 100644 (file)
--- a/misc.h
+++ b/misc.h
@@ -1,4 +1,4 @@
-/*     $OpenBSD: misc.h,v 1.14 2004/05/08 00:21:31 djm Exp $   */
+/*     $OpenBSD: misc.h,v 1.15 2004/06/14 01:44:39 djm Exp $   */
 
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -16,8 +16,8 @@
 
 char   *chop(char *);
 char   *strdelim(char **);
-void    set_nonblock(int);
-void    unset_nonblock(int);
+int     set_nonblock(int);
+int     unset_nonblock(int);
 void    set_nodelay(int);
 int     a2port(const char *);
 char   *cleanhostname(char *);
index fe3eea0944fa6c286bfb8c2b279d945ae8631c89..fca0075e77fab249140ae2f6592696dc8ebfc908 100644 (file)
--- a/packet.c
+++ b/packet.c
@@ -37,7 +37,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: packet.c,v 1.113 2004/05/11 19:01:43 deraadt Exp $");
+RCSID("$OpenBSD: packet.c,v 1.114 2004/06/14 01:44:39 djm Exp $");
 
 #include "openbsd-compat/sys-queue.h"
 
@@ -319,13 +319,10 @@ void
 packet_set_nonblocking(void)
 {
        /* Set the socket into non-blocking mode. */
-       if (fcntl(connection_in, F_SETFL, O_NONBLOCK) < 0)
-               error("fcntl O_NONBLOCK: %.100s", strerror(errno));
+       set_nonblock(connection_in);
 
-       if (connection_out != connection_in) {
-               if (fcntl(connection_out, F_SETFL, O_NONBLOCK) < 0)
-                       error("fcntl O_NONBLOCK: %.100s", strerror(errno));
-       }
+       if (connection_out != connection_in)
+               set_nonblock(connection_out);
 }
 
 /* Returns the socket used for reading. */
index a383221604a650a5f92418b192a1b2889b378a5b..ea84f21965a670e186f5b3e202c8aef13f6d9cef 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "includes.h"
 #include "openbsd-compat/sys-queue.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.118 2004/05/08 00:21:31 djm Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.119 2004/06/14 01:44:39 djm Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/md5.h>
@@ -789,8 +789,7 @@ new_socket(sock_type type, int fd)
 {
        u_int i, old_alloc, new_alloc;
 
-       if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
-               error("fcntl O_NONBLOCK: %s", strerror(errno));
+       set_nonblock(fd);
 
        if (fd > max_fd)
                max_fd = fd;
index c4a2414b17b483c6415dd92ce652e8b63da770b9..01615b5c379504fe993b67cbdb07c55e0da6a180 100644 (file)
@@ -7,7 +7,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keyscan.c,v 1.48 2004/06/13 12:53:24 djm Exp $");
+RCSID("$OpenBSD: ssh-keyscan.c,v 1.49 2004/06/14 01:44:39 djm Exp $");
 
 #include "openbsd-compat/sys-queue.h"
 
@@ -397,8 +397,8 @@ tcpconnect(char *host)
                        error("socket: %s", strerror(errno));
                        continue;
                }
-               if (fcntl(s, F_SETFL, O_NONBLOCK) < 0)
-                       fatal("F_SETFL: %s", strerror(errno));
+               if (set_nonblock(s) == -1)
+                       fatal("%s: set_nonblock(%d)", __func__, s);
                if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0 &&
                    errno != EINPROGRESS)
                        error("connect (`%s'): %s", host, strerror(errno));
diff --git a/sshd.c b/sshd.c
index 5f38781190926e832e859bca53ec070e7e51b152..34379172fce4f8f16f0c7f4d6b599decba2ebca3 100644 (file)
--- a/sshd.c
+++ b/sshd.c
@@ -42,7 +42,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.292 2004/06/13 12:53:24 djm Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.293 2004/06/14 01:44:39 djm Exp $");
 
 #include <openssl/dh.h>
 #include <openssl/bn.h>
@@ -1140,8 +1140,7 @@ main(int ac, char **av)
                                verbose("socket: %.100s", strerror(errno));
                                continue;
                        }
-                       if (fcntl(listen_sock, F_SETFL, O_NONBLOCK) < 0) {
-                               error("listen_sock O_NONBLOCK: %s", strerror(errno));
+                       if (set_nonblock(listen_sock) == -1) {
                                close(listen_sock);
                                continue;
                        }
@@ -1284,8 +1283,7 @@ main(int ac, char **av)
                                                error("accept: %.100s", strerror(errno));
                                        continue;
                                }
-                               if (fcntl(newsock, F_SETFL, 0) < 0) {
-                                       error("newsock del O_NONBLOCK: %s", strerror(errno));
+                               if (unset_nonblock(newsock) == -1) {
                                        close(newsock);
                                        continue;
                                }
This page took 1.059109 seconds and 5 git commands to generate.