summaryrefslogtreecommitdiffstats
path: root/vtysh/vtysh_config.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-03-09 13:25:02 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2016-03-09 13:25:02 +0100
commit3221dca81ea45765bb8707fa81cf8f1c6da36f71 (patch)
treedc1a3cf572c4dc05990d99ef67b7d78880760c20 /vtysh/vtysh_config.c
parentMerge branch 'cmaster' of ssh://stash.cumulusnetworks.com:7999/quag/quagga in... (diff)
downloadfrr-3221dca81ea45765bb8707fa81cf8f1c6da36f71.tar.xz
frr-3221dca81ea45765bb8707fa81cf8f1c6da36f71.zip
vtysh: Set an erroneous exit code if dry run fails because of syntax error
vtysh has a -C option to do a dry run of the quagga commands. However, the program always returns 0 even when there's an error detected in the command. Furthermore, it only parses vtysh.conf, not Quagga.conf. This patch makes vtysh -C parse Quagga.conf also and return a non-zero exit code so that network automation tools can catch this to flag errors in syntax. This non-zero exit code along with printing the exact error with the line number and offending line itself should help in fixing the error. But this lack of proper error code requires the automation tools to go through an additional hoop to validate the syntax. Signed-off-by: Dinesh G Dutt <ddutt@cumulusnetworks.com>
Diffstat (limited to 'vtysh/vtysh_config.c')
-rw-r--r--vtysh/vtysh_config.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index f435cf871..6bb8fad42 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -365,10 +365,11 @@ vtysh_config_dump (FILE *fp)
}
/* Read up configuration file from file_name. */
-static void
+static int
vtysh_read_file (FILE *confp)
{
struct vty *vty;
+ int ret;
vty = vty_new ();
vty->fd = 0; /* stdout */
@@ -379,12 +380,14 @@ vtysh_read_file (FILE *confp)
vtysh_execute_no_pager ("configure terminal");
/* Execute configuration file. */
- vtysh_config_from_file (vty, confp);
+ ret = vtysh_config_from_file (vty, confp);
vtysh_execute_no_pager ("end");
vtysh_execute_no_pager ("disable");
vty_close (vty);
+
+ return (ret);
}
/* Read up configuration file from config_default_dir. */
@@ -392,16 +395,17 @@ int
vtysh_read_config (const char *config_default_dir)
{
FILE *confp = NULL;
+ int ret;
host_config_set (config_default_dir);
confp = fopen (config_default_dir, "r");
if (confp == NULL)
return (1);
- vtysh_read_file (confp);
+ ret = vtysh_read_file (confp);
fclose (confp);
- return (0);
+ return (ret);
}
/* We don't write vtysh specific into file from vtysh. vtysh.conf should