1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-14 22:42:41 +01:00

Fix Git LFS SSH issues

* Adds support for NIX_SSHOPTS
* Properly uses the parsed port from URL (fixes #13337)
* Don't guess the HTTP endpoint, use the response of git-lfs-authenticate
* Add an SSH Git LFS test
* Removed some unused test code
This commit is contained in:
Leandro Reina 2025-08-13 16:40:55 +02:00 committed by Sergei Zimmerman
parent 68839b9545
commit ccf658ed5c
No known key found for this signature in database
7 changed files with 128 additions and 85 deletions

View file

@ -8,6 +8,8 @@
namespace nix {
Strings getNixSshOpts();
class SSHMaster
{
private:

View file

@ -51,6 +51,18 @@ static void checkValidAuthority(const ParsedURL::Authority & authority)
}
}
Strings getNixSshOpts()
{
std::string sshOpts = getEnv("NIX_SSHOPTS").value_or("");
try {
return shellSplitString(sshOpts);
} catch (Error & e) {
e.addTrace({}, "while splitting NIX_SSHOPTS '%s'", sshOpts);
throw;
}
}
SSHMaster::SSHMaster(
const ParsedURL::Authority & authority,
std::string_view keyFile,
@ -82,16 +94,8 @@ void SSHMaster::addCommonSSHOpts(Strings & args)
{
auto state(state_.lock());
std::string sshOpts = getEnv("NIX_SSHOPTS").value_or("");
try {
std::list<std::string> opts = shellSplitString(sshOpts);
for (auto & i : opts)
args.push_back(i);
} catch (Error & e) {
e.addTrace({}, "while splitting NIX_SSHOPTS '%s'", sshOpts);
throw;
}
auto sshArgs = getNixSshOpts();
args.insert(args.end(), sshArgs.begin(), sshArgs.end());
if (!keyFile.empty())
args.insert(args.end(), {"-i", keyFile});