- #27051, create process as impersonated user

This commit is contained in:
Pierre Joye 2009-09-01 22:51:31 +00:00
parent ad2bb4bcb1
commit ddab8be51e
2 changed files with 12 additions and 4 deletions

2
NEWS
View file

@ -177,6 +177,8 @@ PHP NEWS
- Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo). - Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo).
(Kalle, Rick Yorgason) (Kalle, Rick Yorgason)
- Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett) - Fixed bug #28038 (Sent incorrect RCPT TO commands to SMTP server) (Garrett)
- Fixed bug #27051 (Impersonation with FastCGI does not exec process as
impersonated user). (Pierre)
30 Jun 2009, PHP 5.3.0 30 Jun 2009, PHP 5.3.0
- Upgraded bundled PCRE to version 7.9. (Nuno) - Upgraded bundled PCRE to version 7.9. (Nuno)

View file

@ -311,6 +311,7 @@ TSRM_API FILE *popen_ex(const char *command, const char *type, const char *cwd,
SECURITY_ATTRIBUTES security; SECURITY_ATTRIBUTES security;
HANDLE in, out; HANDLE in, out;
DWORD dwCreateFlags = 0; DWORD dwCreateFlags = 0;
BOOL res;
process_pair *proc; process_pair *proc;
char *cmd; char *cmd;
int i; 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); cmd = (char*)malloc(strlen(command)+strlen(TWG(comspec))+sizeof(" /c ")+2);
sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command); sprintf(cmd, "%s /c \"%s\"", TWG(comspec), command);
if (!CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process)) { if(TWG(impersonation_token) == NULL) {
free(cmd); res = CreateProcess(NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
return NULL; } else {
res = CreateProcessAsUser(TWG(impersonation_token), NULL, cmd, &security, &security, security.bInheritHandle, dwCreateFlags, env, cwd, &startup, &process);
} }
free(cmd); free(cmd);
if (!res) {
return NULL;
}
CloseHandle(process.hThread); CloseHandle(process.hThread);
proc = process_get(NULL TSRMLS_CC); proc = process_get(NULL TSRMLS_CC);