cvs: /php4 SAPI.c /php4/sapi/isapi php4isapi.c /php4/sapi/servlet servlet.c

From: Date: Tue, 15 Feb 2000 23:31:08 +0000
Subject: cvs: /php4 SAPI.c /php4/sapi/isapi php4isapi.c /php4/sapi/servlet servlet.c
Groups: php.version4 
Request: Send a blank email to php-version4+get-10324@lists.php.net to get a copy of this message
zeev Tue Feb 15 15:31:08 2000 EDT Modified files: /php4 SAPI.c /php4/sapi/isapi php4isapi.c /php4/sapi/servlet servlet.c Log: @- Improved ISAPI module - it should no longer be necessary to set PHP as @ an ISAPI filter, only as an ISAPI extension, unless you wish to perform @ authentication using PHP. This didn't yet get enough testing, but it @ should work (Zeev) - Fixed auth_user/auth_password memory leak (I didn't have time to test it under Apache, feedback welcome!) Index: php4/SAPI.c diff -u php4/SAPI.c:1.52 php4/SAPI.c:1.53 --- php4/SAPI.c:1.52 Fri Feb 11 07:59:26 2000 +++ php4/SAPI.c Tue Feb 15 15:31:08 2000 @@ -178,6 +178,7 @@ SG(request_info).post_data = NULL; SG(request_info).current_user = NULL; SG(request_info).current_user_length = 0; + SG(request_info).auth_user = SG(request_info).auth_password = NULL; if (SG(request_info).request_method && !strcmp(SG(request_info).request_method, "HEAD")) { SG(request_info).headers_only = 1; @@ -206,6 +207,12 @@ zend_llist_destroy(&SG(sapi_headers).headers); if (SG(request_info).post_data) { efree(SG(request_info).post_data); + } + if (SG(request_info).auth_user) { + efree(SG(request_info).auth_user); + } + if (SG(request_info).auth_password) { + efree(SG(request_info).auth_password); } if (SG(request_info).current_user) { efree(SG(request_info).current_user); Index: php4/sapi/isapi/php4isapi.c diff -u php4/sapi/isapi/php4isapi.c:1.24 php4/sapi/isapi/php4isapi.c:1.25 --- php4/sapi/isapi/php4isapi.c:1.24 Sun Feb 13 14:17:09 2000 +++ php4/sapi/isapi/php4isapi.c Tue Feb 15 15:31:08 2000 @@ -38,7 +38,7 @@ #define ISAPI_SERVER_VAR_BUF_SIZE 1024 #define ISAPI_POST_DATA_BUF 1024 -int IWasLoaded=0; +static int isapi_globals_id=-1; static char *isapi_server_variables[] = { "ALL_HTTP", @@ -392,8 +392,15 @@ }; +typedef struct _php_isapi_globals { + char *auth_user; + char *auth_password; +} php_isapi_globals; + + BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion) { + isapi_globals_id = ts_allocate_id(sizeof(php_isapi_globals), NULL, NULL); pFilterVersion->dwFilterVersion = HTTP_FILTER_REVISION; strcpy(pFilterVersion->lpszFilterDesc, sapi_module.name); pFilterVersion->dwFlags= (SF_NOTIFY_AUTHENTICATION | SF_NOTIFY_PREPROC_HEADERS); @@ -403,22 +410,22 @@ DWORD WINAPI HttpFilterProc(PHTTP_FILTER_CONTEXT pfc, DWORD notificationType, LPVOID pvNotification) { - SLS_FETCH(); + php_isapi_globals *isapi_globals = ts_resource(isapi_globals_id); switch (notificationType) { case SF_NOTIFY_PREPROC_HEADERS: - SG(request_info).auth_user = NULL; - SG(request_info).auth_password = NULL; + isapi_globals->auth_user = NULL; + isapi_globals->auth_password = NULL; break; case SF_NOTIFY_AUTHENTICATION: { char *auth_user = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszUser; char *auth_password = ((HTTP_FILTER_AUTHENT *) pvNotification)->pszPassword; if (auth_user && auth_user[0]) { - SG(request_info).auth_user = estrdup(auth_user); + isapi_globals->auth_user = estrdup(auth_user); } if (auth_password && auth_password[0]) { - SG(request_info).auth_password = estrdup(auth_password); + isapi_globals->auth_password = estrdup(auth_password); } auth_user[0] = 0; auth_password[0] = 0; @@ -447,6 +454,12 @@ *path_end = '\\'; } } + if (isapi_globals_id!=-1) { /* we have valid ISAPI Filter information */ + php_isapi_globals *isapi_globals = ts_resource(isapi_globals_id); + + SG(request_info).auth_user = isapi_globals->auth_user; + SG(request_info).auth_password = isapi_globals->auth_password; + } } @@ -564,7 +577,6 @@ if (sapi_module.startup) { sapi_module.startup(&sapi_module); } - IWasLoaded = 1; break; case DLL_THREAD_ATTACH: break; Index: php4/sapi/servlet/servlet.c diff -u php4/sapi/servlet/servlet.c:1.18 php4/sapi/servlet/servlet.c:1.19 --- php4/sapi/servlet/servlet.c:1.18 Thu Feb 10 10:44:33 2000 +++ php4/sapi/servlet/servlet.c Tue Feb 15 15:31:08 2000 @@ -387,7 +387,6 @@ FREESTRING(SG(request_info).request_uri); FREESTRING(SG(request_info).path_translated); FREESTRING(SG(request_info).content_type); - FREESTRING(SG(request_info).auth_user); FREESTRING(((servlet_request*)SG(server_context))->cookies); efree(SG(server_context)); SG(server_context)=0;

« previous php.version4 (#10324) next »