summaryrefslogtreecommitdiff
path: root/TSRM
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2009-09-01 22:51:31 +0000
committerPierre Joye <pajoye@php.net>2009-09-01 22:51:31 +0000
commitddab8be51ea7050e78f98ee968187ca50095bffb (patch)
treeb3d63f29b80751f970a12f8c4225e15bd80d384c /TSRM
parentad2bb4bcb175f93d0d7820e2d4262ee5e691aa52 (diff)
downloadphp-git-ddab8be51ea7050e78f98ee968187ca50095bffb.tar.gz
- #27051, create process as impersonated user
Diffstat (limited to 'TSRM')
-rw-r--r--TSRM/tsrm_win32.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/TSRM/tsrm_win32.c b/TSRM/tsrm_win32.c
index 19139dd7ae..9cf1fa44ae 100644
--- a/TSRM/tsrm_win32.c
+++ b/TSRM/tsrm_win32.c
@@ -311,6 +311,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
SECURITY_ATTRIBUTES security;
HANDLE in, out;
DWORD dwCreateFlags = 0;
+ BOOL res;
process_pair *proc;
char *cmd;
int i;
@@ -370,12 +371,17 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
- if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process)) {
- free(cmd);
- return NULL;
+ 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);
}
free(cmd);
+ if (!res) {
+ return NULL;
+ }
+
CloseHandle(process.hThread);
proc = process_get(NULL TSRMLS_CC);