# HG changeset patch # User Matt Johnston # Date 1590495339 -28800 # Node ID f8d8af12ac14cb24746452e0a43ed1a783406173 # Parent 83d48276885b774c6d38561c1103e570f36675c6 Make "dbclient -m help -c help" work diff -r 83d48276885b -r f8d8af12ac14 cli-runopts.c --- a/cli-runopts.c Tue May 26 20:15:00 2020 +0800 +++ b/cli-runopts.c Tue May 26 20:15:39 2020 +0800 @@ -378,6 +378,11 @@ } } +#if DROPBEAR_USER_ALGO_LIST + /* -c help doesn't need a hostname */ + parse_ciphers_macs(); +#endif + /* Done with options/flags; now handle the hostname (which may not * start with a hyphen) and optional command */ @@ -408,10 +413,6 @@ /* And now a few sanity checks and setup */ -#if DROPBEAR_USER_ALGO_LIST - parse_ciphers_macs(); -#endif - #if DROPBEAR_CLI_PROXYCMD if (cli_opts.proxycmd) { /* To match the common path of m_freeing it */ diff -r 83d48276885b -r f8d8af12ac14 common-runopts.c --- a/common-runopts.c Tue May 26 20:15:00 2020 +0800 +++ b/common-runopts.c Tue May 26 20:15:39 2020 +0800 @@ -64,38 +64,35 @@ #if DROPBEAR_USER_ALGO_LIST void -parse_ciphers_macs() -{ - if (opts.cipher_list) - { - if (strcmp(opts.cipher_list, "help") == 0) - { +parse_ciphers_macs() { + int printed_help = 0; + if (opts.cipher_list) { + if (strcmp(opts.cipher_list, "help") == 0) { char *ciphers = algolist_string(sshciphers); - dropbear_log(LOG_INFO, "Available ciphers:\n%s\n", ciphers); + dropbear_log(LOG_INFO, "Available ciphers: %s", ciphers); m_free(ciphers); - dropbear_exit("."); - } - - if (check_user_algos(opts.cipher_list, sshciphers, "cipher") == 0) - { - dropbear_exit("No valid ciphers specified for '-c'"); + printed_help = 1; + } else { + if (check_user_algos(opts.cipher_list, sshciphers, "cipher") == 0) { + dropbear_exit("No valid ciphers specified for '-c'"); + } } } - if (opts.mac_list) - { - if (strcmp(opts.mac_list, "help") == 0) - { + if (opts.mac_list) { + if (strcmp(opts.mac_list, "help") == 0) { char *macs = algolist_string(sshhashes); - dropbear_log(LOG_INFO, "Available MACs:\n%s\n", macs); + dropbear_log(LOG_INFO, "Available MACs: %s", macs); m_free(macs); - dropbear_exit("."); + printed_help = 1; + } else { + if (check_user_algos(opts.mac_list, sshhashes, "MAC") == 0) { + dropbear_exit("No valid MACs specified for '-m'"); + } } - - if (check_user_algos(opts.mac_list, sshhashes, "MAC") == 0) - { - dropbear_exit("No valid MACs specified for '-m'"); - } + } + if (printed_help) { + dropbear_exit("."); } } #endif