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 — Support `Get-PSHostProcessInfo` and `Enter-PSHostProcess` on non-Windows by SteveL-MSFT · Pull Request #8232 · PowerShell/PowerShell

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 11, 2018 •
edited by daxian-dbw
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

PR Summary

There a some differences in support of named pipes for Windows and non-Windows. Named pipes on Unix have a 104 character path limit. On macOS, the $env:TMPDIR (on my system) is already 49 characters; corefx adds 12 more. Since AppDomainName isn't really used, changed it from DefaultAppDomain to None to shorten the name. Need to keep it since Windows PowerShell expects it. Changed starttime part of pipe name to 8 hex characters which is to provide uniqueness to the pipe name.

Fix #5110
Possibly also fix 6435, but need verification. #6435

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.

KirkMunro, SeeminglyScience, and TylerLeonhardt reacted with hooray emoji
All reactions
  • 🎉 3 reactions
@SteveL-MSFT
initial code to add UNIX path to named pipes
6b917a0
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested a review from Paul Higinbotham (PaulHigin) November 11, 2018 22:19
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Bruce Payette (BrucePay), Travis Plunk (TravisEz13), Aditya Patwardhan (adityapatwardhan), Andrew (anmenaga), Dongbo Wang (daxian-dbw) and Mike Richmond (mirichmo) as code owners November 11, 2018 22:19
@SteveL-MSFT
fix codefactor and test failure
9b54fd2
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch from af2e3bb to 9b54fd2 Compare November 12, 2018 00:00
Steve Lee (POWERSHELL)
remove unnecessary legacy Windows specific doe
589c644
@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title WIP: Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows Nov 12, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch from a79d490 to c65c187 Compare November 12, 2018 00:25
@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows WIP: Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows Nov 12, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch 2 times, most recently from 3669b26 to a6649fd Compare November 12, 2018 01:08
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Dongbo Wang (daxian-dbw) Nov 12, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch 2 times, most recently from be57216 to 4a96f68 Compare November 12, 2018 01:38
@SteveL-MSFT
[feature]
2504dd9
cleanup existing Windows specific code and update tests
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch from 4a96f68 to 2504dd9 Compare November 12, 2018 01:58
iSazonov
Ilya (iSazonov) reviewed Nov 12, 2018
View reviewed changes
Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

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

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

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

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

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

Steve Lee (SteveL-MSFT) added 2 commits November 11, 2018 22:41
@SteveL-MSFT
address Ilya's feedback, some minor cleanup
33f6254
@SteveL-MSFT
[feature]
60f2f7d
use same model as AMSI uninitialize to cleanup named pipes on exit
when enumerating pshostprocessinfo, check if they are valid, otherwise exclude and try to remove
@SteveL-MSFT Steve Lee (SteveL-MSFT) changed the title WIP: Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows Nov 12, 2018
@PaulHigin

Paul Higinbotham (PaulHigin) commented Nov 12, 2018

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT)

Regarding the server named pipe dispose, this is done in WindowsPowerShell via the CLR AppDomain unload event, which is not supported on CORECLR. However, you can use the AppDomain.CurrentDomain.ProcessExit event that we use for AMSI un-initializing. Unfortunately, these CLR events are not reliable, but they are better than nothing.

The start time added to the filename is intended to make the named pipe instance unique, to prevent a DOS or man-in-the-middle attack. We will want to keep something like this, even if it means using something shorter.

SteveL-MSFT reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

PaulHigin
Paul Higinbotham (PaulHigin) suggested changes Nov 12, 2018
View reviewed changes
Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

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

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

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

@SteveL-MSFT
[feature]
f2a9c04
address Paul's feedback
TylerLeonhardt
TylerLeonhardt approved these changes Nov 12, 2018
View reviewed changes

@TylerLeonhardt TylerLeonhardt 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
Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

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

Comment thread src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs Resolved

Uh oh!

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

Comment thread src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs Resolved

Uh oh!

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

@TylerLeonhardt

TylerLeonhardt commented Nov 12, 2018 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

I love when a PR has more deletions than insertions yet more functionality

vexx32 reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

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

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Nov 13, 2018

Copy link
Copy Markdown
Member

As for the domain name, do we really need it for the pipe name? Is multiple domain is going to be supported in .NET Core 3.0?

I have no problem keeping it for now until we get an accurate answer for the app domain support.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 13, 2018

Copy link
Copy Markdown
Member Author

Dongbo Wang (@daxian-dbw) best I can tell, AppDomains are deprecated in .Net Core and not in the roadmap I can see for 3.0. So it may be fine to remove it for non-Windows. We'll have to keep it for Windows so that Windows PowerShell and PowerShell Core interop still works however.

daxian-dbw reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@PaulHigin

Paul Higinbotham (PaulHigin) commented Nov 13, 2018

Copy link
Copy Markdown
Contributor

Yes, I have proposed dropping the Domain name. If it gets supported again in dotNet Core then we can add it back.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 14, 2018

Copy link
Copy Markdown
Member Author

To retain interoperability between Windows PowerShell and keep the code similar between Windows and non-Windows, I'll shorten the DefaultAppDomainName to 'none' but will keep it in the pipe name.

All reactions

Sorry, something went wrong.

Uh oh!

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

@TravisEz13 Travis Plunk (TravisEz13) added the CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log label Nov 14, 2018
@SteveL-MSFT
[feature]
6cbc498
address Paul and Dongbo's feedback
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the named-pipes branch from 010e0a4 to 6cbc498 Compare November 14, 2018 06:50
@SteveL-MSFT Steve Lee (SteveL-MSFT) removed Breaking-Change breaking change that may affect users CL-BreakingChange Indicates that a PR should be marked as a breaking change in the Change Log labels Nov 14, 2018
@daxian-dbw
Remove extra new lines
6d46bad
daxian-dbw
Dongbo Wang (daxian-dbw) approved these changes Nov 14, 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.

We'll have to keep it for Windows so that Windows PowerShell and PowerShell Core interop still works however.

Then we should keep the AppDomain field on all platforms. none is short enough and it's better to keep the same schema.

Sorry, something went wrong.

Uh oh!

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

All reactions
@PaulHigin

Paul Higinbotham (PaulHigin) commented Nov 14, 2018

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) I forgot about maintaining compatibility with Windows PowerShell. We definitely need to ensure we can still list/parse/connect to those hosts.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 14, 2018

Copy link
Copy Markdown
Member Author

Ugh, with the changes I've made since, I can't connect to/from Windows PowerShell and PowerShell Core. Debugging.

All reactions

Sorry, something went wrong.

Uh oh!

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

Steve Lee (POWERSHELL)
[feature]
f08bf2a
revert defaultappdomainname and starttime format on Windows as it's needed to interop with Windows PowerShell
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 14, 2018

Copy link
Copy Markdown
Member Author

Looks like DefaultAppDomain is necessary on Windows as there is a check for that string and the starttime needs to stay as filetime integers on Windows to support interop between Windows PowerShell and PowerShell Core. I believe everything else is addressed. Paul Higinbotham (@PaulHigin) can you take another look?

daxian-dbw reacted with confused emoji
All reactions
  • 😕 1 reaction

Sorry, something went wrong.

Uh oh!

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

@PaulHigin

Paul Higinbotham (PaulHigin) commented Nov 14, 2018

Copy link
Copy Markdown
Contributor

Steve Lee (@SteveL-MSFT) Yeah, for Windows we need to keep the DomainName to be able to connect to WindowsPowerShell host, and that means keeping the default domain name for Windows platform pipe names.

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 14, 2018

Copy link
Copy Markdown
Member Author

Paul Higinbotham (@PaulHigin) yes, the recent commit has the same DefaultAppDomainName and starttime format on Windows and I verified manually it works from and to Windows PowerShell

All reactions

Sorry, something went wrong.

Uh oh!

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

PaulHigin
Paul Higinbotham (PaulHigin) approved these changes Nov 14, 2018
View reviewed changes

@PaulHigin Paul Higinbotham (PaulHigin) left a comment

Copy link
Copy Markdown
Contributor

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

I wonder if we should add a test to ensure WindowsPowerShell is listed by Get-PSHostProcessInfo? WindowsPowerShell is always installed on Windows so it shouldn't be too hard to run powershell.exe and check.

Sorry, something went wrong.

Uh oh!

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

All reactions
@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 15, 2018

Copy link
Copy Markdown
Member Author

Paul Higinbotham (@PaulHigin) good suggestion. Let me add a test for Windows PowerShell interop.

All reactions

Sorry, something went wrong.

Uh oh!

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

Steve Lee (POWERSHELL)
[feature]
1f26306
added tests to validate interop with Windows PowerShell
@daxian-dbw

Dongbo Wang (daxian-dbw) commented Nov 15, 2018

Copy link
Copy Markdown
Member

Steve Lee (@SteveL-MSFT), there are tests about Enter-PSHostProcess failing in AppVeyor, can you please take a look?

All reactions

Sorry, something went wrong.

Uh oh!

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

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 15, 2018

Copy link
Copy Markdown
Member Author

Dongbo Wang (@daxian-dbw) it appears to be a problem with redirected input with PSReadLine and only on AppVeyor. We're moving off AppVeyor (eventually), so I think we can ignore this otherwise we'll have to special case this by perhaps removing PSReadLine for this test

daxian-dbw reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

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

@daxian-dbw

Dongbo Wang (daxian-dbw) commented Nov 15, 2018

Copy link
Copy Markdown
Member

Given Steve Lee (@SteveL-MSFT)'s clarification on the AppVeyor test failure, I'm merging this PR.

All reactions

Sorry, something went wrong.

Uh oh!

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

@daxian-dbw Dongbo Wang (daxian-dbw) added the Documentation Needed in this repo Documentation is needed in this repo label Nov 15, 2018
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit c5dd3bd into PowerShell:master Nov 15, 2018
Ilya (iSazonov) pushed a commit to iSazonov/PowerShell that referenced this pull request Nov 29, 2018
@SteveL-MSFT @iSazonov
Support 'Get-PSHostProcessInfo' and 'Enter-PSHostProcess' on Unix pla…
cb0b1cd
…tforms (PowerShell#8232)

There a some differences in support of named pipes for Windows and non-Windows.  Named pipes on Unix have a 104 character path limit.  On macOS, the `$env:TMPDIR` (on my system) is already 49 characters; corefx adds 12 more.  Since AppDomainName isn't really used, changed it from `DefaultAppDomain` to `None` to shorten the name.  Need to keep it since Windows PowerShell expects it.  Changed `starttime` part of pipe name to 8 hex characters which is to provide uniqueness to the pipe name.
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Dec 3, 2018
@JustinGrote Justin Grote (JustinGrote) mentioned this pull request Jan 3, 2019
Invoke-Command : Windows Principal functionality is not supported on this platform. #6435
Closed
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the named-pipes branch March 10, 2020 21:02
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @daxian-dbw
Support 'Get-PSHostProcessInfo' and 'Enter-PSHostProcess' on Unix pla…
c23a950
…tforms (PowerShell#8232)

There a some differences in support of named pipes for Windows and non-Windows.  Named pipes on Unix have a 104 character path limit.  On macOS, the `$env:TMPDIR` (on my system) is already 49 characters; corefx adds 12 more.  Since AppDomainName isn't really used, changed it from `DefaultAppDomain` to `None` to shorten the name.  Need to keep it since Windows PowerShell expects it.  Changed `starttime` part of pipe name to 8 hex characters which is to provide uniqueness to the pipe name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov left review comments
@daxian-dbw Dongbo Wang (daxian-dbw) daxian-dbw approved these changes
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) Awaiting requested review from adityapatwardhan
@anmenaga Andrew (anmenaga) Awaiting requested review from anmenaga
@BrucePay Bruce Payette (BrucePay) Awaiting requested review from BrucePay
@mirichmo Mike Richmond (mirichmo) Awaiting requested review from mirichmo
@TravisEz13 Travis Plunk (TravisEz13) Awaiting requested review from TravisEz13 TravisEz13 is a code owner
+2 more reviewers
@TylerLeonhardt TylerLeonhardt TylerLeonhardt approved these changes
@PaulHigin Paul Higinbotham (PaulHigin) PaulHigin approved these changes
Reviewers whose approvals may not affect merge requirements

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 Documentation Needed in this repo Documentation is needed in this repo

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

port Get-PSHostProcessInfo and Enter-PSHostProcess cmdlets to non-Windows

Uh oh!

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

7 participants

@SteveL-MSFT @PaulHigin @TylerLeonhardt @daxian-dbw @iSazonov @TravisEz13 @adityapatwardhan
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.