]> granicus.if.org Git - php/commitdiff
@- Improved ISAPI module - it should no longer be necessary to set PHP as
authorZeev Suraski <zeev@php.net>
Tue, 15 Feb 2000 23:31:10 +0000 (23:31 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 15 Feb 2000 23:31:10 +0000 (23:31 +0000)
@  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!)

main/SAPI.c
sapi/isapi/php4isapi.c
sapi/servlet/servlet.c

index 0d5c1741162c9056d5f5cb6a2fc2587102ca5a5b..412f4f3abad8e1907ef6934bbb59d6901f6aa21d 100644 (file)
@@ -178,6 +178,7 @@ SAPI_API void sapi_activate(SLS_D)
        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;
@@ -207,6 +208,12 @@ SAPI_API void sapi_deactivate(SLS_D)
        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 80b50cf1d75460da4216d8c921c77f993ab641fc..24e8a96b2aad6fff10e295edf51e59e71362efb4 100644 (file)
@@ -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 @@ static sapi_module_struct sapi_module = {
 };
 
 
+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 @@ BOOL WINAPI GetFilterVersion(PHTTP_FILTER_VERSION pFilterVersion)
 
 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 @@ static void init_request_info(sapi_globals_struct *sapi_globals, LPEXTENSION_CON
                        *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 @@ __declspec(dllexport) BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, L
                        if (sapi_module.startup) {
                                sapi_module.startup(&sapi_module);
                        }
-                       IWasLoaded = 1;
                        break;
                case DLL_THREAD_ATTACH:
                        break;
index e92bb2e33c18254adeb4148171697510e882482d..cc2af401a0855c181c4dd284572d8cc39962ae91 100644 (file)
@@ -387,7 +387,6 @@ JNIEXPORT void JNICALL Java_net_php_servlet_send
        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;