Skip to content

Commit

Permalink
vtysh: fix entering configuration node in file-lock mode
Browse files Browse the repository at this point in the history
When the config node is entered in file-lock mode, we should actually
remember it to correctly apply the workaround in `vtysh_exit`.
Otherwise, the file-lock mode is dropped once we exit any node one level
below the config node.

Signed-off-by: Igor Ryzhov <[email protected]>
(cherry picked from commit 1a09cf3)
  • Loading branch information
idryzhov authored and mergify[bot] committed Sep 28, 2023
1 parent 8a1ca70 commit 3239fed
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion vtysh/vtysh.c
Original file line number Diff line number Diff line change
Expand Up @@ -2333,12 +2333,23 @@ DEFUNSH(VTYSH_REALLYALL, vtysh_disable, vtysh_disable_cmd, "disable",
}

DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal, vtysh_config_terminal_cmd,
"configure [terminal [file-lock]]",
"configure [terminal]",
"Configuration from vty interface\n"
"Configuration terminal\n")
{
vty->node = CONFIG_NODE;
return CMD_SUCCESS;
}

DEFUNSH(VTYSH_REALLYALL, vtysh_config_terminal_file_lock,
vtysh_config_terminal_file_lock_cmd,
"configure terminal file-lock",
"Configuration from vty interface\n"
"Configuration terminal\n"
"Configuration with locked datastores\n")
{
vty->node = CONFIG_NODE;
vty->vtysh_file_locked = true;
return CMD_SUCCESS;
}

Expand Down Expand Up @@ -4930,6 +4941,7 @@ void vtysh_init_vty(void)
if (!user_mode)
install_element(VIEW_NODE, &vtysh_enable_cmd);
install_element(ENABLE_NODE, &vtysh_config_terminal_cmd);
install_element(ENABLE_NODE, &vtysh_config_terminal_file_lock_cmd);
install_element(ENABLE_NODE, &vtysh_disable_cmd);

/* "exit" command. */
Expand Down

0 comments on commit 3239fed

Please sign in to comment.