annotate svr-runopts.c @ 560:52d7301e46bd agent-client

Agent forwarding works
author Matt Johnston <matt@ucc.asn.au>
date Thu, 30 Jul 2009 15:14:33 +0000
parents a3748e54273c
children 005530560594
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /*
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * Dropbear - a SSH2 server
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * Copyright (c) 2002,2003 Matt Johnston
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 * All rights reserved.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 * of this software and associated documentation files (the "Software"), to deal
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
9 * in the Software without restriction, including without limitation the rights
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
11 * copies of the Software, and to permit persons to whom the Software is
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
12 * furnished to do so, subject to the following conditions:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14 * The above copyright notice and this permission notice shall be included in
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
15 * all copies or substantial portions of the Software.
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
16 *
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
fe6bca95afa7 Makefile.in contains updated files required
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
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
23 * SOFTWARE. */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
24
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
25 #include "includes.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
26 #include "runopts.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
27 #include "signkey.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
28 #include "buffer.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
29 #include "dbutil.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
30 #include "algo.h"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
31
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
32 svr_runopts svr_opts; /* GLOBAL */
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
33
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 static void printhelp(const char * progname);
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
35 static void addportandaddress(char* spec);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37 static void printhelp(const char * progname) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39 fprintf(stderr, "Dropbear sshd v%s\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 "Usage: %s [options]\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41 "Options are:\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42 "-b bannerfile Display the contents of bannerfile"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 " before user login\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 " (default: none)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 #ifdef DROPBEAR_DSS
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 "-d dsskeyfile Use dsskeyfile for the dss host key\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 " (default: %s)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 #ifdef DROPBEAR_RSA
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 "-r rsakeyfile Use rsakeyfile for the rsa host key\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 " (default: %s)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
52 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 "-F Don't fork into background\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 #ifdef DISABLE_SYSLOG
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 "(Syslog support not compiled in, using stderr)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 #else
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57 "-E Log to stderr rather than syslog\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 #ifdef DO_MOTD
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 "-m Don't display the motd on login\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 "-w Disallow root logins\n"
121
9337c9f9a607 PAM improvements
Matt Johnston <matt@ucc.asn.au>
parents: 104
diff changeset
63 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 "-s Disable password logins\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
65 "-g Disable password logins for root\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
66 #endif
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
67 #ifdef ENABLE_SVR_LOCALTCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
68 "-j Disable local port forwarding\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
69 #endif
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
70 #ifdef ENABLE_SVR_REMOTETCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 "-k Disable remote port forwarding\n"
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
72 "-a Allow connections to forwarded ports from any host\n"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
73 #endif
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
74 "-p [address:]port\n"
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
75 " Listen on specified tcp port (and optionally address),\n"
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
76 " up to %d can be specified\n"
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
77 " (default port is %s if none specified)\n"
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
78 "-P PidFile Create pid file PidFile\n"
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
79 " (default %s)\n"
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
80 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
81 "-i Start for inetd\n"
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
82 #endif
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
83 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n"
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
84 "-K <keepalive> (0 is never, default %d)\n"
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
85 "-I <idle_timeout> (0 is never, default %d)\n"
94
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
86 #ifdef DEBUG_TRACE
510
b85507ade010 - Update manuals, include section on authorized_keys
Matt Johnston <matt@ucc.asn.au>
parents: 492
diff changeset
87 "-v verbose (compiled with DEBUG_TRACE)\n"
94
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
88 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89 ,DROPBEAR_VERSION, progname,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 #ifdef DROPBEAR_DSS
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 DSS_PRIV_FILENAME,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 #ifdef DROPBEAR_RSA
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94 RSA_PRIV_FILENAME,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 #endif
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
96 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
97 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
100 void svr_getopts(int argc, char ** argv) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102 unsigned int i;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 char ** next = 0;
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
104 int nextisport = 0;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
105 char* recv_window_arg = NULL;
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
106 char* keepalive_arg = NULL;
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
107 char* idle_timeout_arg = NULL;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 /* see printhelp() for options */
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
110 svr_opts.rsakeyfile = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
111 svr_opts.dsskeyfile = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
112 svr_opts.bannerfile = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
113 svr_opts.banner = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
114 svr_opts.forkbg = 1;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
115 svr_opts.norootlogin = 0;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
116 svr_opts.noauthpass = 0;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
117 svr_opts.norootpass = 0;
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
118 svr_opts.inetdmode = 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: 94
diff changeset
119 svr_opts.portcount = 0;
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 94
diff changeset
120 svr_opts.hostkey = NULL;
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
121 svr_opts.pidfile = DROPBEAR_PIDFILE;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
122 #ifdef ENABLE_SVR_LOCALTCPFWD
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
123 svr_opts.nolocaltcp = 0;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
124 #endif
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
125 #ifdef ENABLE_SVR_REMOTETCPFWD
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
126 svr_opts.noremotetcp = 0;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
127 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 /* not yet
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 24
diff changeset
129 opts.ipv4 = 1;
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 24
diff changeset
130 opts.ipv6 = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
131 */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 #ifdef DO_MOTD
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
133 svr_opts.domotd = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 #ifndef DISABLE_SYSLOG
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
136 svr_opts.usingsyslog = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
137 #endif
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
138 opts.recv_window = DEFAULT_RECV_WINDOW;
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
139 opts.keepalive_secs = DEFAULT_KEEPALIVE;
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
140 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
141
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
142 #ifdef ENABLE_SVR_REMOTETCPFWD
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
143 opts.listen_fwd_all = 0;
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
144 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 for (i = 1; i < (unsigned int)argc; i++) {
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
147 if (nextisport) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
148 addportandaddress(argv[i]);
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
149 nextisport = 0;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
150 continue;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
151 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
152
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 if (next) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154 *next = argv[i];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
155 if (*next == NULL) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
156 dropbear_exit("Invalid null argument");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
157 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
158 next = 0x00;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
159 continue;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 if (argv[i][0] == '-') {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 switch (argv[i][1]) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 case 'b':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
165 next = &svr_opts.bannerfile;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
166 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
167 #ifdef DROPBEAR_DSS
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
168 case 'd':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
169 next = &svr_opts.dsskeyfile;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
170 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 #ifdef DROPBEAR_RSA
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173 case 'r':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
174 next = &svr_opts.rsakeyfile;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
177 case 'F':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
178 svr_opts.forkbg = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
180 #ifndef DISABLE_SYSLOG
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
181 case 'E':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
182 svr_opts.usingsyslog = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
184 #endif
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
185 #ifdef ENABLE_SVR_LOCALTCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 case 'j':
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
187 svr_opts.nolocaltcp = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
188 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 #endif
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
190 #ifdef ENABLE_SVR_REMOTETCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
191 case 'k':
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
192 svr_opts.noremotetcp = 1;
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
193 break;
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
194 case 'a':
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
195 opts.listen_fwd_all = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
196 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
197 #endif
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
198 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
199 case 'i':
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
200 svr_opts.inetdmode = 1;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
201 break;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
202 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
203 case 'p':
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
204 nextisport = 1;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
205 break;
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
206 case 'P':
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
207 next = &svr_opts.pidfile;
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
208 break;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
209 #ifdef DO_MOTD
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
210 /* motd is displayed by default, -m turns it off */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
211 case 'm':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
212 svr_opts.domotd = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
213 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
214 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
215 case 'w':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
216 svr_opts.norootlogin = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
217 break;
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
218 case 'W':
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
219 next = &recv_window_arg;
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
220 break;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
221 case 'K':
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
222 next = &keepalive_arg;
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
223 break;
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
224 case 'I':
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
225 next = &idle_timeout_arg;
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
226 break;
121
9337c9f9a607 PAM improvements
Matt Johnston <matt@ucc.asn.au>
parents: 104
diff changeset
227 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH)
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
228 case 's':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
229 svr_opts.noauthpass = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
230 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
231 case 'g':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
232 svr_opts.norootpass = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
233 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
234 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
235 case 'h':
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
236 printhelp(argv[0]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
237 exit(EXIT_FAILURE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
238 break;
442
d82a2a44c684 Add -u option to specify /dev/urandom instead
Matt Johnston <matt@ucc.asn.au>
parents: 435
diff changeset
239 case 'u':
446
2cd2edfa11ee Just use /dev/urandom since that's what everyone ends up using anyway.
Matt Johnston <matt@ucc.asn.au>
parents: 442
diff changeset
240 /* backwards compatibility with old urandom option */
442
d82a2a44c684 Add -u option to specify /dev/urandom instead
Matt Johnston <matt@ucc.asn.au>
parents: 435
diff changeset
241 break;
94
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
242 #ifdef DEBUG_TRACE
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
243 case 'v':
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
244 debug_trace = 1;
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
245 break;
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
246 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
247 default:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
248 fprintf(stderr, "Unknown argument %s\n", argv[i]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
249 printhelp(argv[0]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
250 exit(EXIT_FAILURE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
251 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
252 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
253 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
254 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
255
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: 94
diff changeset
256 /* Set up listening ports */
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 94
diff changeset
257 if (svr_opts.portcount == 0) {
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 94
diff changeset
258 svr_opts.ports[0] = m_strdup(DROPBEAR_DEFPORT);
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
259 svr_opts.addresses[0] = m_strdup(DROPBEAR_DEFADDRESS);
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: 94
diff changeset
260 svr_opts.portcount = 1;
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 94
diff changeset
261 }
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
262
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
263 if (svr_opts.dsskeyfile == NULL) {
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
264 svr_opts.dsskeyfile = DSS_PRIV_FILENAME;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
265 }
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
266 if (svr_opts.rsakeyfile == NULL) {
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
267 svr_opts.rsakeyfile = RSA_PRIV_FILENAME;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
268 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
269
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
270 if (svr_opts.bannerfile) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
271 struct stat buf;
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
272 if (stat(svr_opts.bannerfile, &buf) != 0) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
273 dropbear_exit("Error opening banner file '%s'",
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
274 svr_opts.bannerfile);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
275 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
276
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
277 if (buf.st_size > MAX_BANNER_SIZE) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
278 dropbear_exit("Banner file too large, max is %d bytes",
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
279 MAX_BANNER_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
280 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
281
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
282 svr_opts.banner = buf_new(buf.st_size);
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
283 if (buf_readfile(svr_opts.banner, svr_opts.bannerfile)!=DROPBEAR_SUCCESS) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
284 dropbear_exit("Error reading banner file '%s'",
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
285 svr_opts.bannerfile);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
286 }
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
287 buf_setpos(svr_opts.banner, 0);
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
288
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
289 }
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
290
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
291 if (recv_window_arg) {
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
292 opts.recv_window = atol(recv_window_arg);
492
b956d6151600 Replace calls to strtoul() with a helper m_str_to_uint()
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
293 if (opts.recv_window == 0 || opts.recv_window > MAX_RECV_WINDOW) {
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
294 dropbear_exit("Bad recv window '%s'", recv_window_arg);
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
295 }
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
296 }
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
297
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
298 if (keepalive_arg) {
492
b956d6151600 Replace calls to strtoul() with a helper m_str_to_uint()
Matt Johnston <matt@ucc.asn.au>
parents: 454
diff changeset
299 if (m_str_to_uint(keepalive_arg, &opts.keepalive_secs) == DROPBEAR_FAILURE) {
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
300 dropbear_exit("Bad keepalive '%s'", keepalive_arg);
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
301 }
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
302 }
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
303
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
304 if (idle_timeout_arg) {
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
305 if (m_str_to_uint(idle_timeout_arg, &opts.idle_timeout_secs) == DROPBEAR_FAILURE) {
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
306 dropbear_exit("Bad idle_timeout '%s'", idle_timeout_arg);
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
307 }
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
308 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
309 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
310
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
311 static void addportandaddress(char* spec) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
312
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
313 char *myspec = NULL;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
314
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
315 if (svr_opts.portcount < DROPBEAR_MAX_PORTS) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
316
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
317 /* We don't free it, it becomes part of the runopt state */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
318 myspec = m_strdup(spec);
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
319
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
320 /* search for ':', that separates address and port */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
321 svr_opts.ports[svr_opts.portcount] = strchr(myspec, ':');
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
322
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
323 if (svr_opts.ports[svr_opts.portcount] == NULL) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
324 /* no ':' -> the whole string specifies just a port */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
325 svr_opts.ports[svr_opts.portcount] = myspec;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
326 } else {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
327 /* Split the address/port */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
328 svr_opts.ports[svr_opts.portcount][0] = '\0';
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
329 svr_opts.ports[svr_opts.portcount]++;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
330 svr_opts.addresses[svr_opts.portcount] = myspec;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
331 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
332
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
333 if (svr_opts.addresses[svr_opts.portcount] == NULL) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
334 /* no address given -> fill in the default address */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
335 svr_opts.addresses[svr_opts.portcount] = m_strdup(DROPBEAR_DEFADDRESS);
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
336 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
337
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
338 if (svr_opts.ports[svr_opts.portcount][0] == '\0') {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
339 /* empty port -> exit */
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
340 dropbear_exit("Bad port");
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
341 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
342
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
343 svr_opts.portcount++;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
344 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
345 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
346
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
347 static void disablekey(int type, const char* filename) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
348
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
349 int i;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
350
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
351 for (i = 0; sshhostkey[i].name != NULL; i++) {
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
352 if (sshhostkey[i].val == type) {
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
353 sshhostkey[i].usable = 0;
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
354 break;
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
355 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
356 }
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: 94
diff changeset
357 dropbear_log(LOG_WARNING, "Failed reading '%s', disabling %s", filename,
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
358 type == DROPBEAR_SIGNKEY_DSS ? "DSS" : "RSA");
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
359 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
360
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: 94
diff changeset
361 /* Must be called after syslog/etc is working */
72dc22f56858 Change the way we load keys/ports so we don't print error messages into our
Matt Johnston <matt@ucc.asn.au>
parents: 94
diff changeset
362 void loadhostkeys() {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
363
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
364 int ret;
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
365 int type;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
366
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 121
diff changeset
367 TRACE(("enter loadhostkeys"))
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
368
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: 94
diff changeset
369 svr_opts.hostkey = new_sign_key();
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
370
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
371 #ifdef DROPBEAR_RSA
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
372 type = DROPBEAR_SIGNKEY_RSA;
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: 94
diff changeset
373 ret = readhostkey(svr_opts.rsakeyfile, svr_opts.hostkey, &type);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
374 if (ret == DROPBEAR_FAILURE) {
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: 94
diff changeset
375 disablekey(DROPBEAR_SIGNKEY_RSA, svr_opts.rsakeyfile);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
376 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
377 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
378 #ifdef DROPBEAR_DSS
91
dc68f7624f17 Stupid DSS hostkey bug fixed.
Matt Johnston <matt@ucc.asn.au>
parents: 71
diff changeset
379 type = DROPBEAR_SIGNKEY_DSS;
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: 94
diff changeset
380 ret = readhostkey(svr_opts.dsskeyfile, svr_opts.hostkey, &type);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
381 if (ret == DROPBEAR_FAILURE) {
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: 94
diff changeset
382 disablekey(DROPBEAR_SIGNKEY_DSS, svr_opts.dsskeyfile);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
383 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
384 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
385
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
386 if ( 1
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
387 #ifdef DROPBEAR_DSS
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: 94
diff changeset
388 && svr_opts.hostkey->dsskey == NULL
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
389 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
390 #ifdef DROPBEAR_RSA
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: 94
diff changeset
391 && svr_opts.hostkey->rsakey == NULL
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
392 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
393 ) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
394 dropbear_exit("No hostkeys available");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
395 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
396
165
0cfba3034be5 Fixed DEBUG_TRACE macro so that we don't get semicolons left about the place
Matt Johnston <matt@ucc.asn.au>
parents: 121
diff changeset
397 TRACE(("leave loadhostkeys"))
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
398 }