summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2007-07-19 15:54:18 +0000
committerMatt Johnston <matt@ucc.asn.au>2007-07-19 15:54:18 +0000
commit6ec5ee0c500f4d32df4be6f84538e19a62b9b32e (patch)
tree77c19167cd8925321c88cd726a8afe2c31801051
parentbaf1d05697038f4fd37287eb70339fde28f0d096 (diff)
downloaddropbear-6ec5ee0c500f4d32df4be6f84538e19a62b9b32e.tar.gz
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.
-rw-r--r--svr-main.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/svr-main.c b/svr-main.c
index 335395b..9e0578e 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -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(;;) {