Mercurial > dropbear
comparison svr-main.c @ 1278:0c47d97aa9d5
merge
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 16 Mar 2016 22:53:27 +0800 |
parents | 9169e4e7cbee |
children | 750ec4ec4cbe |
comparison
equal
deleted
inserted
replaced
1264:a20b6af6f182 | 1278:0c47d97aa9d5 |
---|---|
34 static size_t listensockets(int *sock, size_t sockcount, int *maxfd); | 34 static size_t listensockets(int *sock, size_t sockcount, int *maxfd); |
35 static void sigchld_handler(int dummy); | 35 static void sigchld_handler(int dummy); |
36 static void sigsegv_handler(int); | 36 static void sigsegv_handler(int); |
37 static void sigintterm_handler(int fish); | 37 static void sigintterm_handler(int fish); |
38 #ifdef INETD_MODE | 38 #ifdef INETD_MODE |
39 static void main_inetd(); | 39 static void main_inetd(void); |
40 #endif | 40 #endif |
41 #ifdef NON_INETD_MODE | 41 #ifdef NON_INETD_MODE |
42 static void main_noinetd(); | 42 static void main_noinetd(void); |
43 #endif | 43 #endif |
44 static void commonsetup(); | 44 static void commonsetup(void); |
45 | 45 |
46 #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) | 46 #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI) |
47 #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) | 47 #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI) |
48 int dropbear_main(int argc, char ** argv) | 48 int dropbear_main(int argc, char ** argv) |
49 #else | 49 #else |
102 /* notreached */ | 102 /* notreached */ |
103 } | 103 } |
104 #endif /* INETD_MODE */ | 104 #endif /* INETD_MODE */ |
105 | 105 |
106 #ifdef NON_INETD_MODE | 106 #ifdef NON_INETD_MODE |
107 void main_noinetd() { | 107 static void main_noinetd() { |
108 fd_set fds; | 108 fd_set fds; |
109 unsigned int i, j; | 109 unsigned int i, j; |
110 int val; | 110 int val; |
111 int maxsock = -1; | 111 int maxsock = -1; |
112 int listensocks[MAX_LISTEN_ADDR]; | 112 int listensocks[MAX_LISTEN_ADDR]; |
304 dropbear_exit("setsid: %s", strerror(errno)); | 304 dropbear_exit("setsid: %s", strerror(errno)); |
305 } | 305 } |
306 #endif | 306 #endif |
307 | 307 |
308 /* make sure we close sockets */ | 308 /* make sure we close sockets */ |
309 for (i = 0; i < listensockcount; i++) { | 309 for (j = 0; j < listensockcount; j++) { |
310 m_close(listensocks[i]); | 310 m_close(listensocks[j]); |
311 } | 311 } |
312 | 312 |
313 m_close(childpipe[0]); | 313 m_close(childpipe[0]); |
314 | 314 |
315 /* start the session */ | 315 /* start the session */ |
336 static void sigchld_handler(int UNUSED(unused)) { | 336 static void sigchld_handler(int UNUSED(unused)) { |
337 struct sigaction sa_chld; | 337 struct sigaction sa_chld; |
338 | 338 |
339 const int saved_errno = errno; | 339 const int saved_errno = errno; |
340 | 340 |
341 while(waitpid(-1, NULL, WNOHANG) > 0); | 341 while(waitpid(-1, NULL, WNOHANG) > 0) {} |
342 | 342 |
343 sa_chld.sa_handler = sigchld_handler; | 343 sa_chld.sa_handler = sigchld_handler; |
344 sa_chld.sa_flags = SA_NOCLDSTOP; | 344 sa_chld.sa_flags = SA_NOCLDSTOP; |
345 sigemptyset(&sa_chld.sa_mask); | 345 sigemptyset(&sa_chld.sa_mask); |
346 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { | 346 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) { |