Mercurial > dropbear
comparison svr-main.c @ 1739:13d834efc376 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 15 Oct 2020 19:55:15 +0800 |
parents | 6ea18ca8fc03 |
children | 2b3a8026a6ce |
comparison
equal
deleted
inserted
replaced
1562:768ebf737aa0 | 1739:13d834efc376 |
---|---|
78 | 78 |
79 #if INETD_MODE | 79 #if INETD_MODE |
80 static void main_inetd() { | 80 static void main_inetd() { |
81 char *host, *port = NULL; | 81 char *host, *port = NULL; |
82 | 82 |
83 /* Set up handlers, syslog, seed random */ | 83 /* Set up handlers, syslog */ |
84 commonsetup(); | 84 commonsetup(); |
85 | |
86 seedrandom(); | |
85 | 87 |
86 #if DEBUG_TRACE | 88 #if DEBUG_TRACE |
87 if (debug_trace) { | 89 if (debug_trace) { |
88 /* -v output goes to stderr which would get sent over the inetd network socket */ | 90 /* -v output goes to stderr which would get sent over the inetd network socket */ |
89 dropbear_exit("Dropbear inetd mode is incompatible with debug -v"); | 91 dropbear_exit("Dropbear inetd mode is incompatible with debug -v"); |
176 } | 178 } |
177 | 179 |
178 /* incoming connection select loop */ | 180 /* incoming connection select loop */ |
179 for(;;) { | 181 for(;;) { |
180 | 182 |
181 FD_ZERO(&fds); | 183 DROPBEAR_FD_ZERO(&fds); |
182 | 184 |
183 /* listening sockets */ | 185 /* listening sockets */ |
184 for (i = 0; i < listensockcount; i++) { | 186 for (i = 0; i < listensockcount; i++) { |
185 FD_SET(listensocks[i], &fds); | 187 FD_SET(listensocks[i], &fds); |
186 } | 188 } |
271 if (pipe(childpipe) < 0) { | 273 if (pipe(childpipe) < 0) { |
272 TRACE(("error creating child pipe")) | 274 TRACE(("error creating child pipe")) |
273 goto out; | 275 goto out; |
274 } | 276 } |
275 | 277 |
276 #ifdef DEBUG_NOFORK | 278 #if DEBUG_NOFORK |
277 fork_ret = 0; | 279 fork_ret = 0; |
278 #else | 280 #else |
279 fork_ret = fork(); | 281 fork_ret = fork(); |
280 #endif | 282 #endif |
281 if (fork_ret < 0) { | 283 if (fork_ret < 0) { |
294 remote_host = NULL; | 296 remote_host = NULL; |
295 | 297 |
296 } else { | 298 } else { |
297 | 299 |
298 /* child */ | 300 /* child */ |
299 #ifdef DEBUG_FORKGPROF | |
300 extern void _start(void), etext(void); | |
301 monstartup((u_long)&_start, (u_long)&etext); | |
302 #endif /* DEBUG_FORKGPROF */ | |
303 | |
304 getaddrstring(&remoteaddr, NULL, &remote_port, 0); | 301 getaddrstring(&remoteaddr, NULL, &remote_port, 0); |
305 dropbear_log(LOG_INFO, "Child connection from %s:%s", remote_host, remote_port); | 302 dropbear_log(LOG_INFO, "Child connection from %s:%s", remote_host, remote_port); |
306 m_free(remote_host); | 303 m_free(remote_host); |
307 m_free(remote_port); | 304 m_free(remote_port); |
308 | 305 |
402 crypto_init(); | 399 crypto_init(); |
403 | 400 |
404 /* Now we can setup the hostkeys - needs to be after logging is on, | 401 /* Now we can setup the hostkeys - needs to be after logging is on, |
405 * otherwise we might end up blatting error messages to the socket */ | 402 * otherwise we might end up blatting error messages to the socket */ |
406 load_all_hostkeys(); | 403 load_all_hostkeys(); |
407 | |
408 seedrandom(); | |
409 } | 404 } |
410 | 405 |
411 /* Set up listening sockets for all the requested ports */ | 406 /* Set up listening sockets for all the requested ports */ |
412 static size_t listensockets(int *socks, size_t sockcount, int *maxfd) { | 407 static size_t listensockets(int *socks, size_t sockcount, int *maxfd) { |
413 | 408 |