From 05ac050c585a52df2f475bface59562656b08b4e Mon Sep 17 00:00:00 2001 From: An-Cheng Huang Date: Thu, 29 Nov 2007 16:56:29 -0800 Subject: restricted modes: * do not restart completion after a "connector" or a '`'. * only allow simple commands and "pipe" in "full" mode. * add mechanism to limit allowed pipe commands. * remove unnecessary command checks (non-interactive and same command). --- bashline.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'bashline.c') diff --git a/bashline.c b/bashline.c index c0f67c9..d11904a 100644 --- a/bashline.c +++ b/bashline.c @@ -941,9 +941,12 @@ find_cmd_start (start) register int s, os; os = 0; - while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS)) <= start) && - rl_line_buffer[s]) - os = s+1; + if (!in_vyatta_restricted_mode(OUTPUT)) { + while (((s = skip_to_delim (rl_line_buffer, os, COMMAND_SEPARATORS)) + <= start) + && rl_line_buffer[s]) + os = s+1; + } return os; } @@ -953,7 +956,11 @@ find_cmd_end (end) { register int e; - e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS); + if (!in_vyatta_restricted_mode(OUTPUT)) { + e = skip_to_delim (rl_line_buffer, end, COMMAND_SEPARATORS); + } else { + e = strlen(rl_line_buffer); + } return e; } @@ -1038,7 +1045,9 @@ attempt_shell_completion (text, start, end) } else if (member (rl_line_buffer[ti], command_separator_chars)) { - in_command_position++; + if (!in_vyatta_restricted_mode(OUTPUT)) { + in_command_position++; + } if (check_redir (ti) == 1) in_command_position = 0; @@ -1060,7 +1069,7 @@ attempt_shell_completion (text, start, end) it can be the start or end of an old-style command substitution, or unmatched. If it's unmatched, both calls to unclosed_pair will succeed. */ - if (*text == '`' && + if (*text == '`' && !in_vyatta_restricted_mode(OUTPUT) && (in_command_position || (unclosed_pair (rl_line_buffer, start, "`") && unclosed_pair (rl_line_buffer, end, "`")))) matches = rl_completion_matches (text, command_subst_completion_function); -- cgit v1.2.3