On Tue, 27 Feb 2007, Dmitry Stogov wrote:

> dmitry                Tue Feb 27 11:05:56 2007 UTC
> 
>   Modified files:              (Branch: PHP_4_4)
>     /php-src/sapi/cgi/libfcgi fcgiapp.c os_win32.c 
>     /php-src/sapi/cgi/libfcgi/include fcgios.h 
>   Log:
>   Backport: Fixed impersonation support for persistent FastCGI connections.

Could you please back this out until after 4.4.6 has been released?

regards,
Derick

> http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/libfcgi/fcgiapp.c?r1=1.1.4.3&r2=1.1.4.3.2.1&diff_format=u
> Index: php-src/sapi/cgi/libfcgi/fcgiapp.c
> diff -u php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3 
> php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3.2.1
> --- php-src/sapi/cgi/libfcgi/fcgiapp.c:1.1.4.3        Fri Apr 22 09:21:48 2005
> +++ php-src/sapi/cgi/libfcgi/fcgiapp.c        Tue Feb 27 11:05:56 2007
> @@ -11,7 +11,7 @@
>   *
>   */
>  #ifndef lint
> -static const char rcsid[] = "$Id: fcgiapp.c,v 1.1.4.3 2005/04/22 09:21:48 
> tony2001 Exp $";
> +static const char rcsid[] = "$Id: fcgiapp.c,v 1.1.4.3.2.1 2007/02/27 
> 11:05:56 dmitry Exp $";
>  #endif /* not lint */
>  
>  #include <assert.h>
> @@ -2061,6 +2061,10 @@
>          OS_IpcClose(request->ipcFd, ! request->detached);
>          request->ipcFd = -1;
>          request->detached = 0;
> +#ifdef _WIN32
> +    } else {
> +        OS_StopImpersonation();
> +#endif
>      }
>  }
>  
> @@ -2225,6 +2229,10 @@
>              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
> http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/libfcgi/os_win32.c?r1=1.6.2.1&r2=1.6.2.1.4.1&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 
> php-src/sapi/cgi/libfcgi/os_win32.c:1.6.2.1.4.1
> --- php-src/sapi/cgi/libfcgi/os_win32.c:1.6.2.1       Sun Sep 21 22:08:16 2003
> +++ php-src/sapi/cgi/libfcgi/os_win32.c       Tue Feb 27 11:05:56 2007
> @@ -17,7 +17,7 @@
>   *  significantly more enjoyable.)
>   */
>  #ifndef lint
> -static const char rcsid[] = "$Id: os_win32.c,v 1.6.2.1 2003/09/21 22:08:16 
> sas Exp $";
> +static const char rcsid[] = "$Id: os_win32.c,v 1.6.2.1.4.1 2007/02/27 
> 11:05:56 dmitry Exp $";
>  #endif /* not lint */
>  
>  #define WIN32_LEAN_AND_MEAN 
> @@ -306,6 +306,18 @@
>       return 0;
>  }
>  
> +int OS_StartImpersonation(void)
> +{
> +     return (!bImpersonate ||
> +             ((hListen != INVALID_HANDLE_VALUE) && 
> +              !ImpersonateNamedPipeClient(hListen)));
> +}
> +
> +void OS_StopImpersonation(void)
> +{
> +     if (bImpersonate) RevertToSelf();
> +}
> +
>  /*
>   *--------------------------------------------------------------
>   *
> @@ -596,7 +608,7 @@
>      if (stdioHandles[0] != INVALID_HANDLE_VALUE) {
>               DisconnectNamedPipe(hListen);
>               CancelIo(hListen);
> -             if (bImpersonate) RevertToSelf();
> +             OS_StopImpersonation();
>       }
>  
>      WSACleanup();
> @@ -1763,14 +1775,14 @@
>      //
>      // impersonate the client
>      //
> -    if(bImpersonate && !ImpersonateNamedPipeClient(hListen)) {
> +    if(bImpersonate && OS_StartImpersonation()) {
>          DisconnectNamedPipe(hListen);
>      } else {
>               ipcFd = Win32NewDescriptor(FD_PIPE_SYNC, (int) hListen, -1);
>               if (ipcFd == -1) 
>               {
>                       DisconnectNamedPipe(hListen);
> -                     if (bImpersonate) RevertToSelf();
> +                     OS_StopImpersonation();
>               }
>       }
>  
> @@ -1975,7 +1987,7 @@
>  
>          if (! DisconnectNamedPipe(fdTable[ipcFd].fid.fileHandle)) return -1;
>  
> -        if (bImpersonate) RevertToSelf();
> +             OS_StopImpersonation();
>  
>          /* fall through */
>      case FD_SOCKET_SYNC:
> @@ -2049,4 +2061,3 @@
>      }
>      return;
>  }
> -
> http://cvs.php.net/viewvc.cgi/php-src/sapi/cgi/libfcgi/include/fcgios.h?r1=1.2.4.2&r2=1.2.4.2.4.1&diff_format=u
> Index: php-src/sapi/cgi/libfcgi/include/fcgios.h
> diff -u php-src/sapi/cgi/libfcgi/include/fcgios.h:1.2.4.2 
> php-src/sapi/cgi/libfcgi/include/fcgios.h:1.2.4.2.4.1
> --- php-src/sapi/cgi/libfcgi/include/fcgios.h:1.2.4.2 Sun Sep 21 22:08:17 2003
> +++ php-src/sapi/cgi/libfcgi/include/fcgios.h Tue Feb 27 11:05:56 2007
> @@ -129,6 +129,8 @@
>  
>  #ifdef _WIN32
>  DLLAPI int OS_SetImpersonate(void);
> +int OS_StartImpersonation(void);
> +void OS_StopImpersonation(void);
>  #endif
>  
>  #if defined (__cplusplus) || defined (c_plusplus)
> 
> 

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

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

Reply via email to