forked from lix-project/lix
Honor $NIX_SSHOPTS again
NixOps needs this.
This commit is contained in:
parent
20df50d8e1
commit
3229f85585
|
@ -2,6 +2,16 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
void SSHMaster::addCommonSSHOpts(Strings & args)
|
||||||
|
{
|
||||||
|
for (auto & i : tokenizeString<Strings>(getEnv("NIX_SSHOPTS")))
|
||||||
|
args.push_back(i);
|
||||||
|
if (!keyFile.empty())
|
||||||
|
args.insert(args.end(), {"-i", keyFile});
|
||||||
|
if (compress)
|
||||||
|
args.push_back("-C");
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string & command)
|
std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string & command)
|
||||||
{
|
{
|
||||||
Path socketPath = startMaster();
|
Path socketPath = startMaster();
|
||||||
|
@ -23,10 +33,7 @@ std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string
|
||||||
throw SysError("duping over stdout");
|
throw SysError("duping over stdout");
|
||||||
|
|
||||||
Strings args = { "ssh", host.c_str(), "-x", "-a" };
|
Strings args = { "ssh", host.c_str(), "-x", "-a" };
|
||||||
if (!keyFile.empty())
|
addCommonSSHOpts(args);
|
||||||
args.insert(args.end(), {"-i", keyFile});
|
|
||||||
if (compress)
|
|
||||||
args.push_back("-C");
|
|
||||||
if (socketPath != "")
|
if (socketPath != "")
|
||||||
args.insert(args.end(), {"-S", socketPath});
|
args.insert(args.end(), {"-S", socketPath});
|
||||||
args.push_back(command);
|
args.push_back(command);
|
||||||
|
@ -73,11 +80,7 @@ Path SSHMaster::startMaster()
|
||||||
, "-o", "LocalCommand=echo started"
|
, "-o", "LocalCommand=echo started"
|
||||||
, "-o", "PermitLocalCommand=yes"
|
, "-o", "PermitLocalCommand=yes"
|
||||||
};
|
};
|
||||||
if (!keyFile.empty())
|
addCommonSSHOpts(args);
|
||||||
args.insert(args.end(), {"-i", keyFile});
|
|
||||||
if (compress)
|
|
||||||
args.push_back("-C");
|
|
||||||
|
|
||||||
execvp(args.begin()->c_str(), stringsToCharPtrs(args).data());
|
execvp(args.begin()->c_str(), stringsToCharPtrs(args).data());
|
||||||
|
|
||||||
throw SysError("starting SSH master");
|
throw SysError("starting SSH master");
|
||||||
|
|
|
@ -23,6 +23,8 @@ private:
|
||||||
|
|
||||||
Sync<State> state_;
|
Sync<State> state_;
|
||||||
|
|
||||||
|
void addCommonSSHOpts(Strings & args);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress)
|
SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress)
|
||||||
|
|
Loading…
Reference in a new issue