From 7cfc61d32ebd375f7b3c1cf259606c843c548454 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 18 Feb 2016 10:23:45 -0500 Subject: [PATCH] lib, vtysh: Rehook the motd command back into vtysh Code was already in place to read and display a motd, but no cli was present to make it happen. Add the cli back to vtysh.conf. Signed-off-by: Donald Sharp Reviewed-by: Don Slice --- lib/command.c | 16 +++++++++++----- lib/command.h | 2 ++ vtysh/vtysh_user.c | 9 +++++++++ 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/command.c b/lib/command.c index a1809f514c..037835e1df 100644 --- a/lib/command.c +++ b/lib/command.c @@ -4004,6 +4004,16 @@ DEFUN (no_config_log_timestamp_precision, return CMD_SUCCESS; } +int +cmd_banner_motd_file (const char *file) +{ + if (host.motdfile) + XFREE (MTYPE_HOST, host.motdfile); + host.motdfile = XSTRDUP (MTYPE_HOST, file); + + return CMD_SUCCESS; +} + DEFUN (banner_motd_file, banner_motd_file_cmd, "banner motd file [FILE]", @@ -4012,11 +4022,7 @@ DEFUN (banner_motd_file, "Banner from a file\n" "Filename\n") { - if (host.motdfile) - XFREE (MTYPE_HOST, host.motdfile); - host.motdfile = XSTRDUP (MTYPE_HOST, argv[0]); - - return CMD_SUCCESS; + return cmd_banner_motd_file (argv[0]); } DEFUN (banner_motd_default, diff --git a/lib/command.h b/lib/command.h index f1d70d7186..6e6ab047f7 100644 --- a/lib/command.h +++ b/lib/command.h @@ -563,6 +563,8 @@ extern void host_config_set (const char *); extern void print_version (const char *); +extern int cmd_banner_motd_file (const char *); + /* struct host global, ick */ extern struct host host; diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index 214279fac4..f31c5d623f 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -173,6 +173,14 @@ user_get (const char *name) return user; } +DEFUN (banner_motd_file, + banner_motd_file_cmd, + "banner motd file [FILE]", + "\n\n\n\n") +{ + return cmd_banner_motd_file (argv[0]); +} + DEFUN (username_nopassword, username_nopassword_cmd, "username WORD nopassword", @@ -222,4 +230,5 @@ vtysh_user_init (void) { userlist = list_new (); install_element (CONFIG_NODE, &username_nopassword_cmd); + install_element (CONFIG_NODE, &banner_motd_file_cmd); } -- 2.39.5