Merge pull request #14813 from idryzhov/vtysh-file-lock

vtysh: clean vtysh_file_locked when exiting config node
This commit is contained in:
Donald Sharp 2023-11-20 15:18:42 -05:00 committed by GitHub
commit 83cbdcc267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1652,6 +1652,7 @@ static int vtysh_end(void)
/* Nothing to do. */ /* Nothing to do. */
break; break;
default: default:
vty->vtysh_file_locked = false;
vty->node = ENABLE_NODE; vty->node = ENABLE_NODE;
break; break;
} }
@ -2396,14 +2397,18 @@ static int vtysh_exit(struct vty *vty)
vty->node = cnode->parent_node; vty->node = cnode->parent_node;
if (vty->node == CONFIG_NODE) { if (vty->node == CONFIG_NODE) {
bool locked = vty->vtysh_file_locked;
/* resync in case one of the daemons is somewhere else */ /* resync in case one of the daemons is somewhere else */
vtysh_execute("end"); vtysh_execute("end");
/* NOTE: a rather expensive thing to do, can we avoid it? */ /* NOTE: a rather expensive thing to do, can we avoid it? */
if (vty->vtysh_file_locked) if (locked)
vtysh_execute("configure terminal file-lock"); vtysh_execute("configure terminal file-lock");
else else
vtysh_execute("configure terminal"); vtysh_execute("configure terminal");
} else if (vty->node == ENABLE_NODE) {
vty->vtysh_file_locked = false;
} }
return CMD_SUCCESS; return CMD_SUCCESS;