fix: correctly apply configuration precedence in reverse parsing order #12
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.
#11 - Correctly apply configuration precedence in reverse parsing order
Fixes #11
Commits
Commits contain logically distinct changes are are best reviewed individually.
Read #12 (comment) for more details.
Description
Previously, the order of precedence applied to
parsed configuration was incorrect.
Configuration was parsed, then sorted in
alphabetical order.
Algorithms (ciphers, key
exchange algorithms, MACs, etc.) were incorrectly
applied during parsing.
The correct precedence order follows
https://linux.die.net/man/5/ssh_config: the
configuration is read from top to bottom,
precedence is applied from bottom (lowest)
to the top (highest precedence).
Options preceding the first
Host
block areconsidered implicit command line options, in
line with OpenSSH's own implementation.
This patch includes the following changes:
Remove the alphabetic ordering of host sections.
Merge matching host sections in reverse order.
More efficiently merge host sections with vastly reduced
clone
s. (clone
on demand.)Resolve algorithms not during the parsing, but during the resolving stage.
More efficiently resolve algorithms, without source list mutation.
Adjust existing unit tests to test the corrected precedence algorithm.
Type of change
This is a bugfix, but some users may depend on the old, broken algorithm. For these users, this change could be considered breaking. On the other hand, this can be said about any bugfix: There might always be someone who abused the previous, incorrect behavior.
Please select relevant options.
Checklist
cargo fmt
cargo clippy
and reports no warningscfg target_os
)Acceptance tests
wait for a project maintainer to fulfill this section...