]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vtysh: stop reading config file if user `exit`s from root level.
authorChristian Hopps <chopps@labn.net>
Sun, 11 Jun 2023 21:53:10 +0000 (17:53 -0400)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Thu, 22 Jun 2023 21:56:43 +0000 (21:56 +0000)
This is required to make sure that we properly send the
XFRR_end_configuration tag to the daemons. Previously if the user had an
`exit` at the root level the parser would just drop out of the config
node and so XFRR_end_configuration, even if sent, would be ignored

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 315e9032e4087494063bbc6f7f52ec8c3d3ce757)

vtysh/vtysh.c

index 04f7ff65e9f64f2026772761d898e63943b9e05f..c94b47fef50697c0c6afb319bc14dbf928d2f14c 100644 (file)
@@ -880,6 +880,13 @@ int vtysh_config_from_file(struct vty *vty, FILE *fp)
                if (strmatch(vty_buf_trimmed, "end"))
                        continue;
 
+               if (strmatch(vty_buf_trimmed, "exit") &&
+                   vty->node == CONFIG_NODE) {
+                       fprintf(stderr, "line %d: Warning[%d]...: %s\n", lineno,
+                               vty->node, "early exit from config file");
+                       break;
+               }
+
                ret = command_config_read_one_line(vty, &cmd, lineno, 1);
 
                switch (ret) {