mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-04 20:18:54 +00:00
lib: add minimal no-config VTY mode
This silences the following warning from watchquagga: "Can't save to configuration file, using vtysh." which otherwise appears when doing a "write file" in vtysh when no integrated-config is in use. Also make "show memory" available in watchquagga. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
1f8df88720
commit
87f44e2f0b
@ -3146,6 +3146,9 @@ DEFUN (config_write_file,
|
||||
struct vty *file_vty;
|
||||
struct stat conf_stat;
|
||||
|
||||
if (host.noconfig)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
/* Check and see if we are operating under vtysh configuration */
|
||||
if (host.config == NULL)
|
||||
{
|
||||
@ -3270,6 +3273,9 @@ DEFUN (config_write_terminal,
|
||||
unsigned int i;
|
||||
struct cmd_node *node;
|
||||
|
||||
if (host.noconfig)
|
||||
return CMD_SUCCESS;
|
||||
|
||||
if (vty->type == VTY_SHELL_SERV)
|
||||
{
|
||||
for (i = 0; i < vector_active (cmdvec); i++)
|
||||
@ -3313,6 +3319,11 @@ DEFUN (show_startup_config,
|
||||
char buf[BUFSIZ];
|
||||
FILE *confp;
|
||||
|
||||
if (host.noconfig)
|
||||
return CMD_SUCCESS;
|
||||
if (host.config == NULL)
|
||||
return CMD_WARNING;
|
||||
|
||||
confp = fopen (host.config, "r");
|
||||
if (confp == NULL)
|
||||
{
|
||||
@ -4203,7 +4214,11 @@ install_default (enum node_type node)
|
||||
install_element (node, &show_running_config_cmd);
|
||||
}
|
||||
|
||||
/* Initialize command interface. Install basic nodes and commands. */
|
||||
/* Initialize command interface. Install basic nodes and commands.
|
||||
*
|
||||
* terminal = 0 -- vtysh / no logging, no config control
|
||||
* terminal = 1 -- normal daemon
|
||||
* terminal = -1 -- watchquagga / no logging, but minimal config control */
|
||||
void
|
||||
cmd_init (int terminal)
|
||||
{
|
||||
@ -4224,6 +4239,7 @@ cmd_init (int terminal)
|
||||
host.enable = NULL;
|
||||
host.logfile = NULL;
|
||||
host.config = NULL;
|
||||
host.noconfig = (terminal < 0);
|
||||
host.lines = -1;
|
||||
host.motd = default_motd;
|
||||
host.motdfile = NULL;
|
||||
@ -4269,12 +4285,17 @@ cmd_init (int terminal)
|
||||
{
|
||||
install_element (ENABLE_NODE, &config_logmsg_cmd);
|
||||
install_default (CONFIG_NODE);
|
||||
|
||||
install_element (VIEW_NODE, &show_thread_cpu_cmd);
|
||||
install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
|
||||
|
||||
install_element (VIEW_NODE, &show_work_queues_cmd);
|
||||
}
|
||||
|
||||
install_element (CONFIG_NODE, &hostname_cmd);
|
||||
install_element (CONFIG_NODE, &no_hostname_cmd);
|
||||
|
||||
if (terminal)
|
||||
if (terminal > 0)
|
||||
{
|
||||
install_element (CONFIG_NODE, &password_cmd);
|
||||
install_element (CONFIG_NODE, &password_text_cmd);
|
||||
@ -4313,11 +4334,6 @@ cmd_init (int terminal)
|
||||
install_element (CONFIG_NODE, &service_terminal_length_cmd);
|
||||
install_element (CONFIG_NODE, &no_service_terminal_length_cmd);
|
||||
|
||||
install_element (VIEW_NODE, &show_thread_cpu_cmd);
|
||||
|
||||
install_element (ENABLE_NODE, &clear_thread_cpu_cmd);
|
||||
install_element (VIEW_NODE, &show_work_queues_cmd);
|
||||
|
||||
vrf_install_commands ();
|
||||
}
|
||||
srandom(time(NULL));
|
||||
|
@ -56,6 +56,7 @@ struct host
|
||||
|
||||
/* config file name of this host */
|
||||
char *config;
|
||||
int noconfig;
|
||||
|
||||
/* Flags for services */
|
||||
int advanced;
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <sigevent.h>
|
||||
#include <lib/version.h>
|
||||
#include "command.h"
|
||||
#include "memory_vty.h"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <sys/un.h>
|
||||
@ -1304,7 +1305,8 @@ main(int argc, char **argv)
|
||||
zprivs_init (&watchquagga_privs);
|
||||
|
||||
master = thread_master_create();
|
||||
cmd_init(1);
|
||||
cmd_init(-1);
|
||||
memory_init();
|
||||
vty_init(master);
|
||||
watchquagga_vty_init();
|
||||
vty_serv_sock(NULL, 0, WATCHQUAGGA_VTYSH_PATH);
|
||||
|
Loading…
Reference in New Issue
Block a user