pajoye                                   Tue, 01 Sep 2009 22:51:31 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=287954

Log:
- #27051, create process as impersonated user

Bug: http://bugs.php.net/27051 (Assigned) Impersonation with FastCGI does not 
EXEC process as impersonated user
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c
    U   php/php-src/trunk/TSRM/tsrm_win32.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2009-09-01 20:12:02 UTC (rev 287953)
+++ php/php-src/branches/PHP_5_3/NEWS   2009-09-01 22:51:31 UTC (rev 287954)
@@ -176,7 +176,9 @@
   com, Kalle)
 - Fixed bug #38091 (Mail() does not use FQDN when sending SMTP helo).
   (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
 - Upgraded bundled PCRE to version 7.9. (Nuno)

Modified: php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c
===================================================================
--- php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c      2009-09-01 20:12:02 UTC 
(rev 287953)
+++ php/php-src/branches/PHP_5_3/TSRM/tsrm_win32.c      2009-09-01 22:51:31 UTC 
(rev 287954)
@@ -311,6 +311,7 @@
        SECURITY_ATTRIBUTES security;
        HANDLE in, out;
        DWORD dwCreateFlags = 0;
+       BOOL res;
        process_pair *proc;
        char *cmd;
        int i;
@@ -370,12 +371,17 @@
        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);


Modified: php/php-src/trunk/TSRM/tsrm_win32.c
===================================================================
--- php/php-src/trunk/TSRM/tsrm_win32.c 2009-09-01 20:12:02 UTC (rev 287953)
+++ php/php-src/trunk/TSRM/tsrm_win32.c 2009-09-01 22:51:31 UTC (rev 287954)
@@ -312,6 +312,7 @@
        SECURITY_ATTRIBUTES security;
        HANDLE in, out;
        DWORD dwCreateFlags = 0;
+       BOOL res;
        process_pair *proc;
        char *cmd;
        int i;
@@ -353,7 +354,6 @@
        read = (type[0] == 'r') ? TRUE : FALSE;
        mode = ((type_len == 2) && (type[1] == 'b')) ? O_BINARY : O_TEXT;

-
        if (read) {
                in = dupHandle(in, FALSE);
                startup.hStdInput  = GetStdHandle(STD_INPUT_HANDLE);
@@ -372,12 +372,17 @@
        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);


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to