From d64b6aed235f6e4d84a2cb8e84b32c3179260254 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 7 Sep 2017 04:52:05 +0200 Subject: VTY: interactive: never look for matching commands on parent node For interactive telnet VTY, remove the implicit move up to the parent node when a command did not succeed on the current node level. When reading config files, this behavior was useful to allow skipping explicit 'exit' commands. (A different patch deals with that.) In the telnet VTY, this behavior was never necessary. Explicit 'exit' commands can move to the parent node, and typically uninformed users expect to require that. On a telnet VTY, counting indents like for reading config files is not an option: a user will always type from the first column or may paste some leading spaces without intended meaning. After this patch, it is thus no longer possible to paste a complete config across several node levels directly to a telnet session, unless it contains 'exit' commands. Change-Id: Id73cba2dd34676bad8a130e9c45e67a272f19588 --- src/vty/command.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/vty') diff --git a/src/vty/command.c b/src/vty/command.c index 33862c0d..52c71913 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -2111,12 +2111,10 @@ int cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd, int vtysh) { - int ret, saved_ret, tried = 0; + int ret; enum node_type onode; - void *oindex; onode = vty->node; - oindex = vty->index; if (cmd_try_do_shortcut(vty->node, vector_slot(vline, 0))) { vector shifted_vline; @@ -2139,29 +2137,7 @@ cmd_execute_command(vector vline, struct vty *vty, struct cmd_element **cmd, return ret; } - saved_ret = ret = cmd_execute_command_real(vline, vty, cmd); - - if (vtysh) - return saved_ret; - - /* Go to parent for config nodes to attempt to find the right command */ - while (ret != CMD_SUCCESS && ret != CMD_WARNING - && is_config_child(vty)) { - vty_go_parent(vty); - ret = cmd_execute_command_real(vline, vty, cmd); - tried = 1; - if (ret == CMD_SUCCESS || ret == CMD_WARNING) { - /* succesfull command, leave the node as is */ - return ret; - } - } - /* no command succeeded, reset the vty to the original node and - return the error for this node */ - if (tried) { - vty->node = onode; - vty->index = oindex; - } - return saved_ret; + return cmd_execute_command_real(vline, vty, cmd); } /* Execute command by argument readline. */ -- cgit v1.2.3