mirror of
https://github.com/NixOS/nix
synced 2025-06-25 02:21:16 +02:00
Fix SSH invocation when local SHELL misbehaves
Setting it to /bin/sh will make it more predictable when users have their favorite shell in SHELL, which might not behave as expected. For instance, a bad rc file could send something to stdout before our LocalCommand gets to write "started". This may help https://github.com/NixOS/nix/issues/11010
This commit is contained in:
parent
c4192a6617
commit
a03bb4455c
2 changed files with 46 additions and 4 deletions
|
@ -81,6 +81,17 @@ in
|
|||
virtualisation.additionalPaths = [ config.system.build.extraUtils ];
|
||||
nix.settings.substituters = lib.mkForce [ ];
|
||||
programs.ssh.extraConfig = "ConnectTimeout 30";
|
||||
environment.systemPackages = [
|
||||
# `bad-shell` is used to make sure Nix works an environment with a misbehaving shell.
|
||||
#
|
||||
# More realistically, a bad shell would still run the command ("echo started")
|
||||
# but considering that our solution is to avoid this shell (set via $SHELL), we
|
||||
# don't need to bother with a more functional mock shell.
|
||||
(pkgs.writeScriptBin "bad-shell" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
echo "Hello, I am a broken shell"
|
||||
'')
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -114,9 +125,13 @@ in
|
|||
'echo hello world on $(hostname)' >&2
|
||||
""")
|
||||
|
||||
# Check that SSH uses SHELL for LocalCommand, as expected, and check that
|
||||
# our test setup here is working. The next test will use this bad SHELL.
|
||||
client.succeed(f"SHELL=$(which bad-shell) ssh -oLocalCommand='true' -oPermitLocalCommand=yes {builder1.name} 'echo hello world' | grep -F 'Hello, I am a broken shell'")
|
||||
|
||||
# Perform a build and check that it was performed on the builder.
|
||||
out = client.succeed(
|
||||
"nix-build ${expr nodes.client 1} 2> build-output",
|
||||
"SHELL=$(which bad-shell) nix-build ${expr nodes.client 1} 2> build-output",
|
||||
"grep -q Hello build-output"
|
||||
)
|
||||
builder1.succeed(f"test -e {out}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue