Don't fail if SaferPolicy API is not available on Win10 IoT or NanoServer#7075
Don't fail if SaferPolicy API is not available on Win10 IoT or NanoServer#7075adityapatwardhan merged 3 commits intoPowerShell:masterfrom
Conversation
fix install-powershellremoting to work on Windows PowerShell 5.1
| int lastError = Marshal.GetLastWin32Error(); | ||
| if (lastError == NativeConstants.FUNCTION_NOT_SUPPORTED) | ||
| { | ||
| _saferApiSupported = false; |
There was a problem hiding this comment.
The var name "_saferApiSupported" is kind of misleading because it is broad in a sense that there are other native API calls (Cert-related) in this file that neither utilize this 'global flag' nor set it in case of similar error handling (Win32Exception(Marshal.GetLastWin32Error())).
So for consistency either this"_saferApiSupported" flag should be added to them; or simply renamed to something more narrow like "_SaferIdentifyLevelApiSupported".
TravisEz13
left a comment
There was a problem hiding this comment.
other than the issue we discussed offline, looks good to me
| /// MAX_PATH -> 260 | ||
| internal const int MAX_PATH = 260; | ||
|
|
||
| /// This function is not supported on this system |
There was a problem hiding this comment.
:-) CodeFactor says that we use incorrect documentation header.
|
|
||
| #endregion execution policy | ||
|
|
||
| private static bool _SaferIdentifyLevelApiSupported = true; |
There was a problem hiding this comment.
From CodeFactor - Variable names and private field names must start with a lower-case letter.
PR Summary
We P/Invoke to the SaferPolicy APIs which are not available on Win10 IoT or NanoServer.
If the Win32 error indicates that the api is not supported, we default to Allowed.
Updated
Install-PowerShellRemoting.ps1to work correctly on Windows PowerShell Core 5 so that you can install PSCore6 remoting on Win10 IoT.Fix #6750
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests