Add new config option to support thread token based agent process to …#133
Open
masatma wants to merge 2 commits intorprichard:masterfrom
Open
Add new config option to support thread token based agent process to …#133masatma wants to merge 2 commits intorprichard:masterfrom
masatma wants to merge 2 commits intorprichard:masterfrom
Conversation
…start - Create agent proces from the thread token instead of current process. This is usefull when winpty.dll is called by Windows Service program to impersonate to the original user from a remote process.
rprichard
reviewed
Nov 13, 2017
Owner
rprichard
left a comment
There was a problem hiding this comment.
Yeah, this change seems basically OK.
| * See https://github.com/rprichard/winpty/issues/58. */ | ||
| #define WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION 0x8ull | ||
|
|
||
| /* Create agent proces from the thread token instead of current process. |
| #define WINPTY_FLAG_ALLOW_CURPROC_DESKTOP_CREATION 0x8ull | ||
|
|
||
| /* Create agent proces from the thread token instead of current process. | ||
| * This is usefull when winpty.dll is called by Windows Service program to |
| &sui, | ||
| &pi); | ||
| if (!success) { | ||
| CloseHandle(token); |
Owner
There was a problem hiding this comment.
I'd prefer this code use RAII (i.e. OwnedHandle), but I can fix that up myself after merging the change.
| nullptr, | ||
| nullptr, | ||
| FALSE, | ||
| CREATE_DEFAULT_ERROR_MODE | CREATE_BREAKAWAY_FROM_JOB | CREATE_UNICODE_ENVIRONMENT | NORMAL_PRIORITY_CLASS, |
Owner
There was a problem hiding this comment.
I'm curious about these creation flags.
- startAgentProcess is already called with a creation flags parameter, which is currently only set to either
DETACHED_PROCESS(for--create-desktop) orCREATE_NEW_CONSOLE(normal code path). This code doesn't ever useCREATE_NEW_CONSOLE, so I assume it reuses its parent's console, if it has one? - Regarding the specific flags:
CREATE_DEFAULT_ERROR_MODE: I wonder if this ought to be the default behavior for winpty -- there was a complaint a while ago about crash handling and winpty (When run in Terminal a programs unhandled exceptions don't produce debug dialog in win32 microsoft/vscode#32134), but I never looked into it. Maybe this creation flag fixes the problem?CREATE_UNICODE_ENVIRONMENT:lpEnvironmentis null; does this do anything?CREATE_BREAKAWAY_FROM_JOBandNORMAL_PRIORITY_CLASS: I wonder if these flags should really be set byWINPTY_FLAG_IMPERSONATE_THREADor whether they're orthogonal settings. Maybe winpty needs a way to specify arbitrary creation flags for the agent and/or the agent's child?
Author
|
can you push this change? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create agent proces from the thread token instead of current process. This is usefull when winpty.dll is called by Windows Service program to impersonate to the original user from a remote process.