Page MenuHomePhabricator

equuleus: buster: vbash: tab completion breaks
Open, NormalPublicENHANCEMENT

Description

Tab completion is partially broken in buster.
When logging in it works until tab-completion is executed on a system command outside of the vbash menu.

steps to reproduce:

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  clone         Clone an object
  configure     Enter configure mode
  connect       Establish a connection
  copy          Copy an object
  ....
vyos@vyos:~$ show [TAB]
Possible completions:
  bridge        Show bridging information
  cluster       Show clustering information
  configuration Show available saved configurations
  conntrack     Show conntrack entries in the conntrack table
  conntrack-sync
  ....
vyos@vyos:~$ ls [TAB]
  Invalid command: set
+o tag [noglob invalid]


  Invalid command: set
-o tag [noglob invalid]


.bash_history  .bashrc        .profile
.bash_logout   .gnupg/        .ssh/
vyos@vyos:~$ [TAB]
Possible completions:
  *

vyos@vyos:~$

Tab completion is now broken until the user spawns a new bash process..

Details

Difficulty level
Unknown (require assessment)
Version
-
Why the issue appeared?
Will be filled on close

Event Timeline

runar triaged this task as Normal priority.Aug 22 2019, 7:48 AM
runar created this task.
jjakob added a subscriber: jjakob.Thu, Sep 5, 12:18 AM

Here's the output of set -x redirected to a file when doing "ls <TAB>" as root.


At first glance it seems like a call to "set -o tag" from within a script is interpreted as an argument to the template "set" node somewhere, which causes it to break.
If anyone wants to dig in to vyatta-op, this is a starting point.

The same, but on current (jessie):


The above 2 files can be diffed to see where the bug is triggered.
The _filedir function from /usr/share/bash-completion/bash_completion was changed, the offending part is:

reset=$(shopt -po noglob); set -o noglob
toks=( $( compgen -d -- "$cur" ) )
eval $reset

when eval is called, it expands to eval 'set -o noglob' which triggers _vyatta_op_run set -o noglob, which chokes on the input.
_vyatta_op_run was set up as alias for "set" in https://github.com/vyos/vyatta-op/blob/66753705b86a3d104dfe127d4dd2b904a54ab404/functions/interpreter/vyatta-op-run#L38

eval alias ${cmd:0:$pos}=\'_vyatta_op_run ${cmd:0:$pos}\'

due to "set" being part of the templates.

jjakob added a comment.Sat, Sep 7, 9:12 PM

It still fails in config mode:

vyos@vyos# ls <TAB>
  Configuration path [-o] is not valid
  Set failed

  Configuration path [-o] is not valid
  Set failed

More debugging is needed. But the op-mode and root completion work now.