Patch from Nicolai Ehemann to try binding before going to the background,

so that if it exits early (because something's already listening etc)
then it will return an exitcode of 1.

--HG--
extra : convert_revision : 4e68851f89a773bc502b30dec2b8f6edaa36d473
This commit is contained in:
Matt Johnston 2007-07-19 15:54:18 +00:00
parent b04e2d14ef
commit 762e9973ff

View File

@ -130,6 +130,19 @@ void main_noinetd() {
hostkeys. */
commonsetup();
/* sockets to identify pre-authenticated clients */
for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) {
childpipes[i] = -1;
}
bzero(preauth_addrs, sizeof(preauth_addrs));
/* Set up the listening sockets */
listensockcount = listensockets(listensocks, MAX_LISTEN_ADDR, &maxsock);
if (listensockcount == 0)
{
dropbear_exit("No listening ports available.");
}
/* fork */
if (svr_opts.forkbg) {
int closefds = 0;
@ -157,19 +170,6 @@ void main_noinetd() {
fclose(pidfile);
}
/* sockets to identify pre-authenticated clients */
for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) {
childpipes[i] = -1;
}
bzero(preauth_addrs, sizeof(preauth_addrs));
/* Set up the listening sockets */
listensockcount = listensockets(listensocks, MAX_LISTEN_ADDR, &maxsock);
if (listensockcount == 0)
{
dropbear_exit("No listening ports available.");
}
/* incoming connection select loop */
for(;;) {