]> granicus.if.org Git - php/commitdiff
Add impersonation feature for running under IIS
authorShane Caraveo <shane@php.net>
Mon, 18 Mar 2002 04:46:32 +0000 (04:46 +0000)
committerShane Caraveo <shane@php.net>
Mon, 18 Mar 2002 04:46:32 +0000 (04:46 +0000)
sapi/fastcgi/fastcgi.c

index 71708446366e18a49e1d93c88a8e26a562c5271c..ccf57eb308f08cfc60dd61a16d7cdbfea12d104e 100644 (file)
@@ -53,6 +53,8 @@
 #include <io.h>
 #include <fcntl.h>
 #include "win32/php_registry.h"
+/* don't want to include fcgios.h, causes conflicts */
+extern int OS_SetImpersonate(void);
 #else
 #include <sys/wait.h>
 #endif
@@ -357,6 +359,8 @@ int main(int argc, char *argv[])
        zend_file_handle file_handle;
        char *s;
        int status;
+#else
+       int impersonate = 0;
 #endif
        char *argv0=NULL;
        char *script_file=NULL;
@@ -461,6 +465,10 @@ int main(int argc, char *argv[])
                }
        }
 
+               /* Initialise FastCGI request structure */
+       FCGX_Init();
+       FCGX_InitRequest( &request, fcgi_fd, 0 );
+
 #ifndef PHP_WIN32
        /* Pre-fork, if required */
        if( getenv( "PHP_FCGI_CHILDREN" )) {
@@ -472,10 +480,6 @@ int main(int argc, char *argv[])
                }
        }
 
-       /* Initialise FastCGI request structure */
-       FCGX_Init();
-       FCGX_InitRequest( &request, fcgi_fd, 0 );
-
        if( children ) {
                int running = 0;
                int i;
@@ -546,6 +550,14 @@ int main(int argc, char *argv[])
 #ifdef DEBUG_FASTCGI
        fprintf( stderr, "Going into accept loop\n" );
 #endif
+#ifdef PHP_WIN32
+       /* attempt to set security impersonation for fastcgi
+          will only happen on NT based OS, others will ignore it. */
+       if (cfg_get_long("fastcgi.impersonate", &impersonate) == FAILURE) {
+               impersonate = 0;
+       }
+       if (impersonate) OS_SetImpersonate();
+#endif
 
        while( FCGX_Accept_r( &request ) >= 0 ) {