diff svr-main.c @ 447:278805938dcf

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.
author Matt Johnston <matt@ucc.asn.au>
date Thu, 19 Jul 2007 15:54:18 +0000
parents edbee0596531
children 7e43f5e473b9
line wrap: on
line diff
--- a/svr-main.c	Thu Jul 19 15:47:32 2007 +0000
+++ b/svr-main.c	Thu Jul 19 15:54:18 2007 +0000
@@ -130,6 +130,19 @@
 	   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 @@
 		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(;;) {