diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc index 00fd25dd293..0d3c4eeb5b4 100644 --- a/src/libstore/ssh.cc +++ b/src/libstore/ssh.cc @@ -3,18 +3,16 @@ namespace nix { SSHMaster::SSHMaster(const std::string & hostNport, const std::string & keyFile, bool useMaster, bool compress, int logFD) - : fakeSSH(host == "localhost") - , keyFile(keyFile) + : keyFile(keyFile) , useMaster(useMaster && !fakeSSH) , compress(compress) , logFD(logFD) { - auto res = split(hostNport, *":"); - port = res.size() > 0 ? atoi(res[1].c_str()) : 0; + auto res = split(hostNport, ':'); + port = res.size() > 1 ? atoi(res[1].c_str()) : 0; // if we have a port, parse that host = res[0]; - // help: is this above already using the actual value or is it broken without this - fakeSSH = host == "localhost"; + fakeSSH = host == "localhost" && !port; if (host == "" || hasPrefix(host, "-")) throw Error("invalid SSH host name '%s'", host);