1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

libstore: fixup fakeSSH check

This broke invocations like:

    NIX_SSHOPTS='-p2222 -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no' nix copy /nix/store/......-foo --to ssh-ng://root@localhost

In Nix 2.30.2, fakeSSH was enabled when the "thing I want to connect to"
was plain old "localhost". Previously, this check was written as:

         , fakeSSH(host == "localhost")

Given the above invocation, `host` would have been `root@localhost`, and
thus `fakeSSH` would be `false` because `root@localhost` != `localhost`.

However, since 49ba06175e, `authority.host`
returned _just_ the host (`localhost`, no user) and erroneously enabled
`fakeSSH` in this case, causing `NIX_SSHOPTS` to be ignored (since,
when `fakeSSH` is `true`, `SSHMaster::startCommand` doesn't call
`addCommonSSHOpts`).

`authority.to_string()` accurately returns the expected `root@localhost`
format (given the above invocation), fixing this.

(cherry picked from commit 7ec1427fc3)
This commit is contained in:
Cole Helbling 2025-10-03 12:03:25 -07:00 committed by github-actions[bot]
parent 80f2ca4015
commit 823c630b2e

View file

@ -78,7 +78,7 @@ SSHMaster::SSHMaster(
oss << authority.host; oss << authority.host;
return std::move(oss).str(); return std::move(oss).str();
}()) }())
, fakeSSH(authority.host == "localhost") , fakeSSH(authority.to_string() == "localhost")
, keyFile(keyFile) , keyFile(keyFile)
, sshPublicHostKey(parsePublicHostKey(authority.host, sshPublicHostKey)) , sshPublicHostKey(parsePublicHostKey(authority.host, sshPublicHostKey))
, useMaster(useMaster && !fakeSSH) , useMaster(useMaster && !fakeSSH)