summaryrefslogtreecommitdiff
path: root/svr-runopts.c
diff options
context:
space:
mode:
Diffstat (limited to 'svr-runopts.c')
-rw-r--r--svr-runopts.c67
1 files changed, 59 insertions, 8 deletions
diff --git a/svr-runopts.c b/svr-runopts.c
index d6c78df..2c905dd 100644
--- a/svr-runopts.c
+++ b/svr-runopts.c
@@ -46,16 +46,19 @@ static void printhelp(const char * progname) {
"-b bannerfile Display the contents of bannerfile"
" before user login\n"
" (default: none)\n"
- "-r keyfile Specify hostkeys (repeatable)\n"
+ "-r keyfile Specify hostkeys (repeatable)\n"
" defaults: \n"
#if DROPBEAR_DSS
- " dss %s\n"
+ " - dss %s\n"
#endif
#if DROPBEAR_RSA
- " rsa %s\n"
+ " - rsa %s\n"
#endif
#if DROPBEAR_ECDSA
- " ecdsa %s\n"
+ " - ecdsa %s\n"
+#endif
+#if DROPBEAR_ED25519
+ " - ed25519 %s\n"
#endif
#if DROPBEAR_DELAY_HOSTKEY
"-R Create hostkeys as required\n"
@@ -99,6 +102,10 @@ static void printhelp(const char * progname) {
"-W <receive_window_buffer> (default %d, larger may be faster, max 1MB)\n"
"-K <keepalive> (0 is never, default %d, in seconds)\n"
"-I <idle_timeout> (0 is never, default %d, in seconds)\n"
+#if DROPBEAR_PLUGIN
+ "-A <authplugin>[,<options>]\n"
+ " Enable external public key auth through <authplugin>\n"
+#endif
"-V Version\n"
#if DEBUG_TRACE
"-v verbose (compiled with DEBUG_TRACE)\n"
@@ -113,6 +120,9 @@ static void printhelp(const char * progname) {
#if DROPBEAR_ECDSA
ECDSA_PRIV_FILENAME,
#endif
+#if DROPBEAR_ED25519
+ ED25519_PRIV_FILENAME,
+#endif
MAX_AUTH_TRIES,
DROPBEAR_MAX_PORTS, DROPBEAR_DEFPORT, DROPBEAR_PIDFILE,
DEFAULT_RECV_WINDOW, DEFAULT_KEEPALIVE, DEFAULT_IDLE_TIMEOUT);
@@ -129,6 +139,9 @@ void svr_getopts(int argc, char ** argv) {
char* maxauthtries_arg = NULL;
char* keyfile = NULL;
char c;
+#if DROPBEAR_PLUGIN
+ char* pubkey_plugin = NULL;
+#endif
/* see printhelp() for options */
@@ -156,6 +169,10 @@ void svr_getopts(int argc, char ** argv) {
#if DROPBEAR_SVR_REMOTETCPFWD
svr_opts.noremotetcp = 0;
#endif
+#if DROPBEAR_PLUGIN
+ svr_opts.pubkey_plugin = NULL;
+ svr_opts.pubkey_plugin_options = NULL;
+#endif
#ifndef DISABLE_ZLIB
opts.compress_mode = DROPBEAR_COMPRESS_DELAYED;
@@ -274,6 +291,11 @@ void svr_getopts(int argc, char ** argv) {
case 'u':
/* backwards compatibility with old urandom option */
break;
+#if DROPBEAR_PLUGIN
+ case 'A':
+ next = &pubkey_plugin;
+ break;
+#endif
#if DEBUG_TRACE
case 'v':
debug_trace = 1;
@@ -394,6 +416,17 @@ void svr_getopts(int argc, char ** argv) {
if (svr_opts.forced_command) {
dropbear_log(LOG_INFO, "Forced command set to '%s'", svr_opts.forced_command);
}
+#if DROPBEAR_PLUGIN
+ if (pubkey_plugin) {
+ char *args = strchr(pubkey_plugin, ',');
+ if (args) {
+ *args='\0';
+ ++args;
+ }
+ svr_opts.pubkey_plugin = pubkey_plugin;
+ svr_opts.pubkey_plugin_options = args;
+ }
+#endif
}
static void addportandaddress(const char* spec) {
@@ -452,9 +485,9 @@ static void addportandaddress(const char* spec) {
static void disablekey(int type) {
int i;
TRACE(("Disabling key type %d", type))
- for (i = 0; sshhostkey[i].name != NULL; i++) {
- if (sshhostkey[i].val == type) {
- sshhostkey[i].usable = 0;
+ for (i = 0; sigalgs[i].name != NULL; i++) {
+ if (sigalgs[i].val == type) {
+ sigalgs[i].usable = 0;
break;
}
}
@@ -511,6 +544,13 @@ static void loadhostkey(const char *keyfile, int fatal_duplicate) {
}
#endif
#endif /* DROPBEAR_ECDSA */
+
+#if DROPBEAR_ED25519
+ if (type == DROPBEAR_SIGNKEY_ED25519) {
+ loadhostkey_helper("ed25519", (void**)&read_key->ed25519key, (void**)&svr_opts.hostkey->ed25519key, fatal_duplicate);
+ }
+#endif
+
sign_key_free(read_key);
TRACE(("leave loadhostkey"))
}
@@ -527,7 +567,7 @@ static void addhostkey(const char *keyfile) {
void load_all_hostkeys() {
int i;
int any_keys = 0;
-#ifdef DROPBEAR_ECDSA
+#if DROPBEAR_ECDSA
int loaded_any_ecdsa = 0;
#endif
@@ -552,6 +592,9 @@ void load_all_hostkeys() {
#if DROPBEAR_ECDSA
loadhostkey(ECDSA_PRIV_FILENAME, 0);
#endif
+#if DROPBEAR_ED25519
+ loadhostkey(ED25519_PRIV_FILENAME, 0);
+#endif
}
#if DROPBEAR_RSA
@@ -615,6 +658,14 @@ void load_all_hostkeys() {
#endif
#endif /* DROPBEAR_ECDSA */
+#if DROPBEAR_ED25519
+ if (!svr_opts.delay_hostkey && !svr_opts.hostkey->ed25519key) {
+ disablekey(DROPBEAR_SIGNKEY_ED25519);
+ } else {
+ any_keys = 1;
+ }
+#endif
+
if (!any_keys) {
dropbear_exit("No hostkeys available. 'dropbear -R' may be useful or run dropbearkey.");
}