Page MenuHomeVyOS Platform

Problems when using <path> as completion helper in op-mode
Closed, ResolvedPublicBUG


Using a completion helper in op mode like:

  <path>vrf name</path>

will generate the following node.def file:

cat /opt/vyatta/share/vyatta-op/templates/show/vrf/node.tag/node.def
help: Show information on specific VRF instance
allowed: /bin/cli-shell-api listActiveNodes vrf name
run: ${vyos_op_scripts_dir}/ -e "$3"

The problem here is a call to /bin/cli-shell-api listNodes vrf name will return: 'bar' 'foo' see the ' quotes. The old node.def implementations got rid if the '' by using shell code like:

  local -a bnodes
  local -a nnodes
  eval "bnodes=($(cli-shell-api listActiveNodes protocols bgp))"
  for b in "${bnodes[@]}"; do
    eval "nnodes=($(cli-shell-api listActiveNodes protocols bgp $b neighbor))"
    echo -n "${nnodes[@]}" ' '

Which removes the ' quotes.

This can easily be done using | sed -e "s/'//g"

Question: Why is this of no issue in configuration mode?


Difficulty level
Unknown (require assessment)
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Unspecified (possibly destroys the router)
Issue type
Internal change (not visible to end users)

Event Timeline

Turns out it's because the conf mode "allowed: " is escaped and eval'd when it's passed to the shell:

However, op mode "allowed:" is a different story altogether . Op mode template "parsing" seems to be done in shell with sed!

I couldn't locate where exactly the "allowed:" field is processed yet.

VyOS 1.3-rolling-202007240117

vyos@r1-roll:~$ show vrf 
Possible completions:
  <Enter>       Execute the current command
  bar           Show information on specific VRF instance

@c-po Can we close it?

A workaround is in place for this

c-po claimed this task.
erkin set Issue type to Internal change (not visible to end users).Aug 31 2021, 5:26 PM