Mercurial > dropbear
comparison svr-main.c @ 101:72dc22f56858
Change the way we load keys/ports so we don't print error messages into our
socket.
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 23 Aug 2004 05:27:34 +0000 |
parents | ac96bc733e71 |
children | 10f4d3319780 |
comparison
equal
deleted
inserted
replaced
100:c72f5c10125d | 101:72dc22f56858 |
---|---|
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 commonsetup(); | 140 commonsetup(); |
141 | 141 |
142 /* Now we can setup the hostkeys - needs to be after logging is on, | |
143 * otherwise we might end up blatting error messages to the socket */ | |
144 loadhostkeys(); | |
145 | |
142 /* should be done after syslog is working */ | 146 /* should be done after syslog is working */ |
143 if (svr_opts.forkbg) { | 147 if (svr_opts.forkbg) { |
144 dropbear_log(LOG_INFO, "Running in background"); | 148 dropbear_log(LOG_INFO, "Running in background"); |
145 } else { | 149 } else { |
146 dropbear_log(LOG_INFO, "Not forking"); | 150 dropbear_log(LOG_INFO, "Not forking"); |
356 | 360 |
357 /* Set up listening sockets for all the requested ports */ | 361 /* Set up listening sockets for all the requested ports */ |
358 static int listensockets(int *sock, int sockcount, int *maxfd) { | 362 static int listensockets(int *sock, int sockcount, int *maxfd) { |
359 | 363 |
360 unsigned int i; | 364 unsigned int i; |
361 char portstring[NI_MAXSERV]; | |
362 char* errstring = NULL; | 365 char* errstring = NULL; |
363 unsigned int sockpos = 0; | 366 unsigned int sockpos = 0; |
364 int nsock; | 367 int nsock; |
365 | 368 |
369 TRACE(("listensockets: %d to try\n", svr_opts.portcount)); | |
370 | |
366 for (i = 0; i < svr_opts.portcount; i++) { | 371 for (i = 0; i < svr_opts.portcount; i++) { |
367 | 372 |
368 snprintf(portstring, sizeof(portstring), "%d", svr_opts.ports[i]); | 373 TRACE(("listening on '%s'", svr_opts.ports[i])); |
369 nsock = dropbear_listen(NULL, portstring, &sock[sockpos], | 374 |
375 nsock = dropbear_listen(NULL, svr_opts.ports[i], &sock[sockpos], | |
370 sockcount - sockpos, | 376 sockcount - sockpos, |
371 &errstring, maxfd); | 377 &errstring, maxfd); |
372 | 378 |
373 if (nsock < 0) { | 379 if (nsock < 0) { |
374 dropbear_log(LOG_WARNING, "Failed listening on port %s: %s", | 380 dropbear_log(LOG_WARNING, "Failed listening on '%s': %s", |
375 portstring, errstring); | 381 svr_opts.ports[i], errstring); |
376 m_free(errstring); | 382 m_free(errstring); |
377 continue; | 383 continue; |
378 } | 384 } |
379 | 385 |
380 sockpos += nsock; | 386 sockpos += nsock; |