mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-06-14 13:22:02 +00:00
Merge pull request #8450 from ton31337/feature/frr_history_turn_on_off
vtysh: Set history file on demand
This commit is contained in:
commit
1ff339ac05
@ -53,6 +53,10 @@ OPTIONS available for the vtysh command:
|
|||||||
|
|
||||||
When executing cli that does not invoke a vtysh shell, if an error ocurrs ignore it for purposes of return codes from vtysh.
|
When executing cli that does not invoke a vtysh shell, if an error ocurrs ignore it for purposes of return codes from vtysh.
|
||||||
|
|
||||||
|
.. option:: -H, --histfile
|
||||||
|
|
||||||
|
Override the history file for vtysh commands. You can set ``vtysh -H /dev/null`` to turn logging of at all.
|
||||||
|
|
||||||
.. option:: -u, --user
|
.. option:: -u, --user
|
||||||
|
|
||||||
Restrict access to configuration commands by preventing use of the "enable" command. This option provides the same limited "security" as password-protected telnet access. *This security should not be relied on in production environments.*
|
Restrict access to configuration commands by preventing use of the "enable" command. This option provides the same limited "security" as password-protected telnet access. *This security should not be relied on in production environments.*
|
||||||
@ -68,6 +72,10 @@ ENVIRONMENT VARIABLES
|
|||||||
VTYSH_PAGER
|
VTYSH_PAGER
|
||||||
This should be the name of the pager to use. Default is more.
|
This should be the name of the pager to use. Default is more.
|
||||||
|
|
||||||
|
VTYSH_HISTFILE
|
||||||
|
Override the history file for vtysh commands. Logging can be turned off using ``VTYSH_HISTFILE=/dev/null vtysh``.
|
||||||
|
Environment is prefered way to override the history file path over command line argument (-H/--histfile).
|
||||||
|
|
||||||
FILES
|
FILES
|
||||||
=====
|
=====
|
||||||
|INSTALL_PREFIX_SBIN|/vtysh
|
|INSTALL_PREFIX_SBIN|/vtysh
|
||||||
|
@ -153,8 +153,10 @@ static void usage(int status)
|
|||||||
progname);
|
progname);
|
||||||
else
|
else
|
||||||
printf("Usage : %s [OPTION...]\n\n"
|
printf("Usage : %s [OPTION...]\n\n"
|
||||||
"Integrated shell for FRR (version " FRR_VERSION "). \n"
|
"Integrated shell for FRR (version " FRR_VERSION
|
||||||
"Configured with:\n " FRR_CONFIG_ARGS "\n\n"
|
"). \n"
|
||||||
|
"Configured with:\n " FRR_CONFIG_ARGS
|
||||||
|
"\n\n"
|
||||||
"-b, --boot Execute boot startup configuration\n"
|
"-b, --boot Execute boot startup configuration\n"
|
||||||
"-c, --command Execute argument as command\n"
|
"-c, --command Execute argument as command\n"
|
||||||
"-d, --daemon Connect only to the specified daemon\n"
|
"-d, --daemon Connect only to the specified daemon\n"
|
||||||
@ -167,6 +169,7 @@ static void usage(int status)
|
|||||||
"-N --pathspace Insert prefix into config & socket paths\n"
|
"-N --pathspace Insert prefix into config & socket paths\n"
|
||||||
"-u --user Run as an unprivileged user\n"
|
"-u --user Run as an unprivileged user\n"
|
||||||
"-w, --writeconfig Write integrated config (frr.conf) and exit\n"
|
"-w, --writeconfig Write integrated config (frr.conf) and exit\n"
|
||||||
|
"-H, --histfile Override history file\n"
|
||||||
"-h, --help Display this help and exit\n\n"
|
"-h, --help Display this help and exit\n\n"
|
||||||
"Note that multiple commands may be executed from the command\n"
|
"Note that multiple commands may be executed from the command\n"
|
||||||
"line by passing multiple -c args, or by embedding linefeed\n"
|
"line by passing multiple -c args, or by embedding linefeed\n"
|
||||||
@ -189,6 +192,7 @@ struct option longopts[] = {
|
|||||||
{"vty_socket", required_argument, NULL, OPTION_VTYSOCK},
|
{"vty_socket", required_argument, NULL, OPTION_VTYSOCK},
|
||||||
{"config_dir", required_argument, NULL, OPTION_CONFDIR},
|
{"config_dir", required_argument, NULL, OPTION_CONFDIR},
|
||||||
{"inputfile", required_argument, NULL, 'f'},
|
{"inputfile", required_argument, NULL, 'f'},
|
||||||
|
{"histfile", required_argument, NULL, 'H'},
|
||||||
{"echo", no_argument, NULL, 'E'},
|
{"echo", no_argument, NULL, 'E'},
|
||||||
{"dryrun", no_argument, NULL, 'C'},
|
{"dryrun", no_argument, NULL, 'C'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
@ -321,6 +325,7 @@ int main(int argc, char **argv, char **env)
|
|||||||
char sysconfdir[MAXPATHLEN];
|
char sysconfdir[MAXPATHLEN];
|
||||||
const char *pathspace_arg = NULL;
|
const char *pathspace_arg = NULL;
|
||||||
char pathspace[MAXPATHLEN] = "";
|
char pathspace[MAXPATHLEN] = "";
|
||||||
|
const char *histfile = NULL;
|
||||||
|
|
||||||
/* SUID: drop down to calling user & go back up when needed */
|
/* SUID: drop down to calling user & go back up when needed */
|
||||||
elevuid = geteuid();
|
elevuid = geteuid();
|
||||||
@ -341,8 +346,8 @@ int main(int argc, char **argv, char **env)
|
|||||||
|
|
||||||
/* Option handling. */
|
/* Option handling. */
|
||||||
while (1) {
|
while (1) {
|
||||||
opt = getopt_long(argc, argv, "be:c:d:nf:mEhCwN:u",
|
opt = getopt_long(argc, argv, "be:c:d:nf:H:mEhCwN:u", longopts,
|
||||||
longopts, 0);
|
0);
|
||||||
|
|
||||||
if (opt == EOF)
|
if (opt == EOF)
|
||||||
break;
|
break;
|
||||||
@ -409,6 +414,9 @@ int main(int argc, char **argv, char **env)
|
|||||||
case 'h':
|
case 'h':
|
||||||
usage(0);
|
usage(0);
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
histfile = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(1);
|
usage(1);
|
||||||
break;
|
break;
|
||||||
@ -569,12 +577,24 @@ int main(int argc, char **argv, char **env)
|
|||||||
/*
|
/*
|
||||||
* Setup history file for use by both -c and regular input
|
* Setup history file for use by both -c and regular input
|
||||||
* If we can't find the home directory, then don't store
|
* If we can't find the home directory, then don't store
|
||||||
* the history information
|
* the history information.
|
||||||
|
* VTYSH_HISTFILE is prefered over command line
|
||||||
|
* argument (-H/--histfile).
|
||||||
*/
|
*/
|
||||||
homedir = vtysh_get_home();
|
if (getenv("VTYSH_HISTFILE")) {
|
||||||
if (homedir) {
|
const char *file = getenv("VTYSH_HISTFILE");
|
||||||
snprintf(history_file, sizeof(history_file), "%s/.history_frr",
|
|
||||||
homedir);
|
strlcpy(history_file, file, sizeof(history_file));
|
||||||
|
} else if (histfile) {
|
||||||
|
strlcpy(history_file, histfile, sizeof(history_file));
|
||||||
|
} else {
|
||||||
|
homedir = vtysh_get_home();
|
||||||
|
if (homedir)
|
||||||
|
snprintf(history_file, sizeof(history_file),
|
||||||
|
"%s/.history_frr", homedir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(history_file) > 0) {
|
||||||
if (read_history(history_file) != 0) {
|
if (read_history(history_file) != 0) {
|
||||||
int fp;
|
int fp;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user