[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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user