diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-01-08 14:08:13 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2019-05-31 16:06:42 +0200 |
commit | 2950f5da55af16c8efd1ca24f714e9d69c602503 (patch) | |
tree | f0fb34f79c0dc851a405b58fa3df719f752e8368 /lib/vty.c | |
parent | Merge pull request #4315 from lkrishnamoor/route_map_3rd_state (diff) | |
download | frr-2950f5da55af16c8efd1ca24f714e9d69c602503.tar.xz frr-2950f5da55af16c8efd1ca24f714e9d69c602503.zip |
lib: Add '--command-log-always` to all daemons startup
Add 'no log commands' cli and at the same time add a
--command-log-always to the daemon startup cli.
If --command-log-always is specified then all commands are
auto-logged and the 'no log commands' form of the command
is now ignored.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/vty.c')
-rw-r--r-- | lib/vty.c | 34 |
1 files changed, 28 insertions, 6 deletions
@@ -46,6 +46,10 @@ #include <arpa/telnet.h> #include <termios.h> +#ifndef VTYSH_EXTRACT_PL +#include "lib/vty_clippy.c" +#endif + DEFINE_MTYPE_STATIC(LIB, VTY, "VTY") DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer") DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history") @@ -92,7 +96,8 @@ static int no_password_check = 0; /* Integrated configuration file path */ static char integrate_default[] = SYSCONFDIR INTEGRATE_DEFAULT_CONFIG; -static int do_log_commands = 0; +static bool do_log_commands; +static bool do_log_commands_perm; void vty_frame(struct vty *vty, const char *format, ...) { @@ -2975,13 +2980,24 @@ DEFUN_NOSH (show_history, } /* vty login. */ -DEFUN (log_commands, +DEFPY (log_commands, log_commands_cmd, - "log commands", + "[no] log commands", + NO_STR "Logging control\n" - "Log all commands (can't be unset without restart)\n") + "Log all commands\n") { - do_log_commands = 1; + if (no) { + if (do_log_commands_perm) { + vty_out(vty, + "Daemon started with permanent logging turned on for commands, ignoring\n"); + return CMD_WARNING; + } + + do_log_commands = false; + } else + do_log_commands = true; + return CMD_SUCCESS; } @@ -3101,7 +3117,7 @@ void vty_init_vtysh(void) } /* Install vty's own commands like `who' command. */ -void vty_init(struct thread_master *master_thread) +void vty_init(struct thread_master *master_thread, bool do_command_logging) { /* For further configuration read, preserve current directory. */ vty_save_cwd(); @@ -3125,6 +3141,12 @@ void vty_init(struct thread_master *master_thread) install_element(CONFIG_NODE, &no_service_advanced_vty_cmd); install_element(CONFIG_NODE, &show_history_cmd); install_element(CONFIG_NODE, &log_commands_cmd); + + if (do_command_logging) { + do_log_commands = true; + do_log_commands_perm = true; + } + install_element(ENABLE_NODE, &terminal_monitor_cmd); install_element(ENABLE_NODE, &terminal_no_monitor_cmd); install_element(ENABLE_NODE, &no_terminal_monitor_cmd); |