Fix Vyatta wrapper override by using late static binding#219
Open
HomesONE wants to merge 1 commit into
Open
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Quagga::build_bgp()andQuagga::build_aspath_regexp()referenceself::$wrapper, which is early-bound at parse time to the value'vtysh -c'defined onQuagga.Vyatta extends Quaggaand overrides:But because the parent uses
self::, the override never takes effect — a router configured withtype: vyattaactually invokesvtysh -c \"...\"on the box instead ofvyatta-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::\$wrapperso PHP late-static-binding resolves the wrapper at call time to the actual subclass. One-character change in two spots inquagga.php.Impact
static::\$wrapperstill resolves to'vtysh -c'.Follow-up
The same
self::\$wrapperearly-binding pattern is present invyos.php,frr.php, andextreme_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.