diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-12-06 16:35:40 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-12-06 16:35:40 +0000 |
commit | d84df989db48f76be16c34f7795e6788ee7841bc (patch) | |
tree | 3f312a402495e6e3601d7eec1885e9697447bb6b | |
parent | 65366a8c766c8a769d42aa6e66b70f4512b4b7c3 (diff) |
- markus@cvs.openbsd.org 2001/11/19 11:20:21
[sshd.c]
fd leak on HUP; ok stevesk@
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | sshd.c | 24 |
2 files changed, 21 insertions, 8 deletions
@@ -9,6 +9,9 @@ - stevesk@cvs.openbsd.org 2001/11/17 19:14:34 [auth2.c auth.c readconf.c servconf.c ssh-agent.c ssh-keygen.c] enum/int type cleanup where it made sense to do so; ok markus@ + - markus@cvs.openbsd.org 2001/11/19 11:20:21 + [sshd.c] + fd leak on HUP; ok stevesk@ 20011126 - (tim) [contrib/cygwin/README, openbsd-compat/bsd-cygwin_util.c, @@ -6931,4 +6934,4 @@ - Wrote replacements for strlcpy and mkdtemp - Released 1.0pre1 -$Id: ChangeLog,v 1.1669 2001/12/06 16:32:47 mouring Exp $ +$Id: ChangeLog,v 1.1670 2001/12/06 16:35:40 mouring Exp $ @@ -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; |