Merge pull request #283406 from tfc/nixos-rebuild-socket
nixos-rebuild: Handle too-long tmpdir paths on macOS
This commit is contained in:
commit
056a4d8d52
2 changed files with 12 additions and 0 deletions
|
@ -132,5 +132,10 @@ import ./make-test-python.nix ({ pkgs, ... }: {
|
||||||
deployer.succeed("passh -c 3 -C -p ${nodes.target.users.users.bob.password} -P \"\[sudo\] password\" nixos-rebuild switch -I nixos-config=/root/configuration-3.nix --target-host bob@target --use-remote-sudo &>/dev/console")
|
deployer.succeed("passh -c 3 -C -p ${nodes.target.users.users.bob.password} -P \"\[sudo\] password\" nixos-rebuild switch -I nixos-config=/root/configuration-3.nix --target-host bob@target --use-remote-sudo &>/dev/console")
|
||||||
target_hostname = deployer.succeed("ssh alice@target cat /etc/hostname").rstrip()
|
target_hostname = deployer.succeed("ssh alice@target cat /etc/hostname").rstrip()
|
||||||
assert target_hostname == "config-3-deployed", f"{target_hostname=}"
|
assert target_hostname == "config-3-deployed", f"{target_hostname=}"
|
||||||
|
|
||||||
|
with subtest("Deploy works with very long TMPDIR"):
|
||||||
|
tmp_dir = "/var/folder/veryveryveryveryverylongpathnamethatdoesnotworkwithcontrolpath"
|
||||||
|
deployer.succeed(f"mkdir -p {tmp_dir}")
|
||||||
|
deployer.succeed(f"TMPDIR={tmp_dir} nixos-rebuild switch -I nixos-config=/root/configuration-1.nix --target-host root@target &>/dev/console")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
|
@ -407,6 +407,13 @@ fi
|
||||||
|
|
||||||
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
|
tmpDir=$(mktemp -t -d nixos-rebuild.XXXXXX)
|
||||||
|
|
||||||
|
if [[ ${#tmpDir} -ge 60 ]]; then
|
||||||
|
# Very long tmp dirs lead to "too long for Unix domain socket"
|
||||||
|
# SSH ControlPath errors. Especially macOS sets long TMPDIR paths.
|
||||||
|
rmdir "$tmpDir"
|
||||||
|
tmpDir=$(TMPDIR= mktemp -t -d nixos-rebuild.XXXXXX)
|
||||||
|
fi
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
for ctrl in "$tmpDir"/ssh-*; do
|
for ctrl in "$tmpDir"/ssh-*; do
|
||||||
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true
|
ssh -o ControlPath="$ctrl" -O exit dummyhost 2>/dev/null || true
|
||||||
|
|
Loading…
Reference in a new issue