-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix up SSHConnectionInfo ssh PATH checks #25780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fix the logic for finding the ssh executable in the PATH when running in a context without an active Runspace. For example running it in an SDK hosted PowerShell instance will not have an active Runspace when creating the ssh process so cannot use the PowerShell command lookup class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for new test we could create simple xUnit test based on code from related issue.
src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
Outdated
Show resolved
Hide resolved
I could split out the logic into it's own function and run that but I can't run the reproducer because it'll require an SSH endpoint that is configured with the PowerShell subsystem. |
The endpoint could be easily created in |
src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs
Outdated
Show resolved
Hide resolved
|
@daxian-dbw sorry I can't seem to reply inline to your last review comment. The comment around cwd is about PowerShell setting PowerShell/src/System.Management.Automation/engine/remoting/common/RunspaceConnectionInfo.cs Line 2325 in ea07b93
The comment is explaining that we can't rely on Happy to reword the comment if it's confusing but would probably need some suggestions on what to change to make it clearer. |
|
@jborean93 It may not be a big deal, but your current comment sounds like "we don't know why cwd is set to the parent directory below, but since it's doing that, we have to search PATH manually here". Please take a look at my comment above (#25780 (comment)). I think it my be better to say in the comment that "we search PATH manually to keep that behavior of 'LookupCommandInfo'". What do you think? |
|
The comment is just trying to say we do the manual lookup because we need the full path so we can set the cwd ourselves. I can try and update the comment to be clearer but without knowing why we set the cwd later on in the code it's hard to justify the extra work when ProcessStartInfo could do it for us. I'm assuming it's because we don't want to use |
…ceConnectionInfo.cs Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
…ceConnectionInfo.cs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Many thanks to @jborean93 and all powershell team for fixing this! |
|
Thanks for the review/merge @daxian-dbw and @iSazonov |
…pace is not available (PowerShell#25780)
…pace is not available (PowerShell#25780)
|
If that would help release/v7.5...Nova-Logic:PowerShell:release/v7.5 that is the same change with small tweak to make it compatible with .net 9 which is used in 7.5 |
…pace is not available (PowerShell#25780)
…pace is not available (PowerShell#25780)
PR Summary
Fix the logic for finding the ssh executable in the PATH when running in a context without an active Runspace. For example running it in an SDK hosted PowerShell instance will not have an active Runspace when creating the ssh process so cannot use the PowerShell command lookup class.
I'm not sure of a way to effectively test this in CI unfortunately.
PR Context
Fixes: #15641
Fixes: #25778
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header