summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2009-09-02 01:59:17 +0000
committerPierre Joye <pajoye@php.net>2009-09-02 01:59:17 +0000
commitda9aee970329e083ee3adfd0df94e6f92acdffba (patch)
treea3884f71a0e3c800833a4d1d19de07cce4daf8d5 /TSRM
parentbfd9f29773480dff8f9753328e1c60b88828f187 (diff)
downloadphp-git-da9aee970329e083ee3adfd0df94e6f92acdffba.tar.gz
- #27051, we need the thread token here, not the process
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_win32.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 9cf1fa44ae..c96ffb687d 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -316,6 +316,8 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
char *cmd;
int i;
char *ptype = (char *)type;
+ HANDLE thread_token = NULL;
+ HANDLE token_user = NULL;
TSRMLS_FETCH();
if (!type) {
@@ -368,14 +370,16 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
dwCreateFlags |= CREATE_NO_WINDOW;
}
+ /* Get a token with the impersonated user. */
+ if(OpenThreadToken(GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, &thread_token)) {
+ DuplicateTokenEx(thread_token, MAXIMUM_ALLOWED, &security, SecurityImpersonation, TokenPrimary, &token_user);
+ }
+
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
- if(TWG(impersonation_token) == NULL) {
- res = CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
- } else {
- res = CreateProcessAsUser(TWG(impersonation_token), NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
- }
+ res = CreateProcessAsUser(token_user, NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
+ CloseHandle(token_user);
free(cmd);
if (!res) {