Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

masatma
Copy link

@masatma masatma commented Nov 10, 2017

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.

…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.
Copy link
Owner

@rprichard rprichard left a 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.

@@ -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.
Copy link
Owner

Choose a reason for hiding this comment

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

s/proces/process

Copy link
Author

Choose a reason for hiding this comment

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

done

@@ -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
Copy link
Owner

Choose a reason for hiding this comment

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

s/usefull/useful

Copy link
Author

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);
Copy link
Owner

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.

Copy link
Author

Choose a reason for hiding this comment

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

left as is.

nullptr,
nullptr,
FALSE,
CREATE_DEFAULT_ERROR_MODE | CREATE_BREAKAWAY_FROM_JOB | CREATE_UNICODE_ENVIRONMENT | NORMAL_PRIORITY_CLASS,
Copy link
Owner

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) or CREATE_NEW_CONSOLE (normal code path). This code doesn't ever use CREATE_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 and NORMAL_PRIORITY_CLASS: I wonder if these flags should really be set by WINPTY_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?

@masatma
Copy link
Author

masatma commented Mar 23, 2018

can you push this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants