Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 88318 invoked by uid 500); 14 Jun 2001 14:36:09 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: tomcat-dev@jakarta.apache.org Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 88304 invoked by uid 500); 14 Jun 2001 14:36:09 -0000 Delivered-To: apmail-jakarta-tomcat-connectors-cvs@apache.org Date: 14 Jun 2001 14:36:08 -0000 Message-ID: <20010614143608.88293.qmail@apache.org> From: andya@apache.org To: jakarta-tomcat-connectors-cvs@apache.org Subject: cvs commit: jakarta-tomcat-connectors/jk/native/domino jk_dsapi_plugin.c HISTORY config.h andya 01/06/14 07:36:08 Modified: jk/native/domino jk_dsapi_plugin.c HISTORY config.h Log: Better SSL support, better ajp14 support Revision Changes Path 1.6 +188 -146 jakarta-tomcat-connectors/jk/native/domino/jk_dsapi_plugin.c Index: jk_dsapi_plugin.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/domino/jk_dsapi_plugin.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- jk_dsapi_plugin.c 2001/06/13 21:26:43 1.5 +++ jk_dsapi_plugin.c 2001/06/14 14:36:08 1.6 @@ -56,7 +56,7 @@ /*************************************************************************** * Description: DSAPI plugin for Lotus Domino * * Author: Andy Armstrong * - * Version: $Revision: 1.5 $ * + * Version: $Revision: 1.6 $ * ***************************************************************************/ /* Based on the IIS redirector by Gal Shachor */ @@ -95,10 +95,11 @@ #endif #endif -#define VERSION "1.0.2" +#define VERSION "1.0.3" #define VERSION_STRING "Jakarta/DSAPI/" VERSION /* What we call ourselves */ -#define FILTERDESC "Apache Tomcat Interceptor (" VERSION_STRING ")" +#define FILTERDESC "Apache Tomcat Interceptor (" VERSION_STRING ")" +#define SERVERDFLT "Lotus Domino" /* Registry location of configuration data */ #define REGISTRY_LOCATION "Software\\Apache Software Foundation\\Jakarta Dsapi Redirector\\1.0" /* Name of INI file relative to whatever the 'current' directory is when the filter is @@ -117,15 +118,17 @@ static jk_logger_t *logger = NULL; static int logLevel = JK_LOG_EMERG_LEVEL; -static jk_pool_t cfgPool; - +static jk_pool_t cfgPool; + static const char *logFile; static const char *workerFile; static const char *workerMountFile; static const char *tomcatStart; static const char *tomcatStop; - -static jk_worker_env_t worker_env; + +#if FOR_TOMCAT >= TOMCAT400 +static jk_worker_env_t worker_env; +#endif static char *crlf = "\r\n"; @@ -255,6 +258,72 @@ printf("\n"); } #endif + +/* Get the value of a server (CGI) variable as a string + */ +static int GetVariable(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, char **dest, const char *dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + *dest = jk_pool_strdup(&ws->p, buf); + else + *dest = jk_pool_strdup(&ws->p, dflt); + + DEBUG(("%s = %s\n", hdrName, *dest)); + + return JK_TRUE; +} + +/* Get the value of a server (CGI) variable as an integer + */ +static int GetVariableInt(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, int *dest, int dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + *dest = atoi(buf); + else + *dest = dflt; + + DEBUG(("%s = %d\n", hdrName, *dest)); + + return JK_TRUE; +} +/* Get the value of a server (CGI) variable as an integer + */ +static int GetVariableBool(private_ws_t *ws, char *hdrName, + char *buf, DWORD bufsz, int *dest, int dflt) +{ + int errID; + + if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) + { + if (isdigit(buf[0])) + *dest = atoi(buf) != 0; + else if (NoCaseStrCmp(buf, "yes") == 0 || NoCaseStrCmp(buf, "on") == 0) + *dest = 1; + else + *dest = 0; + } + else + { + *dest = dflt; + } + + DEBUG(("%s = %d\n", hdrName, *dest)); + + return JK_TRUE; +} + +/* A couple of utility macros to supply standard arguments to GetVariable() and + * GetVariableInt(). + */ +#define GETVARIABLE(name, dest, dflt) GetVariable(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) +#define GETVARIABLEINT(name, dest, dflt) GetVariableInt(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) +#define GETVARIABLEBOOL(name, dest, dflt) GetVariableBool(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) /* Return 1 iff the supplied string contains "web-inf" (in any case * variation. We don't allow URIs containing web-inf, although @@ -467,12 +536,12 @@ { if (initDone) { - initDone = JK_FALSE; - uri_worker_map_free(&uw_map, logger); wc_close(logger); if (logger) jk_close_file_logger(&logger); + + initDone = JK_FALSE; } if (NULL != tomcatStop && '\0' != *tomcatStop) @@ -487,14 +556,12 @@ return kFilterHandledEvent; } - + /* Called when Domino loads the filter. Reads a load of config data from * the registry and elsewhere and displays a banner. */ -DLLEXPORT unsigned int FilterInit(FilterInitData * filterInitData) +DLLEXPORT unsigned int FilterInit(FilterInitData *filterInitData) { - int rc = JK_FALSE; - jk_map_t *map = NULL; jk_open_pool(&cfgPool, NULL, 0); /* empty pool for config data */ @@ -510,36 +577,6 @@ RunProg(tomcatStart); } - if (map_alloc(&map)) - { - if (map_read_properties(map, workerMountFile)) - if (uri_worker_map_alloc(&uw_map, map, logger)) - rc = JK_TRUE; - - map_free(&map); - } - - if (!rc) goto initFailed; - - rc = JK_FALSE; - if (map_alloc(&map)) - { - if (map_read_properties(map, workerFile)) -#if 0 - /* we add the URI->WORKER MAP since workers using AJP14 will feed it */ - worker_env.uri_to_worker = &uw_map; - GETVARIABLE("SERVER_SOFTWARE", &worker_env.server_name, "Lotus Domino"); -#endif - if (wc_open(map, &worker_env, logger)) - rc = JK_TRUE; - - map_free(&map); - } - - if (!rc) goto initFailed; - - initDone = JK_TRUE; - filterInitData->appFilterVersion = kInterfaceVersion; filterInitData->eventFlags = kFilterParsedRequest; strcpy(filterInitData->filterDesc, FILTERDESC); @@ -639,15 +676,12 @@ */ DLLEXPORT unsigned int HttpFilterProc(FilterContext *context, unsigned int eventType, void *eventData) { - if (initDone) + switch (eventType) { - switch (eventType) - { - case kFilterParsedRequest: - return ParsedRequest(context, (FilterParsedRequest *) eventData); - default: - break; - } + case kFilterParsedRequest: + return ParsedRequest(context, (FilterParsedRequest *) eventData); + default: + break; } return kFilterNotHandled; } @@ -683,65 +717,6 @@ return kFilterHandledRequest; } -/* Get the value of a server (CGI) variable as a string - */ -static int GetVariable(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, char **dest, const char *dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - *dest = jk_pool_strdup(&ws->p, buf); - else - *dest = jk_pool_strdup(&ws->p, dflt); - - DEBUG(("%s = %s\n", hdrName, *dest)); - - return JK_TRUE; -} - -/* Get the value of a server (CGI) variable as an integer - */ -static int GetVariableInt(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, int *dest, int dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - *dest = atoi(buf); - else - *dest = dflt; - - DEBUG(("%s = %d\n", hdrName, *dest)); - - return JK_TRUE; -} -/* Get the value of a server (CGI) variable as an integer - */ -static int GetVariableBool(private_ws_t *ws, char *hdrName, - char *buf, DWORD bufsz, int *dest, int dflt) -{ - int errID; - - if (ws->context->GetServerVariable(ws->context, hdrName, buf, bufsz, &errID)) - { - if (isdigit(buf[0])) - *dest = atoi(buf) != 0; - else if (NoCaseStrCmp(buf, "yes") == 0 || NoCaseStrCmp(buf, "on") == 0) - *dest = 1; - else - *dest = 0; - } - else - { - *dest = dflt; - } - - DEBUG(("%s = %d\n", hdrName, *dest)); - - return JK_TRUE; -} - /* Allocate space for a string given a start pointer and an end pointer * and return a pointer to the allocated, copied string. */ @@ -814,13 +789,6 @@ return hdrCount; } -/* A couple of utility macros to supply standard arguments to GetVariable() and - * GetVariableInt(). - */ -#define GETVARIABLE(name, dest, dflt) GetVariable(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) -#define GETVARIABLEINT(name, dest, dflt) GetVariableInt(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) -#define GETVARIABLEBOOL(name, dest, dflt) GetVariableBool(ws, (name), workBuf, sizeof(workBuf), (dest), (dflt)) - /* Set up all the necessary jk_* workspace based on the current HTTP request. */ static int InitService(private_ws_t *ws, jk_ws_service_t *s) @@ -864,35 +832,37 @@ GETVARIABLE("REMOTE_ADDR", &s->remote_addr, ""); GETVARIABLE("SERVER_NAME", &s->server_name, ""); GETVARIABLEINT("SERVER_PORT", &s->server_port, 80); - GETVARIABLE("SERVER_SOFTWARE", &s->server_software, "Lotus Domino"); + GETVARIABLE("SERVER_SOFTWARE", &s->server_software, SERVERDFLT); GETVARIABLEINT("CONTENT_LENGTH", &s->content_length, 0); - + + /* SSL Support */ GETVARIABLEBOOL("HTTPS", &s->is_ssl, 0); + + if (ws->reqData->requestMethod < 0 || + ws->reqData->requestMethod >= sizeof(methodName) / sizeof(methodName[0])) + return JK_FALSE; + + s->method = methodName[ws->reqData->requestMethod]; + + s->headers_names = NULL; + s->headers_values = NULL; + s->num_headers = 0; s->ssl_cert_len = fr.clientCertLen; s->ssl_cert = fr.clientCert; s->ssl_cipher = NULL; /* required by Servlet 2.3 Api */ s->ssl_session = NULL; - s->ssl_key_size = -1; /* required by Servlet 2.3 Api, added in jtc */ - - if (ws->reqData->requestMethod < 0 || - ws->reqData->requestMethod >= sizeof(methodName) / sizeof(methodName[0])) - return JK_FALSE; - - s->method = methodName[ws->reqData->requestMethod]; - - s->headers_names = NULL; - s->headers_values = NULL; - s->num_headers = 0; - - /* There's no point in doing this because Domino never seems to - * set any of these CGI variables. - */ + +#if FOR_TOMCAT >= TOMCAT400 + s->ssl_key_size = -1; /* required by Servlet 2.3 Api, added in jtc */ +#endif + + if (s->is_ssl) + { + int dummy; #if 0 - if (s->is_ssl) - { char *sslNames[] = { "CERT_ISSUER", "CERT_SUBJECT", "CERT_COOKIE", "CERT_FLAGS", "CERT_SERIALNUMBER", @@ -904,25 +874,38 @@ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; + unsigned i, varCount = 0; +#endif DEBUG(("SSL request\n")); - + +#if FOR_TOMCAT >= TOMCAT400 + /* Read the variable into a dummy variable: we do this for the side effect of + * reading it into workBuf. + */ + GETVARIABLEINT("HTTPS_KEYSIZE", &dummy, 0); + if (workBuf[0] == '[') + s->ssl_key_size = atoi(workBuf+1); +#else + (void) dummy; +#endif + +#if 0 for (i = 0; i < sizeof(sslNames)/sizeof(sslNames[0]); i++) { GETVARIABLE(sslNames[i], &sslValues[i], NULL); if (sslValues[i]) varCount++; } - /* Andy, some SSL vars must be mapped directly in s->ssl_cipher, - * ssl-session and s->ssl_key_size - * ie: - * Cipher could be "RC4-MD5" - * KeySize 128 (bits) - * SessionID a string containing the UniqID used in SSL dialogue - */ - + /* Andy, some SSL vars must be mapped directly in s->ssl_cipher, + * ssl->session and s->ssl_key_size + * ie: + * Cipher could be "RC4-MD5" + * KeySize 128 (bits) + * SessionID a string containing the UniqID used in SSL dialogue + */ if (varCount > 0) { unsigned j; @@ -942,8 +925,8 @@ } s->num_attributes = varCount; } - } #endif + } /* Duplicate all the headers now */ @@ -980,6 +963,65 @@ { char *uri = fr.URL; char *workerName, *qp; + + if (!initDone) + { + /* One time initialisation which is deferred so that we have the name of + * the server software to plug into worker_env + */ + int ok = JK_FALSE; + jk_map_t *map = NULL; + + DEBUG(("Initialising worker map\n")); + + if (map_alloc(&map)) + { + if (map_read_properties(map, workerMountFile)) + if (uri_worker_map_alloc(&uw_map, map, logger)) + ok = JK_TRUE; + map_free(&map); + } + + DEBUG(("Got the URI worker map\n")); + + if (ok) + { + ok = JK_FALSE; + DEBUG(("About to allocate map\n")); + if (map_alloc(&map)) + { + DEBUG(("About to read %s\n", workerFile)); + if (map_read_properties(map, workerFile)) + { +#if FOR_TOMCAT >= TOMCAT400 + char server[256]; + + worker_env.uri_to_worker = uw_map; + if (context->GetServerVariable(context, "SERVER_SOFTWARE", server, sizeof(server)-1, &errID)) + worker_env.server_name = jk_pool_strdup(&cfgPool, server); + else + worker_env.server_name = SERVERDFLT; + + DEBUG(("Server name %s\n", worker_env.server_name)); + + if (wc_open(map, &worker_env, logger)) + ok = JK_TRUE; +#else + if (wc_open(map, logger)) + ok = JK_TRUE; +#endif + DEBUG(("OK = %d\n", ok)); + } + + DEBUG(("Read %s, OK = %d\n", workerFile, ok)); + map_free(&map); + } + } + + if (!ok) return kFilterError; + initDone = JK_TRUE; + } + if (qp = strchr(uri, '?'), qp != NULL) *qp = '\0'; workerName = map_uri_to_worker(uw_map, uri, logger); 1.2 +4 -0 jakarta-tomcat-connectors/jk/native/domino/HISTORY Index: HISTORY =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/domino/HISTORY,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- HISTORY 2001/06/08 15:06:39 1.1 +++ HISTORY 2001/06/14 14:36:08 1.2 @@ -1,3 +1,10 @@ +$Log: HISTORY,v $ +Revision 1.2 2001/06/14 14:36:08 andya +Better SSL support, better ajp14 support + + +--- pre cvs log --- + 20010608 1.0.2 AA Banished malloc()/free() in favour of jk_pool based memory allocation for configuration data. Added syntax checking and test harness to inifile code. 1.3 +8 -2 jakarta-tomcat-connectors/jk/native/domino/config.h Index: config.h =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/domino/config.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- config.h 2001/06/04 13:16:08 1.2 +++ config.h 2001/06/14 14:36:08 1.3 @@ -56,12 +56,18 @@ /*************************************************************************** * Description: DSAPI plugin for Lotus Domino * * Author: Andy Armstrong * - * Version: $Revision: 1.2 $ * + * Version: $Revision: 1.3 $ * ***************************************************************************/ #ifndef __config_h #define __config_h +#define TOMCAT320 320 +#define TOMCAT330 330 +#define TOMCAT400 400 + +#define FOR_TOMCAT TOMCAT400 + /* the _memicmp() function is available */ #if defined(WIN32) @@ -84,6 +90,6 @@ /* #undef NO_CAPI */ #define DEBUG(args) \ - do { /*printf args ;*/ } while (0) + do { printf args ; } while (0) #endif /* __config_h */