Skip to content

Fix for SSH remoting when SSH client abruptly terminates#4123

Merged
mirichmo merged 4 commits intoPowerShell:masterfrom
PaulHigin:SSHErrorHang
Jun 29, 2017
Merged

Fix for SSH remoting when SSH client abruptly terminates#4123
mirichmo merged 4 commits intoPowerShell:masterfrom
PaulHigin:SSHErrorHang

Conversation

@PaulHigin
Copy link
Copy Markdown
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
<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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

@iSazonov Do you have any additional comments or concerns?

@iSazonov
Copy link
Copy Markdown
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.

4 participants