Page MenuHomePhabricator

equuleus: buster: vbash: tab completion breaks
Closed, ResolvedPublicENHANCEMENT

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.Sep 5 2019, 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.Sep 7 2019, 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.

hagbard claimed this task.EditedOct 11 2019, 8:35 PM
hagbard added a subscriber: hagbard.

@jjakob Is that still an issue? I have the lastest 1.3 rolling form today and can't reproduce the issue.

NVM, its still an issue in conf mode. I just tabbed without ls, I can reproduce it now.

c-po added a comment.Sun, Oct 13, 1:50 PM

Can we probably also increase the TAB witdh by one?

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  clone         Clone an obje

we have some ver long commands which break tabbing.

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  this-is-a-super-long
                This is the help text from that long command
runar added a comment.Mon, Oct 14, 5:11 PM

@hagbard This is still an issue in conf-mode. to replicate:

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


  Configuration path: [-o] is not valid
  Set failed


./             .bash_history  .bashrc        .profile
../            .bash_logout   .gnupg/        .ssh/

on the next prompt i can't remove text, backspace and ctrl+h don't work.. but after [enter] to a new prompt it seams to behave again

jjakob added a comment.EditedMon, Oct 14, 7:41 PM

https://github.com/vyos/vyatta-cfg/pull/19
This fixes the conf mode completion, at least in the bash cli shell.

I tested this in a live system without building the package or ISO but I don't see why it wouldn't work.
There were some other files where the same error message is present in the code, but I couldn't figure out where or in what situation they're called or triggered so I left them alone (in any case, they're not triggered from the shell CLI):

https://github.com/vyos/vyatta-cfg/blob/06201c4e9ccb68341bebbf73acab74e6d51ab361/etc/bash_completion.d/vyatta-cfg#L809
https://github.com/vyos/vyatta-cfg/blob/06201c4e9ccb68341bebbf73acab74e6d51ab361/src/cstore/cstore.cpp#L466
https://github.com/vyos/vyatta-cfg/blob/06201c4e9ccb68341bebbf73acab74e6d51ab361/src/cstore/cstore.cpp#L2219

@c-po can you provide a way to reproduce your issue?

In T1604#45170, @c-po wrote:

Can we probably also increase the TAB witdh by one?

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  clone         Clone an obje

we have some ver long commands which break tabbing.

vyos@vyos:~$ [TAB]
Possible completions:
  add           Add an object to a service
  clear         Clear system information
  this-is-a-super-long
                This is the help text from that long command
c-po added a comment.EditedFri, Oct 18, 5:39 AM

e.g.:

vyos@vyos# set interfaces wireless wlan0
Possible completions:
+  address      Address for this interface
 > bridge-group Interface bridge group
 > capabilities HT and VHT capabilities for your card
   channel      Wireless radio channel
   debug        Enable hostapd logging to syslog
   description  Description for this interface
 > dhcpv6-options
                DHCPv6 options
   disable-broadcast-ssid
                Disable broadcast of SSID from access-point
   disable-link-detect
                Ignore link state changes on this interface
   expunge-failing-stations
                Disassociate stations based on excessive transmission failures.
 > firewall     Firewall options
   hw-id        Media Access Control (MAC) address
 > ip           IPv4 routing parameters
 > ipv6         IPv6 routing parameters
   isolate-stations
                Isolate stations on the AP so they cannot see each other
   mac          Media Access Control (MAC) address
   max-stations Maximum number of wireless radio stations
   mgmt-frame-protection
                Management Frame Protection (MFP) according to IEEE 802.11w
   mode         Wireless radio mode
   physical-device
                Wireless physical device
 > policy       Policy route options
   redirect     Incoming packet redirection destination
   reduce-transmit-power
                Transmission power reduction in dBm
 > security     Wireless security settings
   ssid         Wireless access-point service set identifier (SSID)
 > traffic-policy
                Traffic-policy for interface
   type         Wireless device type for this interface [REQUIRED]
+> vif          Virtual Local Area Network (VLAN) ID

Is that still and issue, sorry I lost track a little while I was busy with other stuff.

runar added a comment.Fri, Oct 18, 8:45 PM

@c-po what you are describing don't look like a bug.. its more like a feature :) anyways its not related to this issue so please open another ticket on this.

@hagbard I've done quick tests on the latest rolling, and after the latest fix from @jjakob i don't see this issue anymore

@c-po I can't see the issue here, that seems like normal expected behavior (tabbing gives a list of all possible nodes, even the long ones?)
I agree that if there is a problem, it's for a separate issue and describe what the problem and expected behavior is in more detail there.

This is fixed on the latest rolling live ISO, I'll try installing to image and testing there too.

hagbard closed this task as Resolved.Fri, Oct 18, 9:52 PM

Perfect. Thanks a lot guys.