summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:27:31 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:27:31 +0000
commitec46e0b5fd2299f7f1449240894fa36d1745587e (patch)
treea571d4696c04304a7ddbfa6a829c70444915783f /sshd.c
parent983c098311526a2e09a7c2cee18f3bf1081431e5 (diff)
- markus@cvs.openbsd.org 2001/06/04 23:07:21
[clientloop.c serverloop.c sshd.c] set flags in the signal handlers, do real work in the main loop, ok provos@
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/sshd.c b/sshd.c
index 869c12011..1dfcac0d7 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.198 2001/05/28 23:58:35 markus Exp $"); 43RCSID("$OpenBSD: sshd.c,v 1.199 2001/06/04 23:07: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>
@@ -167,8 +167,9 @@ struct {
167 */ 167 */
168int key_do_regen = 0; 168int key_do_regen = 0;
169 169
170/* This is set to true when SIGHUP is received. */ 170/* This is set to true when a signal is received. */
171int received_sighup = 0; 171int received_sighup = 0;
172int received_sigterm = 0;
172 173
173/* session identifier, used by RSA-auth */ 174/* session identifier, used by RSA-auth */
174u_char session_id[16]; 175u_char session_id[16];
@@ -227,21 +228,16 @@ sighup_restart(void)
227 228
228/* 229/*
229 * Generic signal handler for terminating signals in the master daemon. 230 * Generic signal handler for terminating signals in the master daemon.
230 * These close the listen socket; not closing it seems to cause "Address
231 * already in use" problems on some machines, which is inconvenient.
232 */ 231 */
233void 232void
234sigterm_handler(int sig) 233sigterm_handler(int sig)
235{ 234{
236 log("Received signal %d; terminating.", sig); 235 received_sigterm = sig;
237 close_listen_socks();
238 unlink(options.pid_file);
239 exit(255);
240} 236}
241 237
242/* 238/*
243 * SIGCHLD handler. This is called whenever a child dies. This will then 239 * SIGCHLD handler. This is called whenever a child dies. This will then
244 * reap any zombies left by exited c. 240 * reap any zombies left by exited children.
245 */ 241 */
246void 242void
247main_sigchld_handler(int sig) 243main_sigchld_handler(int sig)
@@ -262,6 +258,8 @@ main_sigchld_handler(int sig)
262void 258void
263grace_alarm_handler(int sig) 259grace_alarm_handler(int sig)
264{ 260{
261 /* XXX no idea how fix this signal handler */
262
265 /* Close the connection. */ 263 /* Close the connection. */
266 packet_close(); 264 packet_close();
267 265
@@ -939,6 +937,13 @@ main(int ac, char **av)
939 ret = select(maxfd+1, fdset, NULL, NULL, NULL); 937 ret = select(maxfd+1, fdset, NULL, NULL, NULL);
940 if (ret < 0 && errno != EINTR) 938 if (ret < 0 && errno != EINTR)
941 error("select: %.100s", strerror(errno)); 939 error("select: %.100s", strerror(errno));
940 if (received_sigterm) {
941 log("Received signal %d; terminating.",
942 received_sigterm);
943 close_listen_socks();
944 unlink(options.pid_file);
945 exit(255);
946 }
942 if (key_used && key_do_regen) { 947 if (key_used && key_do_regen) {
943 generate_ephemeral_server_key(); 948 generate_ephemeral_server_key();
944 key_used = 0; 949 key_used = 0;