[client] bug fix to separate out --named-config vs. --no-save-args command line args

This commit is contained in:
Michael Rash 2013-05-18 22:36:13 -04:00
parent 15b1382160
commit 96bbf7e61a
3 changed files with 28 additions and 23 deletions

View File

@ -507,13 +507,15 @@ create_fwknoprc(const char *rcfile)
"#\n"
"# Each section (or stanza) is identified and started by a line in this\n"
"# file that contains a single identifier surrounded by square brackets.\n"
"# It is this identifier (or name) that is used from the fwknop command line\n"
"# via the '-n <name>' argument to reference the corresponding stanza.\n"
"#\n"
"# The parameters within the stanza typicaly match corresponding client \n"
"# command-line parameters.\n"
"#\n"
"# The first one should always be `[default]' as it defines the global\n"
"# default settings for the user. These override the program defaults\n"
"# for these parameter. If a named stanza is used, its entries will\n"
"# for these parameters. If a named stanza is used, its entries will\n"
"# override any of the default. Command-line options will trump them\n"
"# all.\n"
"#\n"
@ -1285,6 +1287,26 @@ update_rc(fko_cli_options_t *options, uint32_t args_bitmask)
static void
validate_options(fko_cli_options_t *options)
{
if ( (options->use_rc_stanza[0] != 0x0)
&& (options->got_named_stanza == 0)
&& (options->save_rc_stanza == 0) )
{
log_msg(LOG_VERBOSITY_ERROR,
"Named configuration stanza: [%s] was not found.",
options->use_rc_stanza);
exit(EXIT_FAILURE);
}
if ( (options->save_rc_stanza == 1) && (options->use_rc_stanza[0] == 0) )
{
log_msg(LOG_VERBOSITY_ERROR,
"The option --save-rc-stanza must be used with the "
"--named-config option to specify the stanza to update.");
exit(EXIT_FAILURE);
}
/* Gotta have a Destination unless we are just testing or getting the
* the version, and must use one of [-s|-R|-a].
*/
@ -1321,25 +1343,6 @@ validate_options(fko_cli_options_t *options)
}
}
if ( (options->use_rc_stanza[0] != 0x0)
&& (options->got_named_stanza == 0)
&& (options->save_rc_stanza == 0) )
{
log_msg(LOG_VERBOSITY_ERROR,
"Named configuration stanza: [%s] was not found.",
options->use_rc_stanza);
exit(EXIT_FAILURE);
}
if ( (options->save_rc_stanza == 1) && (options->use_rc_stanza[0] == 0) )
{
log_msg(LOG_VERBOSITY_ERROR,
"The option --save-rc-stanza must be used with the "
"--named-config option to specify the stanza to update.");
exit(EXIT_FAILURE);
}
if(options->resolve_ip_http || options->spa_proto == FKO_PROTO_HTTP)
if (options->http_user_agent[0] == '\0')
snprintf(options->http_user_agent, HTTP_MAX_USER_AGENT_LEN,
@ -1421,8 +1424,10 @@ config_init(fko_cli_options_t *options, int argc, char **argv)
case 'h':
usage();
exit(EXIT_SUCCESS);
case 'n':
case NO_SAVE_ARGS:
options->no_save_args = 1;
break;
case 'n':
strlcpy(options->use_rc_stanza, optarg, sizeof(options->use_rc_stanza));
break;
case SAVE_RC_STANZA:

View File

@ -1279,7 +1279,7 @@ get_keys(fko_ctx_t ctx, fko_cli_options_t *options,
if(memcmp(hmac_key, key, *key_len) == 0)
{
log_msg(LOG_VERBOSITY_ERROR,
"[*] The encryption passphrase and the HMAC key should not be identical.");
"[*] The encryption passphrase and HMAC key should not be identical, no SPA packet sent. Exiting.");
clean_exit(ctx, options, EXIT_FAILURE);
}
}

View File

@ -105,7 +105,7 @@ REQUIRED ARGUMENTS
------------------
These required arguments can be specified via command-line or from within
the '.fwknoprc' file (see '-n, --named-config' option and the FWKNOPRC FILE
section below.
section below).
*-A, --access*='<port list>'::
Provide a list of ports and protocols to access on a remote computer