GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add fix for nested (Debug-Runspace) debugging on non-Windows platforms and re-enable Windows identity impersonation flow by PaulHigin · Pull Request #8451 · PowerShell/PowerShell

Conversation

@PaulHigin

@PaulHigin Paul Higinbotham (PaulHigin) commented Dec 11, 2018

Copy link
Copy Markdown
Contributor

PR Summary

Nested runspace debugging is now supported on non-Windows platforms after Enter-PSHostProcess was added. However, nested debugging was broken because the Windows impersonation code portion was not fully ifdefed out.

This change removes Windows only impersonation code for cross platform builds. It also updates the Windows impersonation flow code to work with dotNet Core.

Repro:

# On one PowerShell shell instance run:
$pid
14931

$ps = [powershell]::Create()
$ps.AddScript('1..20 | % { sleep 1; "Output $_" }').Invoke()

# On second PowerShell shell run:
Enter-PSHostProcess -Id 14931
[Process:14931]: PS > Debug-Runspace -Id 2

Expect:
Should be able to run a nested debug session on script.

Result:
Cannot debug script due to "Unsupported platform error".

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@PaulHigin
Removed Windows impersonation for UNIX builds, updated impersonation …
4d3e50d
…flow for Core
@PaulHigin Paul Higinbotham (PaulHigin) added Issue-Bug Issue has been identified as a bug in the product OS-macOS OS-Linux WG-Remoting PSRP issues with any transport layer labels Dec 11, 2018
@PaulHigin Paul Higinbotham (PaulHigin) assigned Dongbo Wang (daxian-dbw) Dec 11, 2018
@PaulHigin
Paul Higinbotham (PaulHigin) requested a review from Travis Plunk (TravisEz13) December 11, 2018 18:35
@PaulHigin
Paul Higinbotham (PaulHigin) requested a review from Mike Richmond (mirichmo) as a code owner December 11, 2018 18:35
@PaulHigin
Paul Higinbotham (PaulHigin) removed the request for review from Mike Richmond (mirichmo) December 11, 2018 21:32
TravisEz13
Travis Plunk (TravisEz13) approved these changes Dec 11, 2018
View reviewed changes
@TravisEz13 Travis Plunk (TravisEz13) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Dec 11, 2018
@PaulHigin
Fix CodFactor issue
c9fc4ef
daxian-dbw
Dongbo Wang (daxian-dbw) reviewed Dec 12, 2018
View reviewed changes

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Travis Plunk (@TravisEz13) Paul Higinbotham (@PaulHigin) We ran into an issue before with WindowsIdentity.RunImpersonated(safeAccessTokenHandle, action) on Windows when porting powershell to CoreCLR, and it caused powershell to crash. We (us and .NET Core team) never figured out what was the root cause. I don't know if that issue is gone with the latest .NET Core. I will forward you the email thread on this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

@TravisEz13 Travis Plunk (TravisEz13) changed the title Add fix for nested (Debug-Runspace) debugging on non-Windows platforms WIP: Add fix for nested (Debug-Runspace) debugging on non-Windows platforms Dec 13, 2018
@PaulHigin
Enabled all engine code that flows Windows impersonation to use dotNe…
7907ed6
…t RunImpersonated.
@PaulHigin
Paul Higinbotham (PaulHigin) requested a review from Bruce Payette (BrucePay) as a code owner December 14, 2018 17:29
@PaulHigin

Paul Higinbotham (PaulHigin) commented Dec 14, 2018

Copy link
Copy Markdown
Contributor Author

Looking through the code I realized there were many more places in the engine where Windows identity impersonation flow was disabled. This is needed to support rare but important Windows scenarios. I submitted a commit that re-enables these using the new dotNet RunImpersonated API.

I will also update the title to reflect these new changes.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulHigin Paul Higinbotham (PaulHigin) changed the title WIP: Add fix for nested (Debug-Runspace) debugging on non-Windows platforms Add fix for nested (Debug-Runspace) debugging on non-Windows platforms and re-enable Windows identity impersonation flow Dec 14, 2018
Paul Higinbotham (PaulHigin) added 2 commits December 14, 2018 09:36
@PaulHigin
[Feature]
4d9adec
@PaulHigin
[Feature]
c0efbe9
@PaulHigin

Paul Higinbotham (PaulHigin) commented Dec 18, 2018

Copy link
Copy Markdown
Contributor Author

Dongbo Wang (@daxian-dbw) All tests have passed. Can this be merged?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

daxian-dbw
Dongbo Wang (daxian-dbw) reviewed Dec 18, 2018
View reviewed changes
Comment thread src/System.Management.Automation/engine/Utils.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/Utils.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/fanin/WSManTransportManager.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/remoting/server/ServerRunspacePoolDriver.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread src/System.Management.Automation/engine/hostifaces/LocalPipeline.cs Resolved

Uh oh!

There was an error while loading. Please reload this page.

Paul Higinbotham (PaulHigin) added 2 commits December 18, 2018 13:28
@PaulHigin
[Feature] Address CR comments
1dc2116
@PaulHigin
[Feature] Clean up of pipeline thread impersonation
d1f682d
daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Dec 18, 2018
View reviewed changes

@daxian-dbw Dongbo Wang (daxian-dbw) left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
[Feature] Minor change: always initialize _identityToImpersonate to…
f7ba57a
… null initially
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit bc29337 into PowerShell:master Dec 19, 2018
@PaulHigin
Paul Higinbotham (PaulHigin) deleted the fix-unix-ipc-debugging branch December 19, 2018 18:31
@PaulHigin Paul Higinbotham (PaulHigin) mentioned this pull request Jan 5, 2019
Invoke-Command : Windows Principal functionality is not supported on this platform. #6435
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@PaulHigin @daxian-dbw
Fix 'Debug-Runspace' for Unix platforms and properly enable Windows i…
1fcd0fe
…dentity impersonation code (PowerShell#8451)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
@TravisEz13 Travis Plunk (TravisEz13) TravisEz13 approved these changes
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@daxian-dbw Dongbo Wang (daxian-dbw)

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log Issue-Bug Issue has been identified as a bug in the product OS-Linux OS-macOS WG-Remoting PSRP issues with any transport layer

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@PaulHigin @daxian-dbw @TravisEz13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.