summaryrefslogtreecommitdiffstats
path: root/sshd.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-12-06 17:35:40 +0100
committerBen Lindstrom <mouring@eviladmin.org>2001-12-06 17:35:40 +0100
commitd84df989db48f76be16c34f7795e6788ee7841bc (patch)
tree3f312a402495e6e3601d7eec1885e9697447bb6b /sshd.c
parent - stevesk@cvs.openbsd.org 2001/11/17 19:14:34 (diff)
downloadopenssh-d84df989db48f76be16c34f7795e6788ee7841bc.tar.xz
openssh-d84df989db48f76be16c34f7795e6788ee7841bc.zip
- markus@cvs.openbsd.org 2001/11/19 11:20:21
[sshd.c] fd leak on HUP; ok stevesk@
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/sshd.c b/sshd.c
index f81597f1d..dc4f52322 100644
--- a/sshd.c
+++ b/sshd.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.210 2001/11/14 20:45:08 deraadt Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.211 2001/11/19 11:20:21 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -185,6 +185,10 @@ int session_id2_len = 0;
/* record remote hostname or ip */
u_int utmp_len = MAXHOSTNAMELEN;
+/* options.max_startup sized array of fd ints */
+int *startup_pipes = NULL;
+int startup_pipe; /* in child */
+
/* Prototypes for various functions defined later in this file. */
void destroy_sensitive_data(void);
@@ -203,6 +207,16 @@ close_listen_socks(void)
num_listen_socks = -1;
}
+static void
+close_startup_pipes(void)
+{
+ int i;
+ if (startup_pipes)
+ for (i = 0; i < options.max_startups; i++)
+ if (startup_pipes[i] != -1)
+ close(startup_pipes[i]);
+}
+
/*
* Signal handler for SIGHUP. Sshd execs itself when it receives SIGHUP;
* the effect is to reread the configuration file (and to regenerate
@@ -227,6 +241,7 @@ sighup_restart(void)
{
log("Received SIGHUP; restarting.");
close_listen_socks();
+ close_startup_pipes();
execv(saved_argv[0], saved_argv);
log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0], strerror(errno));
exit(1);
@@ -528,9 +543,6 @@ drop_connection(int startups)
return (r < p) ? 1 : 0;
}
-int *startup_pipes = NULL; /* options.max_startup sized array of fd ints */
-int startup_pipe; /* in child */
-
/*
* Main program for the daemon.
*/
@@ -1058,9 +1070,7 @@ main(int ac, char **av)
* the connection.
*/
startup_pipe = startup_p[1];
- for (j = 0; j < options.max_startups; j++)
- if (startup_pipes[j] != -1)
- close(startup_pipes[j]);
+ close_startup_pipes();
close_listen_socks();
sock_in = newsock;
sock_out = newsock;