summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-11-09 14:42:47 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-11-10 10:15:27 +0100
commit87f44e2f0b1251c9d1dfe492ab1f37d809ee0a7c (patch)
tree8d4cfe9d25b990001a933acd8240b6bed4d65f49
parentRevert "vtysh: Make vtysh run as quagga user" (diff)
downloadfrr-87f44e2f0b1251c9d1dfe492ab1f37d809ee0a7c.tar.xz
frr-87f44e2f0b1251c9d1dfe492ab1f37d809ee0a7c.zip
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>
-rw-r--r--lib/command.c30
-rw-r--r--lib/command.h1
-rw-r--r--watchquagga/watchquagga.c4
3 files changed, 27 insertions, 8 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;
diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c
index 70b35f775..93bbb0429 100644
--- a/watchquagga/watchquagga.c
+++ b/watchquagga/watchquagga.c
@@ -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);