aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-07-18 15:47:57 +0200
committerGitHub <noreply@github.com>2023-07-18 15:47:57 +0200
commit0e3a7e34a056e8f3f5afde36c9410821bc09d488 (patch)
treed6f7ed426c584e1ff8a213d124ffe821c0043857
parenta8d5bb5e7e4400d89ff49ff00e7b5634b24834c3 (diff)
parentd5e1eb20a2712eb17076c3ca2d30e5ac4a351d00 (diff)
Merge pull request #8506 from corngood/ssh-master
Pass NIX_SSHOPTS when checking for an ssh master connection.
-rw-r--r--src/libstore/ssh.cc5
-rw-r--r--tests/nixos/nix-copy.nix9
2 files changed, 13 insertions, 1 deletions
diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc
index fae99d75b..da32f1b79 100644
--- a/src/libstore/ssh.cc
+++ b/src/libstore/ssh.cc
@@ -42,7 +42,10 @@ void SSHMaster::addCommonSSHOpts(Strings & args)
}
bool SSHMaster::isMasterRunning() {
- auto res = runProgram(RunOptions {.program = "ssh", .args = {"-O", "check", host}, .mergeStderrToStdout = true});
+ Strings args = {"-O", "check", host};
+ addCommonSSHOpts(args);
+
+ auto res = runProgram(RunOptions {.program = "ssh", .args = args, .mergeStderrToStdout = true});
return res.first == 0;
}
diff --git a/tests/nixos/nix-copy.nix b/tests/nixos/nix-copy.nix
index 16c477bf9..ef053de03 100644
--- a/tests/nixos/nix-copy.nix
+++ b/tests/nixos/nix-copy.nix
@@ -79,6 +79,15 @@ in {
server.copy_from_host("key.pub", "/root/.ssh/authorized_keys")
server.succeed("systemctl restart sshd")
client.succeed(f"ssh -o StrictHostKeyChecking=no {server.name} 'echo hello world'")
+ client.succeed(f"ssh -O check {server.name}")
+ client.succeed(f"ssh -O exit {server.name}")
+ client.fail(f"ssh -O check {server.name}")
+
+ # Check that an explicit master will work
+ client.succeed(f"ssh -MNfS /tmp/master {server.name}")
+ client.succeed(f"ssh -S /tmp/master -O check {server.name}")
+ client.succeed("NIX_SSHOPTS='-oControlPath=/tmp/master' nix copy --to ssh://server ${pkgA} >&2")
+ client.succeed(f"ssh -S /tmp/master -O exit {server.name}")
# Copy the closure of package B from the server to the client, using ssh-ng.
client.fail("nix-store --check-validity ${pkgB}")