Skip to content

NoClobber WinCompat module import #12269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 16, 2020
Merged

Conversation

anmenaga
Copy link

@anmenaga anmenaga commented Apr 7, 2020

PR Summary

Fix #11419
This addresses an issue where Windows PowerShell proxy modules have a priority over PS Core modules during WinCompat module import. (see #11419 )

PR Context

Implicit PS Remoting code (reused by WinCompat) is doing Export-PSSession -AllowClobber.
The fix is to omit -AllowClobber parameter if WinCompat:

  1. is either importing a module that is one of the engine modules:
"Microsoft.PowerShell.Utility",
"Microsoft.PowerShell.Management",
"Microsoft.PowerShell.Diagnostics",
"Microsoft.PowerShell.Host",
"Microsoft.PowerShell.Security",
"Microsoft.WSMan.Management",
"Microsoft.PowerShell.Commands.Utility",
"Microsoft.PowerShell.Commands.Management",
"Microsoft.PowerShell.Commands.Diagnostics",
"Microsoft.PowerShell.ConsoleHost"
  1. or is importing a module specified in powershell.config.json in WindowsPowerShellCompatibilityNoClobberModuleList list. (this list is empty by default)

If a module falls into one of these buckets, then PS-Core version of the module is imported first (for engine modules from $PSHOME\Modules), then proxies are generated for WinPS version of the module without -AllowClobber flag. This result s in proxy modules not having PS Core commands.

Fix #11419
Fix #12014

Also fixed a bug where WinCompat module DenyList was not working for module names containing dots . in some cases.

PR Checklist

@anmenaga anmenaga added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Apr 7, 2020
@anmenaga anmenaga added this to the 7.1.0-preview.2 milestone Apr 7, 2020
@anmenaga anmenaga requested a review from SteveL-MSFT April 7, 2020 04:35
@ghost ghost assigned daxian-dbw Apr 7, 2020
@iSazonov
Copy link
Collaborator

iSazonov commented Apr 7, 2020

Do we want to have the fix as servicing one for 7.0 LTS?

@daxian-dbw
Copy link
Member

@PoshChan please retry windows

@PoshChan
Copy link
Collaborator

PoshChan commented Apr 8, 2020

@daxian-dbw, successfully started retry of PowerShell-CI-Windows

@anmenaga anmenaga changed the title NoClobber WinCompat module import WIP: NoClobber WinCompat module import Apr 8, 2020
@anmenaga anmenaga changed the title WIP: NoClobber WinCompat module import NoClobber WinCompat module import Apr 14, 2020
@SteveL-MSFT SteveL-MSFT requested a review from rjmholt April 14, 2020 20:40
Copy link
Collaborator

@rjmholt rjmholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, but I think there are some cases with module specifications that need dealing with. Also left some style comments

@ghost ghost added the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Apr 14, 2020
@ghost ghost removed the Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept label Apr 15, 2020
@anmenaga
Copy link
Author

@PoshChan please retry windows

@PoshChan
Copy link
Collaborator

@anmenaga, successfully started retry of PowerShell-CI-Windows

@daxian-dbw daxian-dbw merged commit 0c69537 into PowerShell:master Apr 16, 2020
@TravisEz13 TravisEz13 modified the milestones: 7.0.1-approved, 7.0.1 Apr 20, 2020
@ghost
Copy link

ghost commented Apr 23, 2020

🎉v7.1.0-preview.2 has been released which incorporates this pull request.:tada:

Handy links:

@ghost
Copy link

ghost commented May 14, 2020

🎉v7.0.1 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
None yet
8 participants