Skip to content
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

Fix for SSH remoting when SSH client abruptly terminates #4123

Merged
merged 4 commits into from
Jun 29, 2017
Merged

Fix for SSH remoting when SSH client abruptly terminates #4123

merged 4 commits into from
Jun 29, 2017

Conversation

PaulHigin
Copy link
Contributor

This PR is for Issue #4122

If the SSH client process that PowerShell is using for the SSH transport terminates abruptly the StreamReader will return null instead of closing the pipe for a normal process exit.

The current error stream reading code ignores null StreamReader values resulting in a hang where the remote session never ends.

Fix is to throw an error when this occurs.

@PaulHigin PaulHigin added WG-Remoting PSRP issues with any transport layer Issue-Bug Issue has been identified as a bug in the product labels Jun 27, 2017
@PaulHigin PaulHigin added this to the 6.0.0-beta.4 milestone Jun 27, 2017
@PaulHigin PaulHigin requested a review from iSazonov June 27, 2017 23:11
@@ -1636,4 +1636,7 @@ All WinRM sessions connected to Windows PowerShell session configurations, such
<data name="InvalidRoleCapabilityFileExtension" xml:space="preserve">
<value>The provided role capability file {0} does not have the required .psrc extension.</value>
</data>
<data name="SSHTerminated" >
Copy link
Collaborator

@iSazonov iSazonov Jun 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe SSHAbruptlyTerminated ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will change.

if (string.IsNullOrEmpty(error) ||
if (error == null)
{
return error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you decide to return null here and throw in the calling function? Why not just throw here and make the ReadError() function always return non-null strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special reason except that I think of ReadError() helper method as a wrapper to StreamReader. But I agree that it would be cleaner to just throw in ReadError()

@mirichmo
Copy link
Member

@iSazonov Do you have any additional comments or concerns?

@iSazonov
Copy link
Collaborator

LGTM.

@mirichmo mirichmo merged commit a2922d6 into PowerShell:master Jun 29, 2017
@PaulHigin PaulHigin deleted the SSHErrorHang branch June 29, 2017 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug Issue has been identified as a bug in the product WG-Remoting PSRP issues with any transport layer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants