annotate svr-main.c @ 638:6b17302318b9

Added signature for changeset 3f12086c2ef2
author Matt Johnston <matt@ucc.asn.au>
date Tue, 08 Nov 2011 21:06:29 +0800
parents a98a2138364a
children 67fbba2c2a85
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * Dropbear - a SSH2 server
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 *
290
94ee16f5b8a8 0.48 progress
Matt Johnston <matt@ucc.asn.au>
parents: 279
diff changeset
4 * Copyright (c) 2002-2006 Matt Johnston
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 * All rights reserved.
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 *
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 * of this software and associated documentation files (the "Software"), to deal
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * in the Software without restriction, including without limitation the rights
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 * copies of the Software, and to permit persons to whom the Software is
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * furnished to do so, subject to the following conditions:
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 *
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 * The above copyright notice and this permission notice shall be included in
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 * all copies or substantial portions of the Software.
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 *
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 * SOFTWARE. */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 #include "includes.h"
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 #include "dbutil.h"
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 #include "session.h"
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 #include "buffer.h"
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 #include "signkey.h"
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 #include "runopts.h"
298
7dad470ad4aa minor cleanups for some warnings
Matt Johnston <matt@ucc.asn.au>
parents: 290
diff changeset
31 #include "random.h"
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
33 static size_t listensockets(int *sock, size_t sockcount, int *maxfd);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 static void sigchld_handler(int dummy);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 static void sigsegv_handler(int);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 static void sigintterm_handler(int fish);
156
8c2b3506f112 Rearrange preprocessor parts so that compilation with various options
Matt Johnston <matt@ucc.asn.au>
parents: 113
diff changeset
37 #ifdef INETD_MODE
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
38 static void main_inetd();
156
8c2b3506f112 Rearrange preprocessor parts so that compilation with various options
Matt Johnston <matt@ucc.asn.au>
parents: 113
diff changeset
39 #endif
8c2b3506f112 Rearrange preprocessor parts so that compilation with various options
Matt Johnston <matt@ucc.asn.au>
parents: 113
diff changeset
40 #ifdef NON_INETD_MODE
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
41 static void main_noinetd();
156
8c2b3506f112 Rearrange preprocessor parts so that compilation with various options
Matt Johnston <matt@ucc.asn.au>
parents: 113
diff changeset
42 #endif
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
43 static void commonsetup();
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 #if defined(DBMULTI_dropbear) || !defined(DROPBEAR_MULTI)
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 #if defined(DBMULTI_dropbear) && defined(DROPBEAR_MULTI)
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 int dropbear_main(int argc, char ** argv)
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 #else
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 int main(int argc, char ** argv)
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 #endif
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 {
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
52 _dropbear_exit = svr_dropbear_exit;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
53 _dropbear_log = svr_dropbear_log;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
54
425
1afa503e33f5 Disable core dumps
Matt Johnston <matt@ucc.asn.au>
parents: 379
diff changeset
55 disallow_core();
1afa503e33f5 Disable core dumps
Matt Johnston <matt@ucc.asn.au>
parents: 379
diff changeset
56
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
57 /* get commandline options */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
58 svr_getopts(argc, argv);
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
59
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
60 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
61 /* service program mode */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
62 if (svr_opts.inetdmode) {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
63 main_inetd();
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
64 /* notreached */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
65 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
66 #endif
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
67
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
68 #ifdef NON_INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
69 main_noinetd();
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
70 /* notreached */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
71 #endif
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
72
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
73 dropbear_exit("Compiled without normal mode, can't run without -i\n");
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
74 return -1;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
75 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
76 #endif
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
77
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
78 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
79 static void main_inetd() {
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
80 char *host, *port = NULL;
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
81
272
3be7ae2e8dfa Only read /dev/random once when the program starts
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
82 /* Set up handlers, syslog, seed random */
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
83 commonsetup();
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
84
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
85 /* In case our inetd was lax in logging source addresses */
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
86 get_socket_address(0, NULL, NULL, &host, &port, 0);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
87 dropbear_log(LOG_INFO, "Child connection from %s:%s", host, port);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
88 m_free(host);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
89 m_free(port);
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
90
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
91 /* Don't check the return value - it may just fail since inetd has
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
92 * already done setsid() after forking (xinetd on Darwin appears to do
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
93 * this */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
94 setsid();
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
95
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
96 /* Start service program
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
97 * -1 is a dummy childpipe, just something we can close() without
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
98 * mattering. */
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
99 svr_session(0, -1);
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
100
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
101 /* notreached */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
102 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
103 #endif /* INETD_MODE */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
104
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
105 #ifdef NON_INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
106 void main_noinetd() {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107 fd_set fds;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 unsigned int i, j;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 int val;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110 int maxsock = -1;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
111 int listensocks[MAX_LISTEN_ADDR];
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
112 size_t listensockcount = 0;
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
113 FILE *pidfile = NULL;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
115 int childpipes[MAX_UNAUTH_CLIENTS];
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
116 char * preauth_addrs[MAX_UNAUTH_CLIENTS];
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
117
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 int childsock;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119 int childpipe[2];
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120
433
c216212001fc Fix for -pedantic -ansi compilation, change // to /**/, plus some signedness
Matt Johnston <matt@ucc.asn.au>
parents: 425
diff changeset
121 /* Note: commonsetup() must happen before we daemon()ise. Otherwise
c216212001fc Fix for -pedantic -ansi compilation, change // to /**/, plus some signedness
Matt Johnston <matt@ucc.asn.au>
parents: 425
diff changeset
122 daemon() will chdir("/"), and we won't be able to find local-dir
c216212001fc Fix for -pedantic -ansi compilation, change // to /**/, plus some signedness
Matt Johnston <matt@ucc.asn.au>
parents: 425
diff changeset
123 hostkeys. */
379
b66a00272a90 Load hostkeys before daemon(), since daemon()'s chdir("/") will prevent us
Matt Johnston <matt@ucc.asn.au>
parents: 323
diff changeset
124 commonsetup();
b66a00272a90 Load hostkeys before daemon(), since daemon()'s chdir("/") will prevent us
Matt Johnston <matt@ucc.asn.au>
parents: 323
diff changeset
125
447
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
126 /* sockets to identify pre-authenticated clients */
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
127 for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) {
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
128 childpipes[i] = -1;
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
129 }
539
07a58e4da1ac use memset() rather than bzero()
Matt Johnston <matt@ucc.asn.au>
parents: 476
diff changeset
130 memset(preauth_addrs, 0x0, sizeof(preauth_addrs));
447
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
131
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
132 /* Set up the listening sockets */
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
133 listensockcount = listensockets(listensocks, MAX_LISTEN_ADDR, &maxsock);
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
134 if (listensockcount == 0)
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
135 {
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
136 dropbear_exit("No listening ports available.");
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
137 }
278805938dcf Patch from Nicolai Ehemann to try binding before going to the background,
Matt Johnston <matt@ucc.asn.au>
parents: 445
diff changeset
138
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 /* fork */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 if (svr_opts.forkbg) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 int closefds = 0;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 #ifndef DEBUG_TRACE
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143 if (!svr_opts.usingsyslog) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 closefds = 1;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 #endif
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 if (daemon(0, closefds) < 0) {
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
148 dropbear_exit("Failed to daemonize: %s", strerror(errno));
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
150 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152 /* should be done after syslog is working */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 if (svr_opts.forkbg) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154 dropbear_log(LOG_INFO, "Running in background");
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155 } else {
445
edbee0596531 "backgrounding" is more user-understandable than "forking"
Matt Johnston <matt@ucc.asn.au>
parents: 435
diff changeset
156 dropbear_log(LOG_INFO, "Not backgrounding");
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159 /* create a PID file so that we can be killed easily */
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 298
diff changeset
160 pidfile = fopen(svr_opts.pidfile, "w");
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161 if (pidfile) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 fprintf(pidfile, "%d\n", getpid());
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 fclose(pidfile);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
165
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
166 /* incoming connection select loop */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
167 for(;;) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
168
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
169 FD_ZERO(&fds);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 /* listening sockets */
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
172 for (i = 0; i < listensockcount; i++) {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 FD_SET(listensocks[i], &fds);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
174 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 /* pre-authentication clients */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 if (childpipes[i] >= 0) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 FD_SET(childpipes[i], &fds);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 maxsock = MAX(maxsock, childpipes[i]);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 447
diff changeset
184 val = select(maxsock+1, &fds, NULL, NULL, NULL);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
185
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 if (exitflag) {
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 298
diff changeset
187 unlink(svr_opts.pidfile);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 dropbear_exit("Terminated by signal");
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
190
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
191 if (val == 0) {
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 447
diff changeset
192 /* timeout reached - shouldn't happen. eh */
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
193 continue;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
194 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
195
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
196 if (val < 0) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
197 if (errno == EINTR) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
198 continue;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
199 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
200 dropbear_exit("Listening socket error");
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
201 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
202
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
203 /* close fds which have been authed or closed - svr-auth.c handles
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
204 * closing the auth sockets on success */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
205 for (i = 0; i < MAX_UNAUTH_CLIENTS; i++) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
206 if (childpipes[i] >= 0 && FD_ISSET(childpipes[i], &fds)) {
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
207 m_close(childpipes[i]);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
208 childpipes[i] = -1;
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
209 m_free(preauth_addrs[i]);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
211 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
212
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
213 /* handle each socket which has something to say */
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
214 for (i = 0; i < listensockcount; i++) {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
215 size_t num_unauthed_for_addr = 0;
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
216 size_t num_unauthed_total = 0;
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
217 char *remote_host = NULL, *remote_port = NULL;
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
218 pid_t fork_ret = 0;
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
219 size_t conn_idx = 0;
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
220 struct sockaddr_storage remoteaddr;
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
221 socklen_t remoteaddrlen;
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
222
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 if (!FD_ISSET(listensocks[i], &fds))
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
224 continue;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
225
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
226 remoteaddrlen = sizeof(remoteaddr);
63
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
227 childsock = accept(listensocks[i],
dcc43965928f - A nice cleaner structure for tcp (acceptor) forwarding.
Matt Johnston <matt@ucc.asn.au>
parents: 62
diff changeset
228 (struct sockaddr*)&remoteaddr, &remoteaddrlen);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
229
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230 if (childsock < 0) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
231 /* accept failed */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
232 continue;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
233 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
234
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
235 /* Limit the number of unauthenticated connections per IP */
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
236 getaddrstring(&remoteaddr, &remote_host, NULL, 0);
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
237
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
238 num_unauthed_for_addr = 0;
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
239 num_unauthed_total = 0;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
240 for (j = 0; j < MAX_UNAUTH_CLIENTS; j++) {
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
241 if (childpipes[j] >= 0) {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
242 num_unauthed_total++;
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
243 if (strcmp(remote_host, preauth_addrs[j]) == 0) {
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
244 num_unauthed_for_addr++;
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
245 }
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
246 } else {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
247 /* a free slot */
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
248 conn_idx = j;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
249 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
250 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
251
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
252 if (num_unauthed_total >= MAX_UNAUTH_CLIENTS
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
253 || num_unauthed_for_addr >= MAX_UNAUTH_PER_IP) {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
254 goto out;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
255 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
256
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
257 if (pipe(childpipe) < 0) {
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 158
diff changeset
258 TRACE(("error creating child pipe"))
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
259 goto out;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
260 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
261
476
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
262 #ifdef DEBUG_NOFORK
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
263 fork_ret = 0;
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
264 #else
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
265 fork_ret = fork();
476
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
266 #endif
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
267 if (fork_ret < 0) {
594
a98a2138364a Improve capitalisation for all logged strings
Matt Johnston <matt@ucc.asn.au>
parents: 568
diff changeset
268 dropbear_log(LOG_WARNING, "Error forking: %s", strerror(errno));
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
269 goto out;
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
270
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
271 } else if (fork_ret > 0) {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
272
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
273 /* parent */
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
274 childpipes[conn_idx] = childpipe[0];
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
275 m_close(childpipe[1]);
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
276 preauth_addrs[conn_idx] = remote_host;
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
277 remote_host = NULL;
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
278
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
279 } else {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
280
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
281 /* child */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
282 #ifdef DEBUG_FORKGPROF
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
283 extern void _start(void), etext(void);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
284 monstartup((u_long)&_start, (u_long)&etext);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
285 #endif /* DEBUG_FORKGPROF */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
286
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
287 getaddrstring(&remoteaddr, NULL, &remote_port, 0);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
288 dropbear_log(LOG_INFO, "Child connection from %s:%s", remote_host, remote_port);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
289 m_free(remote_host);
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
290 m_free(remote_port);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
291
476
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
292 #ifndef DEBUG_NOFORK
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
293 if (setsid() < 0) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
294 dropbear_exit("setsid: %s", strerror(errno));
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
295 }
476
df7f7da7f6e4 - Rework pubkey options to be more careful about buffer lengths. Needs review.
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
296 #endif
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
297
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
298 /* make sure we close sockets */
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
299 for (i = 0; i < listensockcount; i++) {
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
300 m_close(listensocks[i]);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
301 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
302
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
303 m_close(childpipe[0]);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
304
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
305 /* start the session */
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
306 svr_session(childsock, childpipe[1]);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
307 /* don't return */
241
c5d3ef11155f * use own assertions which should get logged properly
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
308 dropbear_assert(0);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
309 }
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
310
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
311 out:
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
312 /* This section is important for the parent too */
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
313 m_close(childsock);
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
314 if (remote_host) {
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 539
diff changeset
315 m_free(remote_host);
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
316 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
317 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
318 } /* for(;;) loop */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
319
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
320 /* don't reach here */
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
321 }
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
322 #endif /* NON_INETD_MODE */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
323
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
324
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
325 /* catch + reap zombie children */
108
10f4d3319780 - added circular buffering for channels
Matt Johnston <matt@ucc.asn.au>
parents: 101
diff changeset
326 static void sigchld_handler(int UNUSED(unused)) {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
327 struct sigaction sa_chld;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
328
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
329 while(waitpid(-1, NULL, WNOHANG) > 0);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
330
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
331 sa_chld.sa_handler = sigchld_handler;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
332 sa_chld.sa_flags = SA_NOCLDSTOP;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
333 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
334 dropbear_exit("signal() error");
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
335 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
336 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
337
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
338 /* catch any segvs */
108
10f4d3319780 - added circular buffering for channels
Matt Johnston <matt@ucc.asn.au>
parents: 101
diff changeset
339 static void sigsegv_handler(int UNUSED(unused)) {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
340 fprintf(stderr, "Aiee, segfault! You should probably report "
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
341 "this as a bug to the developer\n");
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
342 exit(EXIT_FAILURE);
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
343 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
344
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
345 /* catch ctrl-c or sigterm */
108
10f4d3319780 - added circular buffering for channels
Matt Johnston <matt@ucc.asn.au>
parents: 101
diff changeset
346 static void sigintterm_handler(int UNUSED(unused)) {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
347
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
348 exitflag = 1;
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
349 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
350
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
351 /* Things used by inetd and non-inetd modes */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
352 static void commonsetup() {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
353
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
354 struct sigaction sa_chld;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
355 #ifndef DISABLE_SYSLOG
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
356 if (svr_opts.usingsyslog) {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
357 startsyslog();
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
358 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
359 #endif
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
360
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
361 /* set up cleanup handler */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
362 if (signal(SIGINT, sigintterm_handler) == SIG_ERR ||
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
363 #ifndef DEBUG_VALGRIND
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
364 signal(SIGTERM, sigintterm_handler) == SIG_ERR ||
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
365 #endif
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
366 signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
367 dropbear_exit("signal() error");
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
368 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
369
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
370 /* catch and reap zombie children */
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
371 sa_chld.sa_handler = sigchld_handler;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
372 sa_chld.sa_flags = SA_NOCLDSTOP;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
373 if (sigaction(SIGCHLD, &sa_chld, NULL) < 0) {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
374 dropbear_exit("signal() error");
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
375 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
376 if (signal(SIGSEGV, sigsegv_handler) == SIG_ERR) {
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
377 dropbear_exit("signal() error");
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
378 }
113
775c6cbfe995 Load the hostkeys for inetd too - oops
Matt Johnston <matt@ucc.asn.au>
parents: 108
diff changeset
379
775c6cbfe995 Load the hostkeys for inetd too - oops
Matt Johnston <matt@ucc.asn.au>
parents: 108
diff changeset
380 /* Now we can setup the hostkeys - needs to be after logging is on,
775c6cbfe995 Load the hostkeys for inetd too - oops
Matt Johnston <matt@ucc.asn.au>
parents: 108
diff changeset
381 * otherwise we might end up blatting error messages to the socket */
775c6cbfe995 Load the hostkeys for inetd too - oops
Matt Johnston <matt@ucc.asn.au>
parents: 108
diff changeset
382 loadhostkeys();
272
3be7ae2e8dfa Only read /dev/random once when the program starts
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
383
3be7ae2e8dfa Only read /dev/random once when the program starts
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
384 seedrandom();
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
385 }
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 63
diff changeset
386
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
387 /* Set up listening sockets for all the requested ports */
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
388 static size_t listensockets(int *sock, size_t sockcount, int *maxfd) {
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
389
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
390 unsigned int i;
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
391 char* errstring = NULL;
277
044bc108b9b3 * Per-IP connection unauthed connection limits
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
392 size_t sockpos = 0;
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
393 int nsock;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
394
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 158
diff changeset
395 TRACE(("listensockets: %d to try\n", svr_opts.portcount))
101
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 71
diff changeset
396
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
397 for (i = 0; i < svr_opts.portcount; i++) {
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
398
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 290
diff changeset
399 TRACE(("listening on '%s:%s'", svr_opts.addresses[i], svr_opts.ports[i]))
101
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 71
diff changeset
400
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 290
diff changeset
401 nsock = dropbear_listen(svr_opts.addresses[i], svr_opts.ports[i], &sock[sockpos],
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
402 sockcount - sockpos,
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
403 &errstring, maxfd);
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
404
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
405 if (nsock < 0) {
101
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 71
diff changeset
406 dropbear_log(LOG_WARNING, "Failed listening on '%s': %s",
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 71
diff changeset
407 svr_opts.ports[i], errstring);
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
408 m_free(errstring);
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
409 continue;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
410 }
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
411
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
412 sockpos += nsock;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
413
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
414 }
62
20563735e8b5 just checkpointing
Matt Johnston <matt@ucc.asn.au>
parents: 30
diff changeset
415 return sockpos;
30
223b0f5f8dce Switching to the magical new Makefile, and new dbmulti style
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
416 }