mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
[release/v7.5] Fix up SSHConnectionInfo ssh PATH checks (#26165)
This commit is contained in:
@@ -145,7 +145,7 @@
|
||||
<AssemblyTitle>PowerShell 7</AssemblyTitle>
|
||||
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
<PropertyGroup>
|
||||
<!-- source generator project needs to target 'netstandard2.0' -->
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
|
||||
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
|
||||
<NoWarn>RS1035</NoWarn>
|
||||
|
||||
@@ -2206,12 +2206,54 @@ namespace System.Management.Automation.Runspaces
|
||||
var context = Runspaces.LocalPipeline.GetExecutionContextFromTLS();
|
||||
if (context != null)
|
||||
{
|
||||
var cmdInfo = context.CommandDiscovery.LookupCommandInfo(sshCommand, CommandOrigin.Internal) as ApplicationInfo;
|
||||
var cmdInfo = CommandDiscovery.LookupCommandInfo(
|
||||
sshCommand,
|
||||
CommandTypes.Application,
|
||||
SearchResolutionOptions.None,
|
||||
CommandOrigin.Internal,
|
||||
context) as ApplicationInfo;
|
||||
|
||||
if (cmdInfo != null)
|
||||
{
|
||||
filePath = cmdInfo.Path;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// A Runspace may not be present in the TLS in SDK hosted apps
|
||||
// or if running in another thread without a Runspace. While
|
||||
// 'ProcessStartInfo' can lookup the full path in PATH, it searches
|
||||
// the process' working directory first. 'LookupCommandInfo' does
|
||||
// not search the process' working directory and we want to keep that
|
||||
// behavior. We also get the parent dir of the full path to set as the
|
||||
// new WorkingDirectory. So, we do a manual lookup here only in PATH.
|
||||
string[] entries = Environment.GetEnvironmentVariable("PATH")?.Split(
|
||||
Path.PathSeparator,
|
||||
StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
|
||||
foreach (var path in entries)
|
||||
{
|
||||
if (!Path.IsPathFullyQualified(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var sshCommandPath = Path.Combine(path, sshCommand);
|
||||
if (File.Exists(sshCommandPath))
|
||||
{
|
||||
filePath = sshCommandPath;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
throw new CommandNotFoundException(
|
||||
sshCommand,
|
||||
null,
|
||||
"CommandNotFoundException",
|
||||
DiscoveryExceptions.CommandNotFoundException);
|
||||
}
|
||||
|
||||
// Create a local ssh process (client) that conects to a remote sshd process (server) using a 'powershell' subsystem.
|
||||
//
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<Copyright>(c) Microsoft Corporation.</Copyright>
|
||||
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>$(PERFLAB_TARGET_FRAMEWORKS)</TargetFrameworks>
|
||||
<TargetFramework Condition="'$(TargetFrameworks)' == ''">net5.0</TargetFramework>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BenchmarkDotNet.Annotations" Version="0.14.0" />
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
<InformationalVersion>1.0.0</InformationalVersion>
|
||||
<TargetFrameworks>net9.0</TargetFrameworks>
|
||||
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -17,13 +17,13 @@ namespace mvc.Controllers
|
||||
Hashtable args = new Hashtable();
|
||||
foreach (var key in Request.Query.Keys)
|
||||
{
|
||||
args.Add(key, string.Join(Constants.HeaderSeparator, Request.Query[key]));
|
||||
args.Add(key, string.Join(Constants.HeaderSeparator, (string)Request.Query[key]));
|
||||
}
|
||||
|
||||
Hashtable headers = new Hashtable();
|
||||
foreach (var key in Request.Headers.Keys)
|
||||
{
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, Request.Headers[key]));
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, (string)Request.Headers[key]));
|
||||
}
|
||||
|
||||
Hashtable output = new Hashtable
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace mvc.Controllers
|
||||
Hashtable headers = new Hashtable();
|
||||
foreach (var key in Request.Headers.Keys)
|
||||
{
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, Request.Headers[key]));
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, (string)Request.Headers[key]));
|
||||
}
|
||||
|
||||
Hashtable output = new Hashtable
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace mvc.Controllers
|
||||
Hashtable headers = new Hashtable();
|
||||
foreach (var key in Request.Query.Keys)
|
||||
{
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, Request.Query[key]));
|
||||
headers.Add(key, string.Join(Constants.HeaderSeparator, (string)Request.Query[key]));
|
||||
|
||||
if (string.Equals("Content-Type", key, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<DelaySign>true</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>$(SnkFile)</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Management.Automation">
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<DelaySign>true</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>$(SnkFile)</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Management.Automation">
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<DelaySign>true</DelaySign>
|
||||
<AssemblyOriginatorKeyFile>$(SnkFile)</AssemblyOriginatorKeyFile>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<LangVersion>11.0</LangVersion>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
|
||||
|
||||
Reference in New Issue
Block a user