-
Notifications
You must be signed in to change notification settings - Fork 166
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
Add new config option to support thread token based agent process to … #133
base: master
Are you sure you want to change the base?
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.
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.
Yeah, this change seems basically OK.
src/include/winpty_constants.h
Outdated
@@ -76,11 +76,18 @@ | |||
* 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. |
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.
s/proces/process
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.
done
src/include/winpty_constants.h
Outdated
@@ -76,11 +76,18 @@ | |||
* 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. | |||
* This is usefull when winpty.dll is called by Windows Service program to |
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.
s/usefull/useful
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.
done
&sui, | ||
&pi); | ||
if (!success) { | ||
CloseHandle(token); |
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.
I'd prefer this code use RAII (i.e. OwnedHandle), but I can fix that up myself after merging the change.
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.
left as is.
src/libwinpty/winpty.cc
Outdated
nullptr, | ||
nullptr, | ||
FALSE, | ||
CREATE_DEFAULT_ERROR_MODE | CREATE_BREAKAWAY_FROM_JOB | CREATE_UNICODE_ENVIRONMENT | NORMAL_PRIORITY_CLASS, |
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.
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
:lpEnvironment
is null; does this do anything?CREATE_BREAKAWAY_FROM_JOB
andNORMAL_PRIORITY_CLASS
: I wonder if these flags should really be set byWINPTY_FLAG_IMPERSONATE_THREAD
or whether they're orthogonal settings. Maybe winpty needs a way to specify arbitrary creation flags for the agent and/or the agent's child?
can you push this change? |
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.