[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.
*/
#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"
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,
*/
#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"
enter_non_blocking(void)
{
in_non_blocking_mode = 1;
- (void) fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
+ set_nonblock(fileno(stdin));
}
/*
*/
#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"
}
/* set/unset filedescriptor to non-blocking */
-void
+int
set_nonblock(int fd)
{
int val;
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;
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 */
-/* $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>
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 *);
*/
#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"
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. */
#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>
{
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;
*/
#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"
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));
*/
#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>
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;
}
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;
}