mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix for SSH remoting when banner is enabled on SSHD endpoint (#16205)
This commit is contained in:
@@ -23,6 +23,7 @@ namespace System.Management.Automation
|
||||
internal const string EngineSource = "PSEngine";
|
||||
internal const string PSNativeCommandArgumentPassingFeatureName = "PSNativeCommandArgumentPassing";
|
||||
internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference";
|
||||
internal const string PSRemotingSSHTransportErrorHandling = "PSRemotingSSHTransportErrorHandling";
|
||||
internal const string PSCleanBlockFeatureName = "PSCleanBlock";
|
||||
|
||||
#endregion
|
||||
@@ -127,6 +128,9 @@ namespace System.Management.Automation
|
||||
new ExperimentalFeature(
|
||||
name: PSNativeCommandErrorActionPreferenceFeatureName,
|
||||
description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"),
|
||||
new ExperimentalFeature(
|
||||
name: PSRemotingSSHTransportErrorHandling,
|
||||
description: "Removes the SSH remoting transport stdErr stream message handling as terminating errors, and instead just writes error messages to console."),
|
||||
new ExperimentalFeature(
|
||||
name: PSCleanBlockFeatureName,
|
||||
description: "Add support of a 'Clean' block to functions and script cmdlets for easy resource cleanup"),
|
||||
|
||||
+33
-1
@@ -1762,7 +1762,39 @@ namespace System.Management.Automation.Remoting.Client
|
||||
|
||||
while (true)
|
||||
{
|
||||
string error = ReadError(reader);
|
||||
string error;
|
||||
|
||||
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSRemotingSSHTransportErrorHandling))
|
||||
{
|
||||
// Blocking read from StdError stream
|
||||
error = reader.ReadLine();
|
||||
|
||||
if (error == null)
|
||||
{
|
||||
// Stream is closed unexpectedly.
|
||||
throw new PSInvalidOperationException(RemotingErrorIdStrings.SSHAbruptlyTerminated);
|
||||
}
|
||||
|
||||
if (error.Length == 0)
|
||||
{
|
||||
// Ignore
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Messages in error stream from ssh are unreliable, and may just be warnings or
|
||||
// banner text.
|
||||
// So just report the messages but don't act on them.
|
||||
System.Console.WriteLine(error);
|
||||
}
|
||||
catch (IOException)
|
||||
{ }
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
error = ReadError(reader);
|
||||
|
||||
if (error.Length == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user