about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-03-21T13·35+0100
committerEelco Dolstra <edolstra@gmail.com>2017-03-21T13·35+0100
commit3229f85585136e5c1d53a2ef2a434fdec75d912e (patch)
treea8bb951e6b228d9739e4cfd34f27dd0e8bd08f59 /src
parent20df50d8e15da7b5d39986a4db533d6c41f0786c (diff)
Honor $NIX_SSHOPTS again
NixOps needs this.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/ssh.cc21
-rw-r--r--src/libstore/ssh.hh2
2 files changed, 14 insertions, 9 deletions
diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc
index 4f88fa64dbd1..e54f3f4ba284 100644
--- a/src/libstore/ssh.cc
+++ b/src/libstore/ssh.cc
@@ -2,6 +2,16 @@
 
 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)
 {
     Path socketPath = startMaster();
@@ -23,10 +33,7 @@ std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string
             throw SysError("duping over stdout");
 
         Strings args = { "ssh", host.c_str(), "-x", "-a" };
-        if (!keyFile.empty())
-            args.insert(args.end(), {"-i", keyFile});
-        if (compress)
-            args.push_back("-C");
+        addCommonSSHOpts(args);
         if (socketPath != "")
             args.insert(args.end(), {"-S", socketPath});
         args.push_back(command);
@@ -73,11 +80,7 @@ Path SSHMaster::startMaster()
             , "-o", "LocalCommand=echo started"
             , "-o", "PermitLocalCommand=yes"
             };
-        if (!keyFile.empty())
-            args.insert(args.end(), {"-i", keyFile});
-        if (compress)
-            args.push_back("-C");
-
+        addCommonSSHOpts(args);
         execvp(args.begin()->c_str(), stringsToCharPtrs(args).data());
 
         throw SysError("starting SSH master");
diff --git a/src/libstore/ssh.hh b/src/libstore/ssh.hh
index 72238dad79ab..b4396467e54e 100644
--- a/src/libstore/ssh.hh
+++ b/src/libstore/ssh.hh
@@ -23,6 +23,8 @@ private:
 
     Sync<State> state_;
 
+    void addCommonSSHOpts(Strings & args);
+
 public:
 
     SSHMaster(const std::string & host, const std::string & keyFile, bool useMaster, bool compress)