Mercurial > dropbear
comparison svr-runopts.c @ 1295:750ec4ec4cbe
Convert #ifdef to #if, other build changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Wed, 04 May 2016 15:33:40 +0200 |
parents | ee2ffa044c7e |
children | 3fdd8c5a0195 e8f67918fdc9 |
comparison
equal
deleted
inserted
replaced
1294:56aba7dedbea | 1295:750ec4ec4cbe |
---|---|
44 "-b bannerfile Display the contents of bannerfile" | 44 "-b bannerfile Display the contents of bannerfile" |
45 " before user login\n" | 45 " before user login\n" |
46 " (default: none)\n" | 46 " (default: none)\n" |
47 "-r keyfile Specify hostkeys (repeatable)\n" | 47 "-r keyfile Specify hostkeys (repeatable)\n" |
48 " defaults: \n" | 48 " defaults: \n" |
49 #ifdef DROPBEAR_DSS | 49 #if DROPBEAR_DSS |
50 " dss %s\n" | 50 " dss %s\n" |
51 #endif | 51 #endif |
52 #ifdef DROPBEAR_RSA | 52 #if DROPBEAR_RSA |
53 " rsa %s\n" | 53 " rsa %s\n" |
54 #endif | 54 #endif |
55 #ifdef DROPBEAR_ECDSA | 55 #if DROPBEAR_ECDSA |
56 " ecdsa %s\n" | 56 " ecdsa %s\n" |
57 #endif | 57 #endif |
58 #ifdef DROPBEAR_DELAY_HOSTKEY | 58 #if DROPBEAR_DELAY_HOSTKEY |
59 "-R Create hostkeys as required\n" | 59 "-R Create hostkeys as required\n" |
60 #endif | 60 #endif |
61 "-F Don't fork into background\n" | 61 "-F Don't fork into background\n" |
62 #ifdef DISABLE_SYSLOG | 62 #ifdef DISABLE_SYSLOG |
63 "(Syslog support not compiled in, using stderr)\n" | 63 "(Syslog support not compiled in, using stderr)\n" |
66 #endif | 66 #endif |
67 #ifdef DO_MOTD | 67 #ifdef DO_MOTD |
68 "-m Don't display the motd on login\n" | 68 "-m Don't display the motd on login\n" |
69 #endif | 69 #endif |
70 "-w Disallow root logins\n" | 70 "-w Disallow root logins\n" |
71 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH) | 71 #if DROPBEAR_SVR_PASSWORD_AUTH || DROPBEAR_SVR_PAM_AUTH |
72 "-s Disable password logins\n" | 72 "-s Disable password logins\n" |
73 "-g Disable password logins for root\n" | 73 "-g Disable password logins for root\n" |
74 "-B Allow blank password logins\n" | 74 "-B Allow blank password logins\n" |
75 #endif | 75 #endif |
76 #ifdef ENABLE_SVR_LOCALTCPFWD | 76 #if DROPBEAR_SVR_LOCALTCPFWD |
77 "-j Disable local port forwarding\n" | 77 "-j Disable local port forwarding\n" |
78 #endif | 78 #endif |
79 #ifdef ENABLE_SVR_REMOTETCPFWD | 79 #if DROPBEAR_SVR_REMOTETCPFWD |
80 "-k Disable remote port forwarding\n" | 80 "-k Disable remote port forwarding\n" |
81 "-a Allow connections to forwarded ports from any host\n" | 81 "-a Allow connections to forwarded ports from any host\n" |
82 "-c command Force executed command\n" | 82 "-c command Force executed command\n" |
83 #endif | 83 #endif |
84 "-p [address:]port\n" | 84 "-p [address:]port\n" |
92 #endif | 92 #endif |
93 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n" | 93 "-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n" |
94 "-K <keepalive> (0 is never, default %d, in seconds)\n" | 94 "-K <keepalive> (0 is never, default %d, in seconds)\n" |
95 "-I <idle_timeout> (0 is never, default %d, in seconds)\n" | 95 "-I <idle_timeout> (0 is never, default %d, in seconds)\n" |
96 "-V Version\n" | 96 "-V Version\n" |
97 #ifdef DEBUG_TRACE | 97 #if DEBUG_TRACE |
98 "-v verbose (compiled with DEBUG_TRACE)\n" | 98 "-v verbose (compiled with DEBUG_TRACE)\n" |
99 #endif | 99 #endif |
100 ,DROPBEAR_VERSION, progname, | 100 ,DROPBEAR_VERSION, progname, |
101 #ifdef DROPBEAR_DSS | 101 #if DROPBEAR_DSS |
102 DSS_PRIV_FILENAME, | 102 DSS_PRIV_FILENAME, |
103 #endif | 103 #endif |
104 #ifdef DROPBEAR_RSA | 104 #if DROPBEAR_RSA |
105 RSA_PRIV_FILENAME, | 105 RSA_PRIV_FILENAME, |
106 #endif | 106 #endif |
107 #ifdef DROPBEAR_ECDSA | 107 #if DROPBEAR_ECDSA |
108 ECDSA_PRIV_FILENAME, | 108 ECDSA_PRIV_FILENAME, |
109 #endif | 109 #endif |
110 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE, | 110 DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE, |
111 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT); | 111 DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT); |
112 } | 112 } |
135 svr_opts.inetdmode = 0; | 135 svr_opts.inetdmode = 0; |
136 svr_opts.portcount = 0; | 136 svr_opts.portcount = 0; |
137 svr_opts.hostkey = NULL; | 137 svr_opts.hostkey = NULL; |
138 svr_opts.delay_hostkey = 0; | 138 svr_opts.delay_hostkey = 0; |
139 svr_opts.pidfile = DROPBEAR_PIDFILE; | 139 svr_opts.pidfile = DROPBEAR_PIDFILE; |
140 #ifdef ENABLE_SVR_LOCALTCPFWD | 140 #if DROPBEAR_SVR_LOCALTCPFWD |
141 svr_opts.nolocaltcp = 0; | 141 svr_opts.nolocaltcp = 0; |
142 #endif | 142 #endif |
143 #ifdef ENABLE_SVR_REMOTETCPFWD | 143 #if DROPBEAR_SVR_REMOTETCPFWD |
144 svr_opts.noremotetcp = 0; | 144 svr_opts.noremotetcp = 0; |
145 #endif | 145 #endif |
146 | 146 |
147 #ifndef DISABLE_ZLIB | 147 #ifndef DISABLE_ZLIB |
148 #if DROPBEAR_SERVER_DELAY_ZLIB | |
149 opts.compress_mode = DROPBEAR_COMPRESS_DELAYED; | 148 opts.compress_mode = DROPBEAR_COMPRESS_DELAYED; |
150 #else | |
151 opts.compress_mode = DROPBEAR_COMPRESS_ON; | |
152 #endif | |
153 #endif | 149 #endif |
154 | 150 |
155 /* not yet | 151 /* not yet |
156 opts.ipv4 = 1; | 152 opts.ipv4 = 1; |
157 opts.ipv6 = 1; | 153 opts.ipv6 = 1; |
164 #endif | 160 #endif |
165 opts.recv_window = DEFAULT_RECV_WINDOW; | 161 opts.recv_window = DEFAULT_RECV_WINDOW; |
166 opts.keepalive_secs = DEFAULT_KEEPALIVE; | 162 opts.keepalive_secs = DEFAULT_KEEPALIVE; |
167 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT; | 163 opts.idle_timeout_secs = DEFAULT_IDLE_TIMEOUT; |
168 | 164 |
169 #ifdef ENABLE_SVR_REMOTETCPFWD | 165 #if DROPBEAR_SVR_REMOTETCPFWD |
170 opts.listen_fwd_all = 0; | 166 opts.listen_fwd_all = 0; |
171 #endif | 167 #endif |
172 | 168 |
173 for (i = 1; i < (unsigned int)argc; i++) { | 169 for (i = 1; i < (unsigned int)argc; i++) { |
174 if (argv[i][0] != '-' || argv[i][1] == '\0') | 170 if (argv[i][0] != '-' || argv[i][1] == '\0') |
195 #ifndef DISABLE_SYSLOG | 191 #ifndef DISABLE_SYSLOG |
196 case 'E': | 192 case 'E': |
197 opts.usingsyslog = 0; | 193 opts.usingsyslog = 0; |
198 break; | 194 break; |
199 #endif | 195 #endif |
200 #ifdef ENABLE_SVR_LOCALTCPFWD | 196 #if DROPBEAR_SVR_LOCALTCPFWD |
201 case 'j': | 197 case 'j': |
202 svr_opts.nolocaltcp = 1; | 198 svr_opts.nolocaltcp = 1; |
203 break; | 199 break; |
204 #endif | 200 #endif |
205 #ifdef ENABLE_SVR_REMOTETCPFWD | 201 #if DROPBEAR_SVR_REMOTETCPFWD |
206 case 'k': | 202 case 'k': |
207 svr_opts.noremotetcp = 1; | 203 svr_opts.noremotetcp = 1; |
208 break; | 204 break; |
209 case 'a': | 205 case 'a': |
210 opts.listen_fwd_all = 1; | 206 opts.listen_fwd_all = 1; |
237 next = &keepalive_arg; | 233 next = &keepalive_arg; |
238 break; | 234 break; |
239 case 'I': | 235 case 'I': |
240 next = &idle_timeout_arg; | 236 next = &idle_timeout_arg; |
241 break; | 237 break; |
242 #if defined(ENABLE_SVR_PASSWORD_AUTH) || defined(ENABLE_SVR_PAM_AUTH) | 238 #if DROPBEAR_SVR_PASSWORD_AUTH || DROPBEAR_SVR_PAM_AUTH |
243 case 's': | 239 case 's': |
244 svr_opts.noauthpass = 1; | 240 svr_opts.noauthpass = 1; |
245 break; | 241 break; |
246 case 'g': | 242 case 'g': |
247 svr_opts.norootpass = 1; | 243 svr_opts.norootpass = 1; |
255 exit(EXIT_SUCCESS); | 251 exit(EXIT_SUCCESS); |
256 break; | 252 break; |
257 case 'u': | 253 case 'u': |
258 /* backwards compatibility with old urandom option */ | 254 /* backwards compatibility with old urandom option */ |
259 break; | 255 break; |
260 #ifdef DEBUG_TRACE | 256 #if DEBUG_TRACE |
261 case 'v': | 257 case 'v': |
262 debug_trace = 1; | 258 debug_trace = 1; |
263 break; | 259 break; |
264 #endif | 260 #endif |
265 case 'V': | 261 case 'V': |
441 if (!svr_opts.delay_hostkey) { | 437 if (!svr_opts.delay_hostkey) { |
442 dropbear_log(LOG_WARNING, "Failed loading %s", keyfile); | 438 dropbear_log(LOG_WARNING, "Failed loading %s", keyfile); |
443 } | 439 } |
444 } | 440 } |
445 | 441 |
446 #ifdef DROPBEAR_RSA | 442 #if DROPBEAR_RSA |
447 if (type == DROPBEAR_SIGNKEY_RSA) { | 443 if (type == DROPBEAR_SIGNKEY_RSA) { |
448 loadhostkey_helper("RSA", (void**)&read_key->rsakey, (void**)&svr_opts.hostkey->rsakey, fatal_duplicate); | 444 loadhostkey_helper("RSA", (void**)&read_key->rsakey, (void**)&svr_opts.hostkey->rsakey, fatal_duplicate); |
449 } | 445 } |
450 #endif | 446 #endif |
451 | 447 |
452 #ifdef DROPBEAR_DSS | 448 #if DROPBEAR_DSS |
453 if (type == DROPBEAR_SIGNKEY_DSS) { | 449 if (type == DROPBEAR_SIGNKEY_DSS) { |
454 loadhostkey_helper("DSS", (void**)&read_key->dsskey, (void**)&svr_opts.hostkey->dsskey, fatal_duplicate); | 450 loadhostkey_helper("DSS", (void**)&read_key->dsskey, (void**)&svr_opts.hostkey->dsskey, fatal_duplicate); |
455 } | 451 } |
456 #endif | 452 #endif |
457 | 453 |
458 #ifdef DROPBEAR_ECDSA | 454 #if DROPBEAR_ECDSA |
459 #ifdef DROPBEAR_ECC_256 | 455 #if DROPBEAR_ECC_256 |
460 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP256) { | 456 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP256) { |
461 loadhostkey_helper("ECDSA256", (void**)&read_key->ecckey256, (void**)&svr_opts.hostkey->ecckey256, fatal_duplicate); | 457 loadhostkey_helper("ECDSA256", (void**)&read_key->ecckey256, (void**)&svr_opts.hostkey->ecckey256, fatal_duplicate); |
462 } | 458 } |
463 #endif | 459 #endif |
464 #ifdef DROPBEAR_ECC_384 | 460 #if DROPBEAR_ECC_384 |
465 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP384) { | 461 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP384) { |
466 loadhostkey_helper("ECDSA384", (void**)&read_key->ecckey384, (void**)&svr_opts.hostkey->ecckey384, fatal_duplicate); | 462 loadhostkey_helper("ECDSA384", (void**)&read_key->ecckey384, (void**)&svr_opts.hostkey->ecckey384, fatal_duplicate); |
467 } | 463 } |
468 #endif | 464 #endif |
469 #ifdef DROPBEAR_ECC_521 | 465 #if DROPBEAR_ECC_521 |
470 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) { | 466 if (type == DROPBEAR_SIGNKEY_ECDSA_NISTP521) { |
471 loadhostkey_helper("ECDSA521", (void**)&read_key->ecckey521, (void**)&svr_opts.hostkey->ecckey521, fatal_duplicate); | 467 loadhostkey_helper("ECDSA521", (void**)&read_key->ecckey521, (void**)&svr_opts.hostkey->ecckey521, fatal_duplicate); |
472 } | 468 } |
473 #endif | 469 #endif |
474 #endif /* DROPBEAR_ECDSA */ | 470 #endif /* DROPBEAR_ECDSA */ |
495 char *hostkey_file = svr_opts.hostkey_files[i]; | 491 char *hostkey_file = svr_opts.hostkey_files[i]; |
496 loadhostkey(hostkey_file, 1); | 492 loadhostkey(hostkey_file, 1); |
497 m_free(hostkey_file); | 493 m_free(hostkey_file); |
498 } | 494 } |
499 | 495 |
500 #ifdef DROPBEAR_RSA | 496 #if DROPBEAR_RSA |
501 loadhostkey(RSA_PRIV_FILENAME, 0); | 497 loadhostkey(RSA_PRIV_FILENAME, 0); |
502 #endif | 498 #endif |
503 | 499 |
504 #ifdef DROPBEAR_DSS | 500 #if DROPBEAR_DSS |
505 loadhostkey(DSS_PRIV_FILENAME, 0); | 501 loadhostkey(DSS_PRIV_FILENAME, 0); |
506 #endif | 502 #endif |
507 | 503 |
508 #ifdef DROPBEAR_ECDSA | 504 #if DROPBEAR_ECDSA |
509 loadhostkey(ECDSA_PRIV_FILENAME, 0); | 505 loadhostkey(ECDSA_PRIV_FILENAME, 0); |
510 #endif | 506 #endif |
511 | 507 |
512 #ifdef DROPBEAR_DELAY_HOSTKEY | 508 #if DROPBEAR_DELAY_HOSTKEY |
513 if (svr_opts.delay_hostkey) { | 509 if (svr_opts.delay_hostkey) { |
514 disable_unset_keys = 0; | 510 disable_unset_keys = 0; |
515 } | 511 } |
516 #endif | 512 #endif |
517 | 513 |
518 #ifdef DROPBEAR_RSA | 514 #if DROPBEAR_RSA |
519 if (disable_unset_keys && !svr_opts.hostkey->rsakey) { | 515 if (disable_unset_keys && !svr_opts.hostkey->rsakey) { |
520 disablekey(DROPBEAR_SIGNKEY_RSA); | 516 disablekey(DROPBEAR_SIGNKEY_RSA); |
521 } else { | 517 } else { |
522 any_keys = 1; | 518 any_keys = 1; |
523 } | 519 } |
524 #endif | 520 #endif |
525 | 521 |
526 #ifdef DROPBEAR_DSS | 522 #if DROPBEAR_DSS |
527 if (disable_unset_keys && !svr_opts.hostkey->dsskey) { | 523 if (disable_unset_keys && !svr_opts.hostkey->dsskey) { |
528 disablekey(DROPBEAR_SIGNKEY_DSS); | 524 disablekey(DROPBEAR_SIGNKEY_DSS); |
529 } else { | 525 } else { |
530 any_keys = 1; | 526 any_keys = 1; |
531 } | 527 } |
532 #endif | 528 #endif |
533 | 529 |
534 | 530 |
535 #ifdef DROPBEAR_ECDSA | 531 #if DROPBEAR_ECDSA |
536 #ifdef DROPBEAR_ECC_256 | 532 #if DROPBEAR_ECC_256 |
537 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 256) | 533 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 256) |
538 && !svr_opts.hostkey->ecckey256) { | 534 && !svr_opts.hostkey->ecckey256) { |
539 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP256); | 535 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP256); |
540 } else { | 536 } else { |
541 any_keys = 1; | 537 any_keys = 1; |
542 } | 538 } |
543 #endif | 539 #endif |
544 | 540 |
545 #ifdef DROPBEAR_ECC_384 | 541 #if DROPBEAR_ECC_384 |
546 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 384) | 542 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 384) |
547 && !svr_opts.hostkey->ecckey384) { | 543 && !svr_opts.hostkey->ecckey384) { |
548 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP384); | 544 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP384); |
549 } else { | 545 } else { |
550 any_keys = 1; | 546 any_keys = 1; |
551 } | 547 } |
552 #endif | 548 #endif |
553 | 549 |
554 #ifdef DROPBEAR_ECC_521 | 550 #if DROPBEAR_ECC_521 |
555 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 521) | 551 if ((disable_unset_keys || ECDSA_DEFAULT_SIZE != 521) |
556 && !svr_opts.hostkey->ecckey521) { | 552 && !svr_opts.hostkey->ecckey521) { |
557 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP521); | 553 disablekey(DROPBEAR_SIGNKEY_ECDSA_NISTP521); |
558 } else { | 554 } else { |
559 any_keys = 1; | 555 any_keys = 1; |