Mercurial > dropbear
comparison svr-main.c @ 1511:5916af64acd4 fuzz
merge from main
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 17 Feb 2018 19:29:51 +0800 |
parents | 47f36d8565cf |
children | 60fceff95858 |
comparison
equal
deleted
inserted
replaced
1457:32f990cc96b1 | 1511:5916af64acd4 |
---|---|
33 | 33 |
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 #if INETD_MODE |
39 static void main_inetd(void); | 39 static void main_inetd(void); |
40 #endif | 40 #endif |
41 #ifdef NON_INETD_MODE | 41 #if NON_INETD_MODE |
42 static void main_noinetd(void); | 42 static void main_noinetd(void); |
43 #endif | 43 #endif |
44 static void commonsetup(void); | 44 static void commonsetup(void); |
45 | 45 |
46 #if defined(DBMULTI_dropbear) || !DROPBEAR_MULTI | 46 #if defined(DBMULTI_dropbear) || !DROPBEAR_MULTI |
56 disallow_core(); | 56 disallow_core(); |
57 | 57 |
58 /* get commandline options */ | 58 /* get commandline options */ |
59 svr_getopts(argc, argv); | 59 svr_getopts(argc, argv); |
60 | 60 |
61 #ifdef INETD_MODE | 61 #if INETD_MODE |
62 /* service program mode */ | 62 /* service program mode */ |
63 if (svr_opts.inetdmode) { | 63 if (svr_opts.inetdmode) { |
64 main_inetd(); | 64 main_inetd(); |
65 /* notreached */ | 65 /* notreached */ |
66 } | 66 } |
67 #endif | 67 #endif |
68 | 68 |
69 #ifdef NON_INETD_MODE | 69 #if NON_INETD_MODE |
70 main_noinetd(); | 70 main_noinetd(); |
71 /* notreached */ | 71 /* notreached */ |
72 #endif | 72 #endif |
73 | 73 |
74 dropbear_exit("Compiled without normal mode, can't run without -i\n"); | 74 dropbear_exit("Compiled without normal mode, can't run without -i\n"); |
75 return -1; | 75 return -1; |
76 } | 76 } |
77 #endif | 77 #endif |
78 | 78 |
79 #ifdef INETD_MODE | 79 #if INETD_MODE |
80 static void main_inetd() { | 80 static void main_inetd() { |
81 char *host, *port = NULL; | 81 char *host, *port = NULL; |
82 | 82 |
83 /* Set up handlers, syslog, seed random */ | 83 /* Set up handlers, syslog, seed random */ |
84 commonsetup(); | 84 commonsetup(); |
85 | |
86 #if DEBUG_TRACE | |
87 if (debug_trace) { | |
88 /* -v output goes to stderr which would get sent over the inetd network socket */ | |
89 dropbear_exit("Dropbear inetd mode is incompatible with debug -v"); | |
90 } | |
91 #endif | |
85 | 92 |
86 /* In case our inetd was lax in logging source addresses */ | 93 /* In case our inetd was lax in logging source addresses */ |
87 get_socket_address(0, NULL, NULL, &host, &port, 0); | 94 get_socket_address(0, NULL, NULL, &host, &port, 0); |
88 dropbear_log(LOG_INFO, "Child connection from %s:%s", host, port); | 95 dropbear_log(LOG_INFO, "Child connection from %s:%s", host, port); |
89 m_free(host); | 96 m_free(host); |
101 | 108 |
102 /* notreached */ | 109 /* notreached */ |
103 } | 110 } |
104 #endif /* INETD_MODE */ | 111 #endif /* INETD_MODE */ |
105 | 112 |
106 #ifdef NON_INETD_MODE | 113 #if NON_INETD_MODE |
107 static void main_noinetd() { | 114 static void main_noinetd() { |
108 fd_set fds; | 115 fd_set fds; |
109 unsigned int i, j; | 116 unsigned int i, j; |
110 int val; | 117 int val; |
111 int maxsock = -1; | 118 int maxsock = -1; |
186 } | 193 } |
187 } | 194 } |
188 | 195 |
189 val = select(maxsock+1, &fds, NULL, NULL, NULL); | 196 val = select(maxsock+1, &fds, NULL, NULL, NULL); |
190 | 197 |
191 if (exitflag) { | 198 if (ses.exitflag) { |
192 unlink(svr_opts.pidfile); | 199 unlink(svr_opts.pidfile); |
193 dropbear_exit("Terminated by signal"); | 200 dropbear_exit("Terminated by signal"); |
194 } | 201 } |
195 | 202 |
196 if (val == 0) { | 203 if (val == 0) { |
357 } | 364 } |
358 | 365 |
359 /* catch ctrl-c or sigterm */ | 366 /* catch ctrl-c or sigterm */ |
360 static void sigintterm_handler(int UNUSED(unused)) { | 367 static void sigintterm_handler(int UNUSED(unused)) { |
361 | 368 |
362 exitflag = 1; | 369 ses.exitflag = 1; |
363 } | 370 } |
364 | 371 |
365 /* Things used by inetd and non-inetd modes */ | 372 /* Things used by inetd and non-inetd modes */ |
366 static void commonsetup() { | 373 static void commonsetup() { |
367 | 374 |