Skip to content

Commit

Permalink
vtysh: clean vtysh_file_locked when exiting config node
Browse files Browse the repository at this point in the history
The flag should be cleared to make sure it's not reused the next time
we enter the config node.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Nov 17, 2023
1 parent c599ed5 commit 40def43
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ static int vtysh_end(void)
/* Nothing to do. */
break;
default:
vty->vtysh_file_locked = false;
vty->node = ENABLE_NODE;
break;
}
Expand Down Expand Up @@ -2396,14 +2397,18 @@ static int vtysh_exit(struct vty *vty)
vty->node = cnode->parent_node;

if (vty->node == CONFIG_NODE) {
bool locked = vty->vtysh_file_locked;

/* resync in case one of the daemons is somewhere else */
vtysh_execute("end");
/* NOTE: a rather expensive thing to do, can we avoid it? */

if (vty->vtysh_file_locked)
if (locked)
vtysh_execute("configure terminal file-lock");
else
vtysh_execute("configure terminal");
} else if (vty->node == ENABLE_NODE) {
vty->vtysh_file_locked = false;
}

return CMD_SUCCESS;
Expand Down

0 comments on commit 40def43

Please sign in to comment.