annotate svr-runopts.c @ 842:7f8f8f2b7a35

Merge
author Matt Johnston <matt@ucc.asn.au>
date Fri, 01 Nov 2013 00:14:48 +0800
parents 75509065db53
children b298bb438625
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"
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
31 #include "ecdsa.h"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
32
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
33 svr_runopts svr_opts; /* GLOBAL */
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
34
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 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
36 static void addportandaddress(char* spec);
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
37 static void loadhostkey(const char *keyfile, int fatal_duplicate);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
38 static void addhostkey(const char *keyfile);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
39
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
40 static void printhelp(const char * progname) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
41
716
af4ef98b8591 Add URL to usage text
Matt Johnston <matt@ucc.asn.au>
parents: 706
diff changeset
42 fprintf(stderr, "Dropbear server v%s https://matt.ucc.asn.au/dropbear/dropbear.html\n"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
43 "Usage: %s [options]\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
44 "-b bannerfile Display the contents of bannerfile"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
45 " before user login\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
46 " (default: none)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
47 #ifdef DROPBEAR_DSS
594
a98a2138364a Improve capitalisation for all logged strings
Matt Johnston <matt@ucc.asn.au>
parents: 575
diff changeset
48 "-d dsskeyfile Use dsskeyfile for the DSS host key\n"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 " (default: %s)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
51 #ifdef DROPBEAR_RSA
594
a98a2138364a Improve capitalisation for all logged strings
Matt Johnston <matt@ucc.asn.au>
parents: 575
diff changeset
52 "-r rsakeyfile Use rsakeyfile for the RSA host key\n"
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
53 " (default: %s)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
54 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
55 "-F Don't fork into background\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 #ifdef DISABLE_SYSLOG
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
57 "(Syslog support not compiled in, using stderr)\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 #else
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 "-E Log to stderr rather than syslog\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
60 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
61 #ifdef DO_MOTD
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
62 "-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
63 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
64 "-w Disallow root logins\n"
121
9337c9f9a607 PAM improvements
Matt Johnston <matt@ucc.asn.au>
parents: 104
diff changeset
65 #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
66 "-s Disable password logins\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
67 "-g Disable password logins for root\n"
692
c58a15983808 Allow configuring "allow blank password option" at runtime
Paul Eggleton <paul.eggleton@linux.intel.com>
parents: 671
diff changeset
68 "-B Allow blank password logins\n"
4
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_LOCALTCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
71 "-j Disable local port forwarding\n"
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
72 #endif
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
73 #ifdef ENABLE_SVR_REMOTETCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
74 "-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
75 "-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
76 #endif
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
77 "-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
78 " 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
79 " 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
80 " (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
81 "-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
82 " (default %s)\n"
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
83 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
84 "-i Start for inetd\n"
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
85 #endif
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
86 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n"
622
e27d7fb23376 Mention that the value is in seconds
Matt Johnston <matt@ucc.asn.au>
parents: 594
diff changeset
87 "-K <keepalive> (0 is never, default %d, in seconds)\n"
e27d7fb23376 Mention that the value is in seconds
Matt Johnston <matt@ucc.asn.au>
parents: 594
diff changeset
88 "-I <idle_timeout> (0 is never, default %d, in seconds)\n"
94
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
89 #ifdef DEBUG_TRACE
510
b85507ade010 - Update manuals, include section on authorized_keys
Matt Johnston <matt@ucc.asn.au>
parents: 492
diff changeset
90 "-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
91 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92 ,DROPBEAR_VERSION, progname,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 #ifdef DROPBEAR_DSS
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
94 DSS_PRIV_FILENAME,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 #ifdef DROPBEAR_RSA
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
97 RSA_PRIV_FILENAME,
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
98 #endif
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
99 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
100 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
101 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
103 void svr_getopts(int argc, char ** argv) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 unsigned int i;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 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
107 int nextisport = 0;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
108 char* recv_window_arg = NULL;
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
109 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
110 char* idle_timeout_arg = NULL;
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
111 char* keyfile = NULL;
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
112
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 /* see printhelp() for options */
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
115 svr_opts.bannerfile = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
116 svr_opts.banner = NULL;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
117 svr_opts.forkbg = 1;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
118 svr_opts.norootlogin = 0;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
119 svr_opts.noauthpass = 0;
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
120 svr_opts.norootpass = 0;
692
c58a15983808 Allow configuring "allow blank password option" at runtime
Paul Eggleton <paul.eggleton@linux.intel.com>
parents: 671
diff changeset
121 svr_opts.allowblankpass = 0;
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
122 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
123 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
124 svr_opts.hostkey = NULL;
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
125 svr_opts.pidfile = DROPBEAR_PIDFILE;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
126 #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
127 svr_opts.nolocaltcp = 0;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
128 #endif
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
129 #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
130 svr_opts.noremotetcp = 0;
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
131 #endif
575
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 568
diff changeset
132 #ifndef DISABLE_ZLIB
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 568
diff changeset
133 opts.enable_compress = 1;
f9b5dc0cba61 - Disable compression for non-final multihops
Matt Johnston <matt@ucc.asn.au>
parents: 568
diff changeset
134 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
135 /* not yet
33
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 24
diff changeset
136 opts.ipv4 = 1;
f789045062e6 Progressing client support
Matt Johnston <matt@ucc.asn.au>
parents: 24
diff changeset
137 opts.ipv6 = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 */
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 #ifdef DO_MOTD
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
140 svr_opts.domotd = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 #ifndef DISABLE_SYSLOG
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
143 svr_opts.usingsyslog = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 #endif
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
145 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
146 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
147 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
148
258
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
149 #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
150 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
151 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 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
154 if (nextisport) {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
155 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
156 nextisport = 0;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
157 continue;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
158 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
159
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
160 if (next) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
161 *next = argv[i];
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
162 if (*next == NULL) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
163 dropbear_exit("Invalid null argument");
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
164 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
165 next = 0x00;
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
166
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
167 if (keyfile) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
168 addhostkey(keyfile);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
169 keyfile = NULL;
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
170 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
171 continue;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
172 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
173
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
174 if (argv[i][0] == '-') {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
175 switch (argv[i][1]) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
176 case 'b':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
177 next = &svr_opts.bannerfile;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
178 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
179 case 'd':
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
180 case 'r':
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
181 next = &keyfile;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
182 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
183 case 'F':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
184 svr_opts.forkbg = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
185 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
186 #ifndef DISABLE_SYSLOG
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
187 case 'E':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
188 svr_opts.usingsyslog = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
189 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
190 #endif
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
191 #ifdef ENABLE_SVR_LOCALTCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
192 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
193 svr_opts.nolocaltcp = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
194 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
195 #endif
271
be18c7dd486e Fix up #ifdefs for tcp forwarding
Matt Johnston <matt@ucc.asn.au>
parents: 258
diff changeset
196 #ifdef ENABLE_SVR_REMOTETCPFWD
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
197 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
198 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
199 break;
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
200 case 'a':
306499676384 * add -g (dbclient) and -a (dropbear) options for allowing non-local
Matt Johnston <matt@ucc.asn.au>
parents: 165
diff changeset
201 opts.listen_fwd_all = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
202 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
203 #endif
71
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
204 #ifdef INETD_MODE
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
205 case 'i':
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
206 svr_opts.inetdmode = 1;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
207 break;
ac96bc733e71 adding inetd mode back from 0.43
Matt Johnston <matt@ucc.asn.au>
parents: 68
diff changeset
208 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
209 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
210 nextisport = 1;
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
211 break;
323
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
212 case 'P':
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
213 next = &svr_opts.pidfile;
3bfbe95f9a14 Add -P pidfile patch from Swen Schillig
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
214 break;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
215 #ifdef DO_MOTD
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
216 /* 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
217 case 'm':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
218 svr_opts.domotd = 0;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
219 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
220 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
221 case 'w':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
222 svr_opts.norootlogin = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
223 break;
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
224 case 'W':
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
225 next = &recv_window_arg;
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
226 break;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
227 case 'K':
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
228 next = &keepalive_arg;
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
229 break;
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
230 case 'I':
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
231 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
232 break;
121
9337c9f9a607 PAM improvements
Matt Johnston <matt@ucc.asn.au>
parents: 104
diff changeset
233 #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
234 case 's':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
235 svr_opts.noauthpass = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
236 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
237 case 'g':
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
238 svr_opts.norootpass = 1;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
239 break;
692
c58a15983808 Allow configuring "allow blank password option" at runtime
Paul Eggleton <paul.eggleton@linux.intel.com>
parents: 671
diff changeset
240 case 'B':
c58a15983808 Allow configuring "allow blank password option" at runtime
Paul Eggleton <paul.eggleton@linux.intel.com>
parents: 671
diff changeset
241 svr_opts.allowblankpass = 1;
c58a15983808 Allow configuring "allow blank password option" at runtime
Paul Eggleton <paul.eggleton@linux.intel.com>
parents: 671
diff changeset
242 break;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
243 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
244 case 'h':
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
245 printhelp(argv[0]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
246 exit(EXIT_FAILURE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
247 break;
442
d82a2a44c684 Add -u option to specify /dev/urandom instead
Matt Johnston <matt@ucc.asn.au>
parents: 435
diff changeset
248 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
249 /* 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
250 break;
94
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
251 #ifdef DEBUG_TRACE
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
252 case 'v':
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
253 debug_trace = 1;
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
254 break;
c85c88500ea6 DEBUG_TRACE now only triggers with -v on the cmdline
Matt Johnston <matt@ucc.asn.au>
parents: 91
diff changeset
255 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
256 default:
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
257 fprintf(stderr, "Unknown argument %s\n", argv[i]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
258 printhelp(argv[0]);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
259 exit(EXIT_FAILURE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
260 break;
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
261 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
262 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
263 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
264
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
265 /* 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
266 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
267 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
268 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
269 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
270 }
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
271
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
272 if (svr_opts.bannerfile) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
273 struct stat buf;
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
274 if (stat(svr_opts.bannerfile, &buf) != 0) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
275 dropbear_exit("Error opening banner file '%s'",
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
276 svr_opts.bannerfile);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
277 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
278
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
279 if (buf.st_size > MAX_BANNER_SIZE) {
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
280 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
281 MAX_BANNER_SIZE);
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
282 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
283
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
284 svr_opts.banner = buf_new(buf.st_size);
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
285 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
286 dropbear_exit("Error reading banner file '%s'",
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
287 svr_opts.bannerfile);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
288 }
24
469950e86d0f switching to global vars
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
289 buf_setpos(svr_opts.banner, 0);
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
290 }
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
291
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
292 if (recv_window_arg) {
449
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
293 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
294 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
295 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
296 }
3e6c536bc023 Add -W <windowsize> argument and document it.
Matt Johnston <matt@ucc.asn.au>
parents: 446
diff changeset
297 }
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
298
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
299 if (keepalive_arg) {
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
300 unsigned int val;
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
301 if (m_str_to_uint(keepalive_arg, &val) == DROPBEAR_FAILURE) {
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
302 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
303 }
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
304 opts.keepalive_secs = val;
454
7e43f5e473b9 - Add -K keepalive flag for dropbear and dbclient
Matt Johnston <matt@ucc.asn.au>
parents: 449
diff changeset
305 }
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
306
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
307 if (idle_timeout_arg) {
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
308 unsigned int val;
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
309 if (m_str_to_uint(idle_timeout_arg, &val) == DROPBEAR_FAILURE) {
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
310 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
311 }
568
005530560594 Rearrange getaddrstring() etc
Matt Johnston <matt@ucc.asn.au>
parents: 513
diff changeset
312 opts.idle_timeout_secs = val;
513
a3748e54273c Idle timeout patch from Farrell Aultman. Needs testing, unsure if server
Matt Johnston <matt@ucc.asn.au>
parents: 510
diff changeset
313 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
314 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
315
434
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
316 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
317
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
318 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
319
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
320 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
321
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
322 /* 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
323 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
324
706
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
325 if (myspec[0] == '[') {
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
326 myspec++;
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
327 svr_opts.ports[svr_opts.portcount] = strchr(myspec, ']');
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
328 if (svr_opts.ports[svr_opts.portcount] == NULL) {
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
329 /* Unmatched [ -> exit */
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
330 dropbear_exit("Bad listen address");
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
331 }
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
332 svr_opts.ports[svr_opts.portcount][0] = '\0';
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
333 svr_opts.ports[svr_opts.portcount]++;
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
334 if (svr_opts.ports[svr_opts.portcount][0] != ':') {
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
335 /* Missing port -> exit */
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
336 dropbear_exit("Missing port");
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
337 }
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
338 } else {
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
339 /* search for ':', that separates address and port */
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
340 svr_opts.ports[svr_opts.portcount] = strrchr(myspec, ':');
002cf09827c0 Allow specifying server "-p" options with ipv6 bracket notation,
Matt Johnston <matt@ucc.asn.au>
parents: 692
diff changeset
341 }
434
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 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
344 /* 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
345 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
346 } else {
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
347 /* 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
348 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
349 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
350 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
351 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
352
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
353 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
354 /* 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
355 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
356 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
357
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
358 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
359 /* 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
360 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
361 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
362
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
363 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
364 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
365 }
0aaaf68e97dc Add -p [address:]port option for binding to addresses, patch from
Matt Johnston <matt@ucc.asn.au>
parents: 271
diff changeset
366
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
367 static void disablekey(int type) {
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
368 int i;
802
4029d3432a4f Fix broken disablekey()
Matt Johnston <matt@ucc.asn.au>
parents: 795
diff changeset
369 TRACE(("Disabling key type %d", type))
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
370 for (i = 0; sshhostkey[i].name != NULL; i++) {
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
371 if (sshhostkey[i].val == type) {
802
4029d3432a4f Fix broken disablekey()
Matt Johnston <matt@ucc.asn.au>
parents: 795
diff changeset
372 sshhostkey[i].usable = 0;
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
373 break;
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
374 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
375 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
376 }
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
377
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
378 static void loadhostkey_helper(const char *name, void** src, void** dst, int fatal_duplicate) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
379 if (*dst) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
380 if (fatal_duplicate) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
381 dropbear_exit("Only one %s key can be specified", name);
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
382 }
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
383 } else {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
384 *dst = *src;
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
385 *src = NULL;
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
386 }
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
387
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
388 }
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
389
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
390 /* Must be called after syslog/etc is working */
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
391 static void loadhostkey(const char *keyfile, int fatal_duplicate) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
392 sign_key * read_key = new_sign_key();
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
393 int type = DROPBEAR_SIGNKEY_ANY;
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
394 if (readhostkey(keyfile, read_key, &type) == DROPBEAR_FAILURE) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
395 dropbear_log(LOG_WARNING, "Failed loading %s", keyfile);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
396 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
397
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
398 #ifdef DROPBEAR_RSA
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
399 if (type == DROPBEAR_SIGNKEY_RSA) {
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
400 loadhostkey_helper("RSA", &read_key->rsakey, &svr_opts.hostkey->rsakey, fatal_duplicate);
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
401 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
402 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
403
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
404 #ifdef DROPBEAR_DSS
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
405 if (type == DROPBEAR_SIGNKEY_DSS) {
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
406 loadhostkey_helper("DSS", &read_key->dsskey, &svr_opts.hostkey->dsskey, fatal_duplicate);
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
407 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
408 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
409
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
410 #ifdef DROPBEAR_ECDSA
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
411 #ifdef DROPBEAR_ECC_256
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
412 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP256) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
413 loadhostkey_helper("ECDSA256", &read_key->ecckey256, &svr_opts.hostkey->ecckey256, fatal_duplicate);
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
414 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
415 #endif
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
416 #ifdef DROPBEAR_ECC_384
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
417 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP384) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
418 loadhostkey_helper("ECDSA384", &read_key->ecckey384, &svr_opts.hostkey->ecckey384, fatal_duplicate);
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
419 }
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
420 #endif
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
421 #ifdef DROPBEAR_ECC_521
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
422 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) {
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
423 loadhostkey_helper("ECDSA521", &read_key->ecckey521, &svr_opts.hostkey->ecckey521, fatal_duplicate);
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
424 }
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
425 #endif
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
426 #endif // DROPBEAR_ECDSA
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
427 sign_key_free(read_key);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
428 TRACE(("leave loadhostkey"))
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
429 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
430
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
431 static void addhostkey(const char *keyfile) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
432 if (svr_opts.num_hostkey_files >= MAX_HOSTKEYS) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
433 dropbear_exit("Too many hostkeys");
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
434 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
435 svr_opts.hostkey_files[svr_opts.num_hostkey_files] = m_strdup(keyfile);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
436 svr_opts.num_hostkey_files++;
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
437 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
438
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
439 void load_all_hostkeys() {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
440 int i;
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
441
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
442 svr_opts.hostkey = new_sign_key();
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
443
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
444 for (i = 0; i < svr_opts.num_hostkey_files; i++) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
445 char *hostkey_file = svr_opts.hostkey_files[i];
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
446 loadhostkey(hostkey_file, 1);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
447 m_free(hostkey_file);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
448 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
449
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
450 #ifdef DROPBEAR_RSA
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
451 loadhostkey(RSA_PRIV_FILENAME, 0);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
452 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
453
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
454 #ifdef DROPBEAR_DSS
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
455 loadhostkey(DSS_PRIV_FILENAME, 0);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
456 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
457
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
458 #ifdef DROPBEAR_ECDSA
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
459 loadhostkey(ECDSA_PRIV_FILENAME, 0);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
460 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
461
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
462 #ifdef DROPBEAR_RSA
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
463 if (!svr_opts.hostkey->rsakey) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
464 disablekey(DROPBEAR_SIGNKEY_RSA);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
465 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
466 #endif
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
467 #ifdef DROPBEAR_DSS
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
468 if (!svr_opts.hostkey->dsskey) {
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
469 disablekey(DROPBEAR_SIGNKEY_RSA);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
470 }
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
471 #endif
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
472 #ifdef DROPBEAR_ECDSA
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
473 #ifdef DROPBEAR_ECC_256
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
474 if (!svr_opts.hostkey->ecckey256) {
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
475 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP256);
47
4b53a43f0082 - client pubkey auth works
Matt Johnston <matt@ucc.asn.au>
parents: 33
diff changeset
476 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
477 #endif
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
478 #ifdef DROPBEAR_ECC_384
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
479 if (!svr_opts.hostkey->ecckey384) {
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
480 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP384);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
481 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
482 #endif
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
483 #ifdef DROPBEAR_ECC_521
807
75509065db53 have separate ecdsa keys for each size
Matt Johnston <matt@ucc.asn.au>
parents: 802
diff changeset
484 if (!svr_opts.hostkey->ecckey521) {
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
485 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP521);
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
486 }
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
487 #endif
795
7f604f9b3756 ecdsa is working
Matt Johnston <matt@ucc.asn.au>
parents: 716
diff changeset
488 #endif
4
fe6bca95afa7 Makefile.in contains updated files required
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
489 }