Skip to content

Fix Vyatta wrapper override by using late static binding#219

Open
HomesONE wants to merge 1 commit into
gmazoyer:mainfrom
HomesONE:fix/vyatta-wrapper-static-binding
Open

Fix Vyatta wrapper override by using late static binding#219
HomesONE wants to merge 1 commit into
gmazoyer:mainfrom
HomesONE:fix/vyatta-wrapper-static-binding

Conversation

@HomesONE

Copy link
Copy Markdown

Problem

Quagga::build_bgp() and Quagga::build_aspath_regexp() reference self::$wrapper, which is early-bound at parse time to the value 'vtysh -c' defined on Quagga.

Vyatta extends Quagga and overrides:

protected static \$wrapper = '/opt/vyatta/bin/vyatta-op-cmd-wrapper';

But because the parent uses self::, the override never takes effect — a router configured with type: vyatta actually invokes vtysh -c \"...\" on the box instead of vyatta-op-cmd-wrapper. Silent for years, presumably caught only by anyone who actually tries the Vyatta type and sees confusing command-not-found errors (or worse, accidentally running vtysh on a host where it does exist).

Fix

Switch to static::\$wrapper so PHP late-static-binding resolves the wrapper at call time to the actual subclass. One-character change in two spots in quagga.php.

Impact

  • Quagga: no change — static::\$wrapper still resolves to 'vtysh -c'.
  • Vyatta: now actually uses the configured wrapper path.

Follow-up

The same self::\$wrapper early-binding pattern is present in vyos.php, frr.php, and extreme_netiron.php. None of those currently have subclasses, so there's no behavioural change to fix today — but the footgun is still there for any future override. Happy to send a follow-up PR converting those too if you'd like to be consistent. Kept out of this PR to keep the diff minimal and the intent obvious.

`Quagga::build_bgp()` and `Quagga::build_aspath_regexp()` reference
`self::$wrapper`, which is early-bound at definition site to
`'vtysh -c'`. Because `Vyatta extends Quagga` and overrides
`protected static $wrapper = '/opt/vyatta/bin/vyatta-op-cmd-wrapper'`,
the override is silently ignored — a router configured as
`type: vyatta` actually runs `vtysh -c "..."` on the box instead of
the intended Vyatta operational-command wrapper.

Switch to `static::$wrapper` so PHP late-static-binding resolves
the wrapper at call site to the actual class. No effect on
straight Quagga deployments (still `vtysh -c`); Vyatta now reaches
the configured wrapper.

The same `self::$wrapper` pattern is present in `vyos.php`,
`frr.php`, and `extreme_netiron.php`. None of those currently have
subclasses, so behaviour there is unchanged — but leaving the
footgun in place would mean any future subclass override would
silently break the same way. Left for a follow-up to keep this
change minimal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant