mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Remove Platform.HasExecutionPolicy query
Also change Get-ExecutionPolicy to not throw, but to return Unrestricted (which is the effect of the actual policy).
This commit is contained in:
1 parent
73a1a51f69
commit
e6c037c666
3 files changed
+9
-17
No files matched your search
@@ -217,12 +217,6 @@ namespace System.Management.Automation
|
||||
|
||||
}
|
||||
|
||||
// Linux does not have PowerShell execution policies
|
||||
internal static bool HasExecutionPolicy()
|
||||
{
|
||||
return IsWindows;
|
||||
}
|
||||
|
||||
// Linux has a single rooted file system
|
||||
internal static bool HasSingleRootFilesystem()
|
||||
{
|
||||
|
||||
@@ -138,11 +138,9 @@ namespace System.Management.Automation
|
||||
|
||||
internal static void SetExecutionPolicy(ExecutionPolicyScope scope, ExecutionPolicy policy, string shellId)
|
||||
{
|
||||
if (!Platform.HasExecutionPolicy())
|
||||
{
|
||||
#if LINUX
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
#else
|
||||
string executionPolicy = "Restricted";
|
||||
string preferenceKey = Utils.GetRegistryConfigurationPath(shellId);
|
||||
const string PolicyKeyValueName = "ExecutionPolicy";
|
||||
@@ -227,6 +225,7 @@ namespace System.Management.Automation
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Clean up the parents of a registry key as long as they
|
||||
@@ -283,11 +282,9 @@ namespace System.Management.Automation
|
||||
|
||||
internal static ExecutionPolicy GetExecutionPolicy(string shellId, ExecutionPolicyScope scope)
|
||||
{
|
||||
if (!Platform.HasExecutionPolicy())
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
#if LINUX
|
||||
return ExecutionPolicy.Unrestricted;
|
||||
#else
|
||||
switch (scope)
|
||||
{
|
||||
case ExecutionPolicyScope.Process:
|
||||
@@ -368,6 +365,7 @@ namespace System.Management.Automation
|
||||
}
|
||||
|
||||
return ExecutionPolicy.Restricted;
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static ExecutionPolicy ParseExecutionPolicy(string policy)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Describe "ExecutionPolicy" {
|
||||
|
||||
Context "Check Get-ExecutionPolicy behavior" {
|
||||
It "Should throw PlatformNotSupported when not on Windows" -Skip:$IsWindows {
|
||||
{ Get-ExecutionPolicy } | Should Throw "Operation is not supported on this platform."
|
||||
It "Should unrestricted when not on Windows" -Skip:$IsWindows {
|
||||
Get-ExecutionPolicy | Should Be Unrestricted
|
||||
}
|
||||
|
||||
It "Should return Microsoft.Powershell.ExecutionPolicy PSObject on Windows" -Skip:($IsLinux -Or $IsOSX) {
|
||||
|
||||
Reference in new issue
Block a user