diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 30 | ||||
-rw-r--r-- | lib/command.h | 1 |
2 files changed, 24 insertions, 7 deletions
diff --git a/lib/command.c b/lib/command.c index 56c262a64..e8ba63762 100644 --- a/lib/command.c +++ b/lib/command.c @@ -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)); diff --git a/lib/command.h b/lib/command.h index ba40770ba..d2fc969d7 100644 --- a/lib/command.h +++ b/lib/command.h @@ -56,6 +56,7 @@ struct host /* config file name of this host */ char *config; + int noconfig; /* Flags for services */ int advanced; |