Fix SSH argument handling for timeouts and complex options#625
Open
cafkafk wants to merge 1 commit intonix-community:mainfrom
Open
Fix SSH argument handling for timeouts and complex options#625cafkafk wants to merge 1 commit intonix-community:mainfrom
cafkafk wants to merge 1 commit intonix-community:mainfrom
Conversation
d282120 to
ac10e25
Compare
Member
Author
Update `importFacts`, `generateHardwareConfig`, and other functions to append the `ConnectTimeout` option to the `sshArgs` array instead of passing it as a direct argument to `runSsh` and `runSshNoTty`. This ensures more consistent handling of SSH arguments throughout the script and leverages subshells where necessary to scope the argument changes.
ac10e25 to
bbb2cc2
Compare
Member
Author
|
For context: The failing tests seems to be an issue with CI, not this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two related issues with how SSH arguments are propagated, which were causing failures for deployments using complex SSH options (e.g.,
ProxyCommandwith arguments) or relying onConnectTimeout.Issues Fixed
1. Fix
NIX_SSHOPTSQuotingsshArgswas being flattened intoNIX_SSHOPTSusing"${sshArgs[*]}". This naive expansion destroys the quoting of array elements that contain spaces.Passing
--ssh-option "ProxyCommand='wrapper.sh' %h %p"would result innixsplitting the proxy command string, causing SSH to execute the wrapper without arguments (failed IAP tunnels, etc.).Fix: Changed to
NIX_SSHOPTS="$(printf '%q ' "${sshArgs[@]}")"to properly shell-escape the arguments, preserving the structure of complex flags when passed tonix.2. Fix
ConnectTimeoutInjectionInternal calls like
runSsh -o ConnectTimeout=10were broken becauserunSshappends positional arguments ($@) after the destination.ssh root@host -o ConnectTimeout=10tries to execute-oas a remote command on the server. This returns exit code 127 (command not found) instead of actually setting a connection timeout, breaking logic that relies on exit codes (like the post-kexec wait loop).Fix: Refactored these calls to append
-o ConnectTimeout=10to thesshArgsarray (scoped within subshells where appropriate) so they are correctly passed as SSH flags before the destination.