diff options
author | Donald Sharp <sharpd@nvidia.com> | 2021-07-22 17:59:25 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2021-07-22 18:00:58 +0200 |
commit | d1b287e1725afffd206cb773e6edcb9ec87603dc (patch) | |
tree | cffebfb9361447b92412d67878a4bf94dd96065e /vtysh | |
parent | Merge pull request #8983 from mobash-rasool/pim-upstreaming-activity (diff) | |
download | frr-d1b287e1725afffd206cb773e6edcb9ec87603dc.tar.xz frr-d1b287e1725afffd206cb773e6edcb9ec87603dc.zip |
vtysh: Handle `en` better when in -u for vtysh
vtysh was unable to distinguish between end and ena. The
code can now do so:
sharpd@eva ~/frr5 (master)> sudo vtysh/vtysh -u sharpd
Hello, this is FRRouting (version 8.1-dev).
Copyright 1996-2005 Kunihiro Ishiguro, et al.
eva> e
% Ambiguous command: e
eva> en
% Command not allowed: enable
eva> ena
% Command not allowed: enable
eva> enab
% Command not allowed: enable
eva> enabl
% Command not allowed: enable
eva> enable
% Command not allowed: enable
eva> enb
% Unknown command: enb
eva> enc
% Unknown command: enc
eva> end
% Unknown command: end
eva> ene
% Unknown command: ene
eva> quit
Fixes: #2296
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 0bc2c6ebd..a8906e72a 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -479,10 +479,21 @@ static int vtysh_execute_func(const char *line, int pager) return CMD_SUCCESS; if (user_mode) { + bool allow = true; if (strncmp("en", vector_slot(vline, 0), 2) == 0) { - cmd_free_strvec(vline); - vty_out(vty, "%% Command not allowed: enable\n"); - return CMD_WARNING; + if (strlen(line) >= 3) { + if (strncmp("ena", vector_slot(vline, 0), 3) + == 0) + allow = false; + } else + allow = false; + + if (!allow) { + cmd_free_strvec(vline); + vty_out(vty, + "%% Command not allowed: enable\n"); + return CMD_WARNING; + } } } |