summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-12-06 16:35:40 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-12-06 16:35:40 +0000
commitd84df989db48f76be16c34f7795e6788ee7841bc (patch)
tree3f312a402495e6e3601d7eec1885e9697447bb6b /sshd.c
parent65366a8c766c8a769d42aa6e66b70f4512b4b7c3 (diff)
- 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 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: sshd.c,v 1.210 2001/11/14 20:45:08 deraadt Exp $"); 43RCSID("$OpenBSD: sshd.c,v 1.211 2001/11/19 11:20:21 markus Exp $");
44 44
45#include <openssl/dh.h> 45#include <openssl/dh.h>
46#include <openssl/bn.h> 46#include <openssl/bn.h>
@@ -185,6 +185,10 @@ int session_id2_len = 0;
185/* record remote hostname or ip */ 185/* record remote hostname or ip */
186u_int utmp_len = MAXHOSTNAMELEN; 186u_int utmp_len = MAXHOSTNAMELEN;
187 187
188/* options.max_startup sized array of fd ints */
189int *startup_pipes = NULL;
190int startup_pipe; /* in child */
191
188/* Prototypes for various functions defined later in this file. */ 192/* Prototypes for various functions defined later in this file. */
189void destroy_sensitive_data(void); 193void destroy_sensitive_data(void);
190 194
@@ -203,6 +207,16 @@ close_listen_socks(void)
203 num_listen_socks = -1; 207 num_listen_socks = -1;
204} 208}
205 209
210static void
211close_startup_pipes(void)
212{
213 int i;
214 if (startup_pipes)
215 for (i = 0; i < options.max_startups; i++)
216 if (startup_pipes[i] != -1)
217 close(startup_pipes[i]);
218}
219
206/* 220/*
207 * Signal handler for SIGHUP. Sshd execs itself when it receives SIGHUP; 221 * Signal handler for SIGHUP. Sshd execs itself when it receives SIGHUP;
208 * the effect is to reread the configuration file (and to regenerate 222 * the effect is to reread the configuration file (and to regenerate
@@ -227,6 +241,7 @@ sighup_restart(void)
227{ 241{
228 log("Received SIGHUP; restarting."); 242 log("Received SIGHUP; restarting.");
229 close_listen_socks(); 243 close_listen_socks();
244 close_startup_pipes();
230 execv(saved_argv[0], saved_argv); 245 execv(saved_argv[0], saved_argv);
231 log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0], strerror(errno)); 246 log("RESTART FAILED: av[0]='%.100s', error: %.100s.", saved_argv[0], strerror(errno));
232 exit(1); 247 exit(1);
@@ -528,9 +543,6 @@ drop_connection(int startups)
528 return (r < p) ? 1 : 0; 543 return (r < p) ? 1 : 0;
529} 544}
530 545
531int *startup_pipes = NULL; /* options.max_startup sized array of fd ints */
532int startup_pipe; /* in child */
533
534/* 546/*
535 * Main program for the daemon. 547 * Main program for the daemon.
536 */ 548 */
@@ -1058,9 +1070,7 @@ main(int ac, char **av)
1058 * the connection. 1070 * the connection.
1059 */ 1071 */
1060 startup_pipe = startup_p[1]; 1072 startup_pipe = startup_p[1];
1061 for (j = 0; j < options.max_startups; j++) 1073 close_startup_pipes();
1062 if (startup_pipes[j] != -1)
1063 close(startup_pipes[j]);
1064 close_listen_socks(); 1074 close_listen_socks();
1065 sock_in = newsock; 1075 sock_in = newsock;
1066 sock_out = newsock; 1076 sock_out = newsock;