Mercurial > dropbear
comparison svr-main.c @ 910:89555751c489 asm
merge up to 2013.63, improve ASM makefile rules a bit
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 27 Feb 2014 21:35:58 +0800 |
parents | 860e3522f8fc |
children | 0bb16232e7c4 |
comparison
equal
deleted
inserted
replaced
909:e4b75744acab | 910:89555751c489 |
---|---|
26 #include "dbutil.h" | 26 #include "dbutil.h" |
27 #include "session.h" | 27 #include "session.h" |
28 #include "buffer.h" | 28 #include "buffer.h" |
29 #include "signkey.h" | 29 #include "signkey.h" |
30 #include "runopts.h" | 30 #include "runopts.h" |
31 #include "random.h" | 31 #include "dbrandom.h" |
32 #include "crypto_desc.h" | |
32 | 33 |
33 static size_t listensockets(int *sock, size_t sockcount, int *maxfd); | 34 static size_t listensockets(int *sock, size_t sockcount, int *maxfd); |
34 static void sigchld_handler(int dummy); | 35 static void sigchld_handler(int dummy); |
35 static void sigsegv_handler(int); | 36 static void sigsegv_handler(int); |
36 static void sigintterm_handler(int fish); | 37 static void sigintterm_handler(int fish); |
132 /* Set up the listening sockets */ | 133 /* Set up the listening sockets */ |
133 listensockcount = listensockets(listensocks, MAX_LISTEN_ADDR, &maxsock); | 134 listensockcount = listensockets(listensocks, MAX_LISTEN_ADDR, &maxsock); |
134 if (listensockcount == 0) | 135 if (listensockcount == 0) |
135 { | 136 { |
136 dropbear_exit("No listening ports available."); | 137 dropbear_exit("No listening ports available."); |
138 } | |
139 | |
140 for (i = 0; i < listensockcount; i++) { | |
141 set_sock_priority(listensocks[i], DROPBEAR_PRIO_LOWDELAY); | |
142 FD_SET(listensocks[i], &fds); | |
137 } | 143 } |
138 | 144 |
139 /* fork */ | 145 /* fork */ |
140 if (svr_opts.forkbg) { | 146 if (svr_opts.forkbg) { |
141 int closefds = 0; | 147 int closefds = 0; |
329 | 335 |
330 /* catch + reap zombie children */ | 336 /* catch + reap zombie children */ |
331 static void sigchld_handler(int UNUSED(unused)) { | 337 static void sigchld_handler(int UNUSED(unused)) { |
332 struct sigaction sa_chld; | 338 struct sigaction sa_chld; |
333 | 339 |
340 const int saved_errno = errno; | |
341 | |
334 while(waitpid(-1, NULL, WNOHANG) > 0); | 342 while(waitpid(-1, NULL, WNOHANG) > 0); |
335 | 343 |
336 sa_chld.sa_handler = sigchld_handler; | 344 sa_chld.sa_handler = sigchld_handler; |
337 sa_chld.sa_flags = SA_NOCLDSTOP; | 345 sa_chld.sa_flags = SA_NOCLDSTOP; |
338 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { | 346 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { |
339 dropbear_exit("signal() error"); | 347 dropbear_exit("signal() error"); |
340 } | 348 } |
349 errno = saved_errno; | |
341 } | 350 } |
342 | 351 |
343 /* catch any segvs */ | 352 /* catch any segvs */ |
344 static void sigsegv_handler(int UNUSED(unused)) { | 353 static void sigsegv_handler(int UNUSED(unused)) { |
345 fprintf(stderr, "Aiee, segfault! You should probably report " | 354 fprintf(stderr, "Aiee, segfault! You should probably report " |
346 "this as a bug to the developer\n"); | 355 "this as a bug to the developer\n"); |
347 exit(EXIT_FAILURE); | 356 _exit(EXIT_FAILURE); |
348 } | 357 } |
349 | 358 |
350 /* catch ctrl-c or sigterm */ | 359 /* catch ctrl-c or sigterm */ |
351 static void sigintterm_handler(int UNUSED(unused)) { | 360 static void sigintterm_handler(int UNUSED(unused)) { |
352 | 361 |
381 } | 390 } |
382 if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) { | 391 if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) { |
383 dropbear_exit("signal() error"); | 392 dropbear_exit("signal() error"); |
384 } | 393 } |
385 | 394 |
395 crypto_init(); | |
396 | |
386 /* Now we can setup the hostkeys - needs to be after logging is on, | 397 /* Now we can setup the hostkeys - needs to be after logging is on, |
387 * otherwise we might end up blatting error messages to the socket */ | 398 * otherwise we might end up blatting error messages to the socket */ |
388 loadhostkeys(); | 399 load_all_hostkeys(); |
389 | 400 |
390 seedrandom(); | 401 seedrandom(); |
391 } | 402 } |
392 | 403 |
393 /* Set up listening sockets for all the requested ports */ | 404 /* Set up listening sockets for all the requested ports */ |