From b84c61f314ea568feb9f9a3f83475e75c57d0e9b Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Mon, 18 Mar 2002 04:46:32 +0000 Subject: [PATCH] Add impersonation feature for running under IIS --- sapi/fastcgi/fastcgi.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/sapi/fastcgi/fastcgi.c b/sapi/fastcgi/fastcgi.c index 7170844636..ccf57eb308 100644 --- a/sapi/fastcgi/fastcgi.c +++ b/sapi/fastcgi/fastcgi.c @@ -53,6 +53,8 @@ #include #include #include "win32/php_registry.h" +/* don't want to include fcgios.h, causes conflicts */ +extern int OS_SetImpersonate(void); #else #include #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 ) { -- 2.50.1