[client] allow -D to be used in --save-rc-stanza mode if -n is not given

This change simplifies the fwknop client usage by allowing the -D argument to
be used as the stanza name if -n is not also specified in --save-rc-stanza
mode.
This commit is contained in:
Michael Rash
2013-05-31 23:01:47 -04:00
parent 32a6d05cdb
commit 9b2cd9e2e5
3 changed files with 19 additions and 8 deletions

View File

@@ -638,8 +638,7 @@ keys_status(fko_cli_options_t *options)
{
set_rc_file(rcfile, options);
log_msg(LOG_VERBOSITY_NORMAL,
"[+] Wrote Rijndael and HMAC keys to rc file: %s",
options->rc_file);
"[+] Wrote Rijndael and HMAC keys to rc file: %s", rcfile);
}
else
log_msg(LOG_VERBOSITY_NORMAL,
@@ -1571,10 +1570,16 @@ validate_options(fko_cli_options_t *options)
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);
/* Set the stanza name to the -D arg value
*/
if (options->spa_server_str[0] == 0x0)
{
log_msg(LOG_VERBOSITY_ERROR,
"Must use --destination unless --test mode is used");
exit(EXIT_FAILURE);
}
strlcpy(options->use_rc_stanza, options->spa_server_str, sizeof(options->use_rc_stanza));
}
/* Gotta have a Destination unless we are just testing or getting the

View File

@@ -218,7 +218,11 @@ Specify path to the fwknop rc file (default is $HOME/\&.fwknoprc)\&.
.RS 4
Save command line arguments to the $HOME/\&.fwknoprc stanza specified with the
\fB\-n\fR
option\&.
option\&. If the
\fB\-n\fR
option is omitted, then the stanza name will default to the destination server value (hostname or IP) given with the
\fB\-D\fR
argument\&.
.RE
.PP
\fB\-\-force\-stanza\fR

View File

@@ -233,7 +233,9 @@ GENERAL OPTIONS
*--save-rc-stanza*='<stanza name>'::
Save command line arguments to the $HOME/.fwknoprc stanza specified with
the *-n* option.
the *-n* option. If the *-n* option is omitted, then the stanza name will
default to the destination server value (hostname or IP) given with the
*-D* argument.
*--force-stanza*::
Used with *--save-rc-stanza* to overwrite all of the variables for the