-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Support Get-PSHostProcessInfo and Enter-PSHostProcess on non-Windows
#8232
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
Conversation
af2e3bb to
9b54fd2
Compare
Get-PSHostProcessInfo and Enter-PSHostProcess on non-WindowsGet-PSHostProcessInfo and Enter-PSHostProcess on non-Windows
a79d490 to
c65c187
Compare
Get-PSHostProcessInfo and Enter-PSHostProcess on non-WindowsGet-PSHostProcessInfo and Enter-PSHostProcess on non-Windows
3669b26 to
a6649fd
Compare
be57216 to
4a96f68
Compare
4a96f68 to
2504dd9
Compare
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Outdated
Show resolved
Hide resolved
Get-PSHostProcessInfo and Enter-PSHostProcess on non-WindowsGet-PSHostProcessInfo and Enter-PSHostProcess on non-Windows
|
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. |
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
TylerLeonhardt
left a comment
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 👍
src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Outdated
Show resolved
Hide resolved
|
I love when a PR has more deletions than insertions yet more functionality |
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/commands/EnterPSHostProcessCommand.cs
Show resolved
Hide resolved
src/System.Management.Automation/engine/remoting/common/RemoteSessionNamedPipe.cs
Show resolved
Hide resolved
|
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. |
|
@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. |
|
Yes, I have proposed dropping the Domain name. If it gets supported again in dotNet Core then we can add it back. |
|
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. |
010e0a4 to
6cbc498
Compare
daxian-dbw
left a comment
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.
|
@SteveL-MSFT I forgot about maintaining compatibility with Windows PowerShell. We definitely need to ensure we can still list/parse/connect to those hosts. |
|
Ugh, with the changes I've made since, I can't connect to/from Windows PowerShell and PowerShell Core. Debugging. |
|
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. @PaulHigin can you take another look? |
|
@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. |
|
@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 |
PaulHigin
left a comment
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.
|
@PaulHigin good suggestion. Let me add a test for Windows PowerShell interop. |
|
@SteveL-MSFT, there are tests about |
|
@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 |
|
Given @SteveL-MSFT's clarification on the AppVeyor test failure, I'm merging this PR. |
…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.
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 fromDefaultAppDomaintoNoneto shorten the name. Need to keep it since Windows PowerShell expects it. Changedstarttimepart 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
.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