host.name = strdup("test");
host.domainname = strdup("testdomainname");
- vty_init(master);
+ vty_init(master, true);
memory_init();
yang_init();
nb_init(master, NULL, 0);
#define OPTION_LOGLEVEL 1004
#define OPTION_TCLI 1005
#define OPTION_DB_FILE 1006
+#define OPTION_LOGGING 1007
static const struct option lo_always[] = {
{"help", no_argument, NULL, 'h'},
{"log", required_argument, NULL, OPTION_LOG},
{"log-level", required_argument, NULL, OPTION_LOGLEVEL},
{"tcli", no_argument, NULL, OPTION_TCLI},
+ {"command-log-always", no_argument, NULL, OPTION_LOGGING},
{NULL}};
static const struct optspec os_always = {
"hvdM:",
case OPTION_LOGLEVEL:
di->early_loglevel = optarg;
break;
+ case OPTION_LOGGING:
+ di->log_always = true;
+ break;
default:
return 1;
}
else
cmd_init(1);
- vty_init(master);
+ vty_init(master, di->log_always);
memory_init();
log_ref_init();
const struct frr_yang_module_info **yang_modules;
size_t n_yang_modules;
+
+ bool log_always;
};
/* execname is the daemon's executable (and pidfile and configfile) name,
lib/nexthop_group.lo: lib/nexthop_group_clippy.c
lib/northbound_cli_clippy.c: $(CLIPPY_DEPS)
lib/northbound_cli.lo: lib/northbound_cli_clippy.c
+lib/vty_clippy.c: $(CLIPPY_DEPS)
+lib/vty.lo: lib/vty_clippy.c
pkginclude_HEADERS += \
lib/agg_table.h \
#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")
/* 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, ...)
{
}
/* 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;
}
}
/* 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();
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);
#endif
/* Prototypes. */
-extern void vty_init(struct thread_master *);
+extern void vty_init(struct thread_master *, bool do_command_logging);
extern void vty_init_vtysh(void);
extern void vty_terminate(void);
extern void vty_reset(void);
/* Library inits. */
cmd_init(1);
- vty_init(master);
+ vty_init(master, false);
memory_init();
yang_init();
nb_init(master, NULL, 0);
cmd_hostname_set("test");
cmd_domainname_set("test.domain");
- vty_init(master);
+ vty_init(master, false);
memory_init();
yang_init();
nb_init(master, NULL, 0);
/* Library inits. */
cmd_init(1);
cmd_hostname_set("test");
- vty_init(master);
+ vty_init(master, false);
memory_init();
yang_init();
nb_init(master, modules, array_size(modules));