ssh: Allow forwardAgent to be set to null #6046
Open
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.
Description
Allow setting the forwardAgent to
null
to prevent it from being set inHost *
.In situations where you use
CanonicalizeHostname
andCanonicalDomains
the ssh config is parsed twice. THe first time a value is set, typically means it's the final value. This means that ifprograms.ssh.forwardAgent
is set tofalse
you cannot haveForwardAgent = yes
apply to a canonical match (Match canonical *.my.tld
) asHost *
will be parsed first.If we consider the config where
programs.ssh.forwardAgent = false;
:ssh myhost
will first pass throughHost *
and setForwardAgent no
, canonicalize the name to myhost.my.tld, then matchMatch canonical *.my.tld
and try to setForwardAgent
toyes
but since it's alreadyno
it will be ignored.The same is a problem in reverse if
programs.ssh.forwardAgent = true;
and the canonical match isForwardAgent no
.The default for
forwardAgent
is alreadyfalse
so there's not a need to always explicitly set it, we allowforwardAgent = null
in match blocks, we can set it tonull
in the root as well.Note
This does add a blank line if
forwardAgent
is set to null in theHost *
block. Mabye not ideal, can probably fix it if it's really a problem.Checklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
ornix develop --ignore-environment .#all
using Flakes.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
Maintainer CC