From 10a22a629468b18f5b07316980e2761285283939 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Fri, 15 May 2020 16:12:23 +0200 Subject: vlib: restore commands for non-interactive sessions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'quit' and 'show terminal' are valid for non-interactive sessions too. Type: fix Fixes: a58be82dda89d6496f92e451b42eee31f0cf47b4 Change-Id: Ib63244c7b64ad2e30c257ed19e982295f59bfffa Signed-off-by: Benoît Ganne --- src/vlib/unix/cli.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c index c7249eb2af4..b553e12bac2 100644 --- a/src/vlib/unix/cli.c +++ b/src/vlib/unix/cli.c @@ -3238,13 +3238,18 @@ vlib_unix_cli_set_prompt (char *prompt) } static unix_cli_file_t * -unix_cli_file_if_interactive (unix_cli_main_t * cm) +unix_cli_file_if_exists (unix_cli_main_t * cm) { - unix_cli_file_t *cf; if (!cm->cli_file_pool) return 0; - cf = pool_elt_at_index (cm->cli_file_pool, cm->current_input_file_index); - if (!cf->is_interactive) + return pool_elt_at_index (cm->cli_file_pool, cm->current_input_file_index); +} + +static unix_cli_file_t * +unix_cli_file_if_interactive (unix_cli_main_t * cm) +{ + unix_cli_file_t *cf; + if ((cf = unix_cli_file_if_exists (cm)) && !cf->is_interactive) return 0; return cf; } @@ -3260,8 +3265,8 @@ unix_cli_quit (vlib_main_t * vm, unix_cli_main_t *cm = &unix_cli_main; unix_cli_file_t *cf; - if (!(cf = unix_cli_file_if_interactive (cm))) - return clib_error_return (0, "invalid for non-interactive sessions"); + if (!(cf = unix_cli_file_if_exists (cm))) + return clib_error_return (0, "invalid session"); /* Cosmetic: suppress the final prompt from appearing before we die */ cf->is_interactive = 0; @@ -3551,8 +3556,8 @@ unix_cli_show_terminal (vlib_main_t * vm, unix_cli_file_t *cf; vlib_node_t *n; - if (!(cf = unix_cli_file_if_interactive (cm))) - return clib_error_return (0, "invalid for non-interactive sessions"); + if (!(cf = unix_cli_file_if_exists (cm))) + return clib_error_return (0, "invalid session"); n = vlib_get_node (vm, cf->process_node_index); -- cgit 1.2.3-korg