dmitry          Thu Apr 19 13:41:37 2007 UTC

  Modified files:              (Branch: PHP_4_4)
    /php-src/sapi/cgi/libfcgi   fcgiapp.c os_win32.c 
  Log:
  Fixed support for IIS FastCGI technical preview
  
  
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/libfcgi/fcgiapp.c?r1=1.1.4.3.2.3&r2=1.1.4.3.2.4&diff_format=u
Index: php-src/sapi/cgi/libfcgi/fcgiapp.c
diff -u php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3.2.3 
php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3.2.4
--- php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3.2.3      Thu Mar  1 07:51:07 2007
+++ php-src/sapi/cgi/libfcgi/fcgiapp.c  Thu Apr 19 13:41:37 2007
@@ -11,7 +11,7 @@
  *
  */
 #ifndef lint
-static const char rcsid[] = "$Id: fcgiapp.c,v 1.1.4.3.2.3 2007/03/01 07:51:07 
dmitry Exp $";
+static const char rcsid[] = "$Id: fcgiapp.c,v 1.1.4.3.2.4 2007/04/19 13:41:37 
dmitry Exp $";
 #endif /* not lint */
 
 #include <assert.h>
@@ -2229,10 +2229,6 @@
             if (reqDataPtr->ipcFd < 0) {
                 return (errno > 0) ? (0 - errno) : -9999;
             }
-#ifdef _WIN32
-               } else if (!OS_StartImpersonation()) {
-                       FCGX_Free(reqDataPtr, 1);
-#endif
         }
         /*
          * A connection is open.  Read from the connection in order to
@@ -2279,6 +2275,16 @@
         FCGX_Free(reqDataPtr, 1);
 
     } /* for (;;) */
+
+#ifdef _WIN32
+    /*
+     * impersonate the client
+     */
+       if (!OS_StartImpersonation()) {
+               goto TryAgain;
+       }
+#endif
+
     /*
      * Build the remaining data structures representing the new
      * request and return successfully to the caller.
http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/libfcgi/os_win32.c?r1=1.6.2.1.4.3&r2=1.6.2.1.4.4&diff_format=u
Index: php-src/sapi/cgi/libfcgi/os_win32.c
diff -u php-src/sapi/cgi/libfcgi/os_win32.c:1.6.2.1.4.3 
php-src/sapi/cgi/libfcgi/os_win32.c:1.6.2.1.4.4
--- php-src/sapi/cgi/libfcgi/os_win32.c:1.6.2.1.4.3     Thu Mar  1 07:51:07 2007
+++ php-src/sapi/cgi/libfcgi/os_win32.c Thu Apr 19 13:41:37 2007
@@ -17,7 +17,7 @@
  *  significantly more enjoyable.)
  */
 #ifndef lint
-static const char rcsid[] = "$Id: os_win32.c,v 1.6.2.1.4.3 2007/03/01 07:51:07 
dmitry Exp $";
+static const char rcsid[] = "$Id: os_win32.c,v 1.6.2.1.4.4 2007/04/19 13:41:37 
dmitry Exp $";
 #endif /* not lint */
 
 #define WIN32_LEAN_AND_MEAN 
@@ -60,6 +60,7 @@
 static BOOLEAN shutdownNow = FALSE;
 
 static BOOLEAN bImpersonate = FALSE;
+static BOOLEAN bImpersonated = FALSE;
 /*
  * An enumeration of the file types
  * supported by the FD_TABLE structure.
@@ -308,14 +309,25 @@
 
 int OS_StartImpersonation(void)
 {
-       return (!bImpersonate ||
-               ((hListen != INVALID_HANDLE_VALUE) && 
-                !ImpersonateNamedPipeClient(hListen)));
+       if (!bImpersonate) {
+               return 1;
+       } else if (hListen == INVALID_HANDLE_VALUE) {
+               return 1;
+       } else {
+               if (ImpersonateNamedPipeClient(hListen)) {
+                       bImpersonated = TRUE;
+                       return 1;
+               }
+       }
+       return 0;
 }
 
 void OS_StopImpersonation(void)
 {
-       if (bImpersonate) RevertToSelf();
+       if (bImpersonated) {
+               bImpersonated = FALSE;
+               RevertToSelf();
+       }
 }
 
 /*
@@ -1772,18 +1784,10 @@
         }
     }
 
-    //
-    // impersonate the client
-    //
-    if(bImpersonate && OS_StartImpersonation()) {
-        DisconnectNamedPipe(hListen);
-    } else {
-               ipcFd = Win32NewDescriptor(FD_PIPE_SYNC, (int) hListen, -1);
-               if (ipcFd == -1) 
-               {
-                       DisconnectNamedPipe(hListen);
-                       OS_StopImpersonation();
-               }
+       ipcFd = Win32NewDescriptor(FD_PIPE_SYNC, (int) hListen, -1);
+       if (ipcFd == -1) 
+       {
+               DisconnectNamedPipe(hListen);
        }
 
     return ipcFd;

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

Reply via email to