cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2002-02-06 Thread larryi

larryi  02/02/06 19:55:37

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Update to use the official JK version string
  
  Revision  ChangesPath
  1.13  +2 -2  jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_isapi_plugin.c 13 Jan 2002 01:50:39 -  1.12
  +++ jk_isapi_plugin.c 7 Feb 2002 03:55:37 -   1.13
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.12 $   *
  + * Version: $Revision: 1.13 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -76,7 +76,7 @@
   #include jk_ajp12_worker.h
   #include jk_uri_worker_map.h
   
  -#define VERSION_STRING Jakarta/ISAPI/1.0b1
  +#define VERSION_STRING Jakarta/ISAPI/ JK_VERSTRING
   
   /*
* We use special two headers to pass values from the filter to the 
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2002-01-12 Thread larryi

larryi  02/01/12 17:50:39

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Add a uri_select parameter to the configuration settings that controls
  the URL forwarded to Tomcat.  It accepts valid values of parsed,
  unparsed, and escaped.  These values forward to Tomcat the
  normalized/decoded URL, the original URL, or a normalized/decoded
  re-encoded URL, respectively. This makes it possible for this isapi plugin
  to work correctly with Tomcat 3.2.x, which expects an encoded URL.
  
  The re-encode routine was borrowed from Apache 1.3 source.
  
  Fixed some tabs.
  
  Revision  ChangesPath
  1.12  +199 -64   jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- jk_isapi_plugin.c 5 Jan 2002 04:25:20 -   1.11
  +++ jk_isapi_plugin.c 13 Jan 2002 01:50:39 -  1.12
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.11 $   *
  + * Version: $Revision: 1.12 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -98,6 +98,12 @@
   #define REGISTRY_LOCATION   (Software\\Apache Software Foundation\\Jakarta 
Isapi Redirector\\1.0)
   #define EXTENSION_URI_TAG   (extension_uri)
   
  +#define URI_SELECT_TAG  (uri_select)
  +
  +#define URI_SELECT_PARSED_VERB  (parsed)
  +#define URI_SELECT_UNPARSED_VERB(unparsed)
  +#define URI_SELECT_ESCAPED_VERB (escaped)
  +
   #define BAD_REQUEST  -1
   #define BAD_PATH -2
   
  @@ -141,6 +147,12 @@
   static char worker_file[MAX_PATH * 2];
   static char worker_mount_file[MAX_PATH * 2];
   
  +#define URI_SELECT_OPT_PARSED   0
  +#define URI_SELECT_OPT_UNPARSED 1
  +#define URI_SELECT_OPT_ESCAPED  2
  +
  +static int uri_select_option = URI_SELECT_OPT_PARSED;
  +
   struct isapi_private_data {
   jk_pool_t p;
   
  @@ -296,6 +308,63 @@
   }
   }
   
  +/* Apache code to escape a URL */
  +
  +#define T_OS_ESCAPE_PATH (4)
  +
  +static const unsigned char test_char_table[256] = {
  +0,14,14,14,14,14,14,14,14,14,15,14,14,14,14,14,14,14,14,14,
  +14,14,14,14,14,14,14,14,14,14,14,14,14,0,7,6,1,6,1,1,
  +9,9,1,0,8,0,0,10,0,0,0,0,0,0,0,0,0,0,8,15,
  +15,8,15,15,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  +0,0,0,0,0,0,0,0,0,0,0,15,15,15,7,0,7,0,0,0,
  +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  +0,0,0,15,7,15,1,14,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  +6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6 
  +};
  +
  +#define TEST_CHAR(c, f)  (test_char_table[(unsigned)(c)]  (f))
  +
  +static const char c2x_table[] = 0123456789abcdef;
  +
  +static unsigned char *c2x(unsigned what, unsigned char *where)
  +{
  +*where++ = '%';
  +*where++ = c2x_table[what  4];
  +*where++ = c2x_table[what  0xf];
  +return where;
  +}
  +
  +static int escape_url(const char *path, char *dest, int destsize)
  +{
  +const unsigned char *s = (const unsigned char *)path;
  +unsigned char *d = (unsigned char *)dest;
  +unsigned char *e = dest + destsize - 1;
  +unsigned char *ee = dest + destsize - 3;
  +unsigned c;
  +
  +while ((c = *s)) {
  + if (TEST_CHAR(c, T_OS_ESCAPE_PATH)) {
  +if (d = ee )
  +return JK_FALSE;
  + d = c2x(c, d);
  + }
  + else {
  +if (d = e )
  +return JK_FALSE;
  + *d++ = c;
  + }
  + ++s;
  +}
  +*d = '\0';
  +return JK_TRUE;
  +}
  +
   static int uri_is_web_inf(char *uri)
   {
   char *c = uri;
  @@ -613,13 +682,40 @@
   }
   
   if(worker) {
  +char *forwardURI;
  +
   /* This is a servlet, should redirect ... */
   jk_log(logger, JK_LOG_DEBUG, 
  HttpFilterProc [%s] is a servlet url - should redirect to 
%s\n, 
  uri, worker);
   
  +/* get URI we should forward */
  +if (uri_select_option == URI_SELECT_OPT_UNPARSED) {
  +/* get original unparsed URI */
  +p-GetHeader(pfc, url, (LPVOID)uri, 

cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2002-01-04 Thread larryi

larryi  02/01/04 20:25:20

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  In HttpFilterProc, the '?' is searched for in an escaped URI.  In
  init_ws_service as part of HttpExtensionProc, the '?' is searched for
  in a URI that has been unescaped.  This isn't guaranteed to find the
  same '?'.  To avoid this, save the query string in it's own tomcat
  header and use that in init_ws_service instead of searching again.
  
  Added some logging if the worker and worker mount files are not found.
  
  Fix some tabs and a typo.
  
  Revision  ChangesPath
  1.11  +22 -29jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- jk_isapi_plugin.c 8 Dec 2001 15:40:59 -   1.10
  +++ jk_isapi_plugin.c 5 Jan 2002 04:25:20 -   1.11
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.10 $   *
  + * Version: $Revision: 1.11 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -87,10 +87,12 @@
*
*/
   #define URI_HEADER_NAME (TOMCATURI:)
  +#define QUERY_HEADER_NAME   (TOMCATQUERY:)
   #define WORKER_HEADER_NAME  (TOMCATWORKER:)
   #define CONTENT_LENGTH  (CONTENT_LENGTH:)
   
   #define HTTP_URI_HEADER_NAME (HTTP_TOMCATURI)
  +#define HTTP_QUERY_HEADER_NAME   (HTTP_TOMCATQUERY)
   #define HTTP_WORKER_HEADER_NAME  (HTTP_TOMCATWORKER)
   
   #define REGISTRY_LOCATION   (Software\\Apache Software Foundation\\Jakarta 
Isapi Redirector\\1.0)
  @@ -545,8 +547,8 @@
  (SF_NOTIFY_PREPROC_HEADERS == dwNotificationType)) { 
   PHTTP_FILTER_PREPROC_HEADERS p = 
(PHTTP_FILTER_PREPROC_HEADERS)pvNotification;
   char uri[INTERNET_MAX_URL_LENGTH];
  - char snuri[INTERNET_MAX_URL_LENGTH]=/;
  - char Host[INTERNET_MAX_URL_LENGTH];
  +char snuri[INTERNET_MAX_URL_LENGTH]=/;
  +char Host[INTERNET_MAX_URL_LENGTH];
   
   char *query;
   DWORD sz = sizeof(uri);
  @@ -559,7 +561,8 @@
* Just in case somebody set these headers in the request!
*/
   p-SetHeader(pfc, URI_HEADER_NAME, NULL);
  - p-SetHeader(pfc, WORKER_HEADER_NAME, NULL);
  +p-SetHeader(pfc, QUERY_HEADER_NAME, NULL);
  +p-SetHeader(pfc, WORKER_HEADER_NAME, NULL);
   
   if(!p-GetHeader(pfc, url, (LPVOID)uri, (LPDWORD)sz)) {
   jk_log(logger, JK_LOG_ERROR, 
  @@ -572,13 +575,13 @@
   char *worker=0;
   query = strchr(uri, '?');
   if(query) {
  -*query = '\0';
  +*query++ = '\0';
   }
   
   rc = unescape_url(uri);
   if (rc == BAD_REQUEST) {
   jk_log(logger, JK_LOG_ERROR, 
  -   HttpFilterProc [%s] contains on or more invalid escape 
sequences.\n, 
  +   HttpFilterProc [%s] contains one or more invalid escape 
sequences.\n, 
  uri);
   write_error_response(pfc,400 Bad Request,
   HTMLBODYH1Request contains invalid 
encoding/H1/BODY/HTML);
  @@ -608,17 +611,6 @@
  uri);
   worker = map_uri_to_worker(uw_map, uri, logger);
   }
  -if(query) {
  -char *querytmp = uri + strlen(uri);
  -*querytmp++ = '?';
  -query++;
  -/* if uri was shortened, move the query characters */
  -if (querytmp != query) {
  -while (*query != '\0')
  -*querytmp++ = *query++;
  -*querytmp = '\0';
  -}
  -}
   
   if(worker) {
   /* This is a servlet, should redirect ... */
  @@ -627,7 +619,9 @@
  uri, worker);
   
   
  - if(!p-AddHeader(pfc, URI_HEADER_NAME, uri) || 
  +if(!p-AddHeader(pfc, URI_HEADER_NAME, uri) || 
  +   ( (query != NULL  strlen(query)  0)
  +   ? !p-AddHeader(pfc, QUERY_HEADER_NAME, query) : FALSE ) 
|| 
  !p-AddHeader(pfc, WORKER_HEADER_NAME, worker) ||
  !p-SetHeader(pfc, url, extension_uri)) {
 

cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-12-08 Thread larryi

larryi  01/12/08 07:40:59

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Fix bug where if uri is shortened by un-escaping or normalizing, the query
  gets lost.
  
  Also converted some tabs to spaces.
  
  Revision  ChangesPath
  1.10  +24 -16jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- jk_isapi_plugin.c 2001/10/01 00:27:11 1.9
  +++ jk_isapi_plugin.c 2001/12/08 15:40:59 1.10
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.9 $   *
  + * Version: $Revision: 1.10 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -594,22 +594,30 @@
   }
   getparents(uri);
   
  - if(p-GetHeader(pfc, Host:, (LPVOID)Host, (LPDWORD)szHost)) 
{
  - strcat(snuri,Host);
  - strcat(snuri,uri);
  - jk_log(logger, JK_LOG_DEBUG, 
  -In HttpFilterProc Virtual Host redirection 
of %s\n, 
  -snuri);
  - worker = map_uri_to_worker(uw_map, snuri, logger); 
   
  - }
  - if (!worker) {
  - jk_log(logger, JK_LOG_DEBUG, 
  -In HttpFilterProc test Default redirection 
of %s\n, 
  -uri);
  - worker = map_uri_to_worker(uw_map, uri, logger);
  - }
  +if(p-GetHeader(pfc, Host:, (LPVOID)Host, (LPDWORD)szHost)) {
  +strcat(snuri,Host);
  +strcat(snuri,uri);
  +jk_log(logger, JK_LOG_DEBUG, 
  +   In HttpFilterProc Virtual Host redirection of %s\n, 
  +   snuri);
  +worker = map_uri_to_worker(uw_map, snuri, logger);
  +}
  +if (!worker) {
  +jk_log(logger, JK_LOG_DEBUG, 
  +   In HttpFilterProc test Default redirection of %s\n, 
  +   uri);
  +worker = map_uri_to_worker(uw_map, uri, logger);
  +}
   if(query) {
  -*query = '?';
  +char *querytmp = uri + strlen(uri);
  +*querytmp++ = '?';
  +query++;
  +/* if uri was shortened, move the query characters */
  +if (querytmp != query) {
  +while (*query != '\0')
  +*querytmp++ = *query++;
  +*querytmp = '\0';
  +}
   }
   
   if(worker) {
  
  
  

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-30 Thread larryi

larryi  01/09/30 17:27:11

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Port Apache routines to decode and normalize the URI from IIS. Also, block
  access to META-INF and refactor the error response handling a little.
  
  Revision  ChangesPath
  1.9   +158 -20   jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- jk_isapi_plugin.c 2001/09/22 21:08:16 1.8
  +++ jk_isapi_plugin.c 2001/10/01 00:27:11 1.9
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.8 $   *
  + * Version: $Revision: 1.9 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -96,6 +96,9 @@
   #define REGISTRY_LOCATION   (Software\\Apache Software Foundation\\Jakarta 
Isapi Redirector\\1.0)
   #define EXTENSION_URI_TAG   (extension_uri)
   
  +#define BAD_REQUEST  -1
  +#define BAD_PATH -2
  +
   #define GET_SERVER_VARIABLE_VALUE(name, place) {\
   (place) = NULL;   \
   huge_buf_sz = sizeof(huge_buf); \
  @@ -189,6 +192,108 @@
 int len);
   
   
  +static char x2c(const char *what)
  +{
  +register char digit;
  +
  +digit = ((what[0] = 'A') ? ((what[0]  0xdf) - 'A') + 10 : (what[0] - '0'));
  +digit *= 16;
  +digit += (what[1] = 'A' ? ((what[1]  0xdf) - 'A') + 10 : (what[1] - '0'));
  +return (digit);
  +}
  +
  +static int unescape_url(char *url)
  +{
  +register int x, y, badesc, badpath;
  +
  +badesc = 0;
  +badpath = 0;
  +for (x = 0, y = 0; url[y]; ++x, ++y) {
  +if (url[y] != '%')
  +url[x] = url[y];
  +else {
  +if (!isxdigit(url[y + 1]) || !isxdigit(url[y + 2])) {
  +badesc = 1;
  +url[x] = '%';
  +}
  +else {
  +url[x] = x2c(url[y + 1]);
  +y += 2;
  +if (url[x] == '/' || url[x] == '\0')
  +badpath = 1;
  +}
  +}
  +}
  +url[x] = '\0';
  +if (badesc)
  +return BAD_REQUEST;
  +else if (badpath)
  +return BAD_PATH;
  +else
  +return 0;
  +}
  +
  +static void getparents(char *name)
  +{
  +int l, w;
  +
  +/* Four paseses, as per RFC 1808 */
  +/* a) remove ./ path segments */
  +
  +for (l = 0, w = 0; name[l] != '\0';) {
  +if (name[l] == '.'  name[l + 1] == '/'  (l == 0 || name[l - 1] == '/'))
  +l += 2;
  +else
  +name[w++] = name[l++];
  +}
  +
  +/* b) remove trailing . path, segment */
  +if (w == 1  name[0] == '.')
  +w--;
  +else if (w  1  name[w - 1] == '.'  name[w - 2] == '/')
  +w--;
  +name[w] = '\0';
  +
  +/* c) remove all xx/../ segments. (including leading ../ and /../) */
  +l = 0;
  +
  +while (name[l] != '\0') {
  +if (name[l] == '.'  name[l + 1] == '.'  name[l + 2] == '/' 
  +(l == 0 || name[l - 1] == '/')) {
  +register int m = l + 3, n;
  +
  +l = l - 2;
  +if (l = 0) {
  +while (l = 0  name[l] != '/')
  +l--;
  +l++;
  +}
  +else
  +l = 0;
  +n = l;
  +while ((name[n] = name[m]))
  +(++n, ++m);
  +}
  +else
  +++l;
  +}
  +
  +/* d) remove trailing xx/.. segment. */
  +if (l == 2  name[0] == '.'  name[1] == '.')
  +name[0] = '\0';
  +else if (l  2  name[l - 1] == '.'  name[l - 2] == '.'  name[l - 3] == 
'/') {
  +l = l - 4;
  +if (l = 0) {
  +while (l = 0  name[l] != '/')
  +l--;
  +l++;
  +}
  +else
  +l = 0;
  +name[l] = '\0';
  +}
  +}
  +
   static int uri_is_web_inf(char *uri)
   {
   char *c = uri;
  @@ -199,10 +304,34 @@
   if(strstr(uri, web-inf)) {
   return JK_TRUE;
   }
  +if(strstr(uri, meta-inf)) {
  +return JK_TRUE;
  +}
   
   return JK_FALSE;
   }
   
  +static void write_error_response(PHTTP_FILTER_CONTEXT pfc,char *status,char * msg)
  +{
  +char crlf[3] = { (char)13, (char)10, '\0' };
  + 

cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-22 Thread larryi

larryi  01/09/22 14:08:16

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Fix bug where the header name isn't set if a request has content-length: 0
  
  Revision  ChangesPath
  1.8   +2 -1  jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jk_isapi_plugin.c 2001/09/21 02:58:16 1.7
  +++ jk_isapi_plugin.c 2001/09/22 21:08:16 1.8
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.7 $   *
  + * Version: $Revision: 1.8 $   *
***/
   
   // This define is needed to include wincrypt,h, needed to get client certificates
  @@ -1011,6 +1011,7 @@
   } else if(need_content_length_header 
  !strnicmp(tmp, CONTENT_LENGTH, strlen(CONTENT_LENGTH))) {
   need_content_length_header = FALSE;
  +s-headers_names[i]  = tmp;
   } else {
   s-headers_names[i]  = tmp;
   }
  
  
  



cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-20 Thread larryi

larryi  01/09/20 19:58:17

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Patch to include the certificate data for ssl requests.
  
  Submitted by: Ignacio J. Ortega
  
  Lifted a Base64 encoder routine from Apache's apr-util and modified it
  to Base64 encode the certificate data since IIS supplies straight Der
  encoded data.
  
  I couldn't find support for SSL PWS on Win9x.  However, isapi_redirect.dll
  on Win9x still works for HTTP requests.
  
  Revision  ChangesPath
  1.7   +107 -2jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_isapi_plugin.c 2001/09/13 01:49:51 1.6
  +++ jk_isapi_plugin.c 2001/09/21 02:58:16 1.7
  @@ -57,9 +57,12 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.6 $   *
  + * Version: $Revision: 1.7 $   *
***/
   
  +// This define is needed to include wincrypt,h, needed to get client certificates
  +#define _WIN32_WINNT 0x0400
  +
   #include httpext.h
   #include httpfilt.h
   #include wininet.h
  @@ -179,6 +182,13 @@
   DWORD bufsz,
   char  *def_val);
   
  +static int base64_encode_cert_len(int len);
  +
  +static int base64_encode_cert(char *encoded,
  +  const unsigned char *string,
  +  int len);
  +
  +
   static int uri_is_web_inf(char *uri)
   {
   char *c = uri;
  @@ -913,6 +923,7 @@
   for(i = 0 ; i  9 ; i++) {
   GET_SERVER_VARIABLE_VALUE(ssl_env_names[i], ssl_env_values[i]);
   if(ssl_env_values[i]) {
  + jk_log(logger, JK_LOG_DEBUG, SSL vars %s:%s.\n, 
ssl_env_names[i], ssl_env_values[i]);
   num_of_vars++;
   }
   }
  @@ -933,6 +944,28 @@
   }
   }
   s-num_attributes = num_of_vars;
  + if (ssl_env_values[4]  ssl_env_values[4][0] == '1') {
  + CERT_CONTEXT_EX cc;
  + DWORD cc_sz = sizeof(cc);
  + cc.cbAllocated = sizeof(huge_buf);
  + cc.CertContext.pbCertEncoded = (BYTE*) huge_buf;
  + cc.CertContext.cbCertEncoded = 0;
  +
  + if 
(private_data-lpEcb-ServerSupportFunction(private_data-lpEcb-ConnID,
  +
  (DWORD)HSE_REQ_GET_CERT_INFO_EX,   
  +
  (LPVOID)cc,NULL,NULL) != FALSE)
  + {
  + jk_log(logger, JK_LOG_DEBUG,Client 
Certificate encoding:%d sz:%d flags:%ld\n,
  + 
cc.CertContext.dwCertEncodingType  X509_ASN_ENCODING ,
  + 
cc.CertContext.cbCertEncoded,
  + cc.dwCertificateFlags);
  +s-ssl_cert=jk_pool_alloc(private_data-p,
  +
base64_encode_cert_len(cc.CertContext.cbCertEncoded));
  +
  +s-ssl_cert_len = base64_encode_cert(s-ssl_cert,
  +huge_buf,cc.CertContext.cbCertEncoded) - 1;
  + }
  + }
   }
   }
   
  @@ -1057,4 +1090,76 @@
   }
   
   return JK_TRUE;
  -}
  \ No newline at end of file
  +}
  +
  +static const char begin_cert [] = 
  + -BEGIN CERTIFICATE-\r\n;
  +
  +static const char end_cert [] = 
  + -END CERTIFICATE-\r\n;
  +
  +static const char basis_64[] =
  +ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/;
  +
  +static int base64_encode_cert_len(int len)
  +{
  + int n = ((len + 2) / 3 * 4) + 1; // base64 encoded size
  + n += (n + 63 / 64) * 2; // add CRLF's
  + n += sizeof(begin_cert) + sizeof(end_cert) - 2;  // add enclosing strings.
  +return n;
  +}
  +
  +static int base64_encode_cert(char *encoded,
  +  const unsigned char *string, int len)
  +{
  +int i,c;
  +char *p;
  + const char *t;
  +
  +p = encoded;
  +
  + t 

cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-12 Thread nacho

nacho   01/09/12 17:07:39

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Virtual server support for IIS
  
  This patch adds some syntax sugar to uriworkermap.properties file format
  to allow fine grained control over redirection of tomcat contexts to IIS
  virtual hosts, allowing a syntax like :
  
  /www.somevirtualhost.com/context/*.jsp=ajp13
  
  in UWM.P file.. in addition to the old one of :
  
  /context/*.jsp=ajp13
  
  The old syntax comprises the mapping for the entire server, that is this
  context are honored in all IIS virtual servers..
  
  The new syntax permits to map a context against a unique virtual server, or a group 
of them..
  
  Revision  ChangesPath
  1.4   +22 -7 jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_isapi_plugin.c 2001/09/02 07:27:27 1.3
  +++ jk_isapi_plugin.c 2001/09/13 00:07:39 1.4
  @@ -56,7 +56,8 @@
   /***
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.3 $   *
  + * Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  + * Version: $Revision: 1.4 $   *
***/
   
   #include httpext.h
  @@ -402,9 +403,13 @@
   if(is_inited 
  (SF_NOTIFY_PREPROC_HEADERS == dwNotificationType)) { 
   PHTTP_FILTER_PREPROC_HEADERS p = 
(PHTTP_FILTER_PREPROC_HEADERS)pvNotification;
  -char uri[INTERNET_MAX_URL_LENGTH]; 
  +char uri[INTERNET_MAX_URL_LENGTH];
  + char snuri[INTERNET_MAX_URL_LENGTH]=/;
  + char Host[INTERNET_MAX_URL_LENGTH];
  +
   char *query;
   DWORD sz = sizeof(uri);
  +DWORD szHost = sizeof(Host);
   
   jk_log(logger, JK_LOG_DEBUG, 
  HttpFilterProc started\n);
  @@ -422,15 +427,25 @@
   }
   
   if(strlen(uri)) {
  -char *worker;
  +char *worker=0;
   query = strchr(uri, '?');
   if(query) {
   *query = '\0';
   }
  -jk_log(logger, JK_LOG_DEBUG, 
  -   In HttpFilterProc test redirection of %s\n, 
  -   uri);
  -worker = map_uri_to_worker(uw_map, uri, logger);
  + if(p-GetHeader(pfc, Host:, (LPVOID)Host, (LPDWORD)szHost)) 
{
  + strcat(snuri,Host);
  + strcat(snuri,uri);
  + jk_log(logger, JK_LOG_DEBUG, 
  +In HttpFilterProc Virtual Host redirection 
of %s\n, 
  +snuri);
  + worker = map_uri_to_worker(uw_map, snuri, logger); 
   
  + }
  + if (!worker) {
  + jk_log(logger, JK_LOG_DEBUG, 
  +In HttpFilterProc test Default redirection 
of %s\n, 
  +uri);
  + worker = map_uri_to_worker(uw_map, uri, logger);
  + }
   if(query) {
   *query = '?';
   }
  
  
  



cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-12 Thread nacho

nacho   01/09/12 18:11:25

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  With this patch the ISAPI redirector can load it's initial config
  from a properties file situated in the same virtual dir where the
  isapi_redirect.dll lies.
  
  This patch allows to have multiple Tomcat instances serving various
  IIS virtual servers be configured in easy way.
  
  1) You install the ISAPI filter DLL in a virtual directory.
  
  2) In the same directory you put a properties file of the same name
 (except for the extension)
 i.e. /jakarta/isapi_redirect.dll and /jakarta/isapi_redirect.properties
  
  3) The ini file is a property file with exactly the same properties
  as used to be put in the registry
i.e.
worker_file=C:\tomcat\conf\workers.properties
worker_mount_file=C:\tomcat\conf\uriworkermap.properties
log_level=error
log_file=C:\tomcat\logs\isapi_redirector.log
extension_uri=/jakarta/isapi_redirect.dll
  
  4) The filter loads this ini file and gets its settings from it.
  
  5) If the filter can't find the ini file it uses the registry (old
   behaviour) == 1 ISAPI per machine.
  
  6) You can then install another filter, with another ini file, and
  not have the two conflict.
  
  Submitted by  Tim Whittington [Tim.Whittington at orion.co.nz]
  
  Revision  ChangesPath
  1.5   +119 -53   jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- jk_isapi_plugin.c 2001/09/13 00:07:39 1.4
  +++ jk_isapi_plugin.c 2001/09/13 01:11:25 1.5
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.4 $   *
  + * Version: $Revision: 1.5 $   *
***/
   
   #include httpext.h
  @@ -121,6 +121,8 @@
   }   \
   }\
   
  +static char ini_file_name[MAX_PATH];
  +static int using_ini_file = JK_FALSE;
   static int   is_inited = JK_FALSE;
   static jk_uri_worker_map_t *uw_map = NULL; 
   static jk_logger_t *logger = NULL; 
  @@ -615,6 +617,10 @@
   LPVOID lpReserved)  // Reserved parameter for future use
   {
   BOOL fReturn = TRUE;
  +char drive[_MAX_DRIVE];
  +char dir[_MAX_DIR];
  +char fname[_MAX_FNAME];
  +char file_name[_MAX_PATH];
   
   switch (ulReason) {
   case DLL_PROCESS_DETACH:
  @@ -627,6 +633,12 @@
   default:
   break;
   } 
  +if (GetModuleFileName( hInst, file_name, sizeof(file_name))) {
  +_splitpath( file_name, drive, dir, fname, NULL );
  +_makepath( ini_file_name, drive, dir, fname, .properties );
  +} else {
  +fReturn = JK_FALSE;
  +}
   
   return fReturn;
   }
  @@ -638,6 +650,19 @@
   if(read_registry_init_data()) {
   jk_map_t *map;
   
  + /* Logging the initialization type: registry or properties file in 
virtual dir
  + */
  + if (using_ini_file) {
  +  jk_log(logger, JK_LOG_DEBUG, Using ini file %s.\n, 
ini_file_name);
  + } else {
  +  jk_log(logger, JK_LOG_DEBUG, Using registry.\n);
  + }
  + jk_log(logger, JK_LOG_DEBUG, Using log file %s.\n, log_file);
  + jk_log(logger, JK_LOG_DEBUG, Using log level %d.\n, log_level);
  + jk_log(logger, JK_LOG_DEBUG, Using extension uri %s.\n, 
extension_uri);
  + jk_log(logger, JK_LOG_DEBUG, Using worker file %s.\n, worker_file);
  + jk_log(logger, JK_LOG_DEBUG, Using worker mount file %s.\n, 
worker_mount_file);
  +
   if(!jk_open_file_logger(logger, log_file, log_level)) {
   logger = NULL;
   }
  @@ -677,62 +702,103 @@
   HKEY hkey;
   long rc;
   int  ok = JK_TRUE;
  -rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  -  REGISTRY_LOCATION,
  -  (DWORD)0, 
  -  KEY_READ, 
  -  hkey);
  -if(ERROR_SUCCESS != rc) {
  -return JK_FALSE;
  -} 
  +char *tmp;
  +jk_map_t *map;
   
  -if(get_registry_config_parameter(hkey,
  - JK_LOG_FILE_TAG, 
  - tmpbuf,
  - sizeof(log_file))) {
  -strcpy(log_file, tmpbuf);
  -} else {
  -ok = 

cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-12 Thread nacho

nacho   01/09/12 18:49:52

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Oops , logging before the opening of the log file is not a good idea :)
  
  Thanks to Tim Whittington
  
  Revision  ChangesPath
  1.6   +5 -4  jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_isapi_plugin.c 2001/09/13 01:11:25 1.5
  +++ jk_isapi_plugin.c 2001/09/13 01:49:51 1.6
  @@ -57,7 +57,7 @@
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
* Author:  Ignacio J. Ortega [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.5 $   *
  + * Version: $Revision: 1.6 $   *
***/
   
   #include httpext.h
  @@ -650,6 +650,10 @@
   if(read_registry_init_data()) {
   jk_map_t *map;
   
  +if(!jk_open_file_logger(logger, log_file, log_level)) {
  +logger = NULL;
  +}
  +
/* Logging the initialization type: registry or properties file in 
virtual dir
*/
if (using_ini_file) {
  @@ -663,9 +667,6 @@
jk_log(logger, JK_LOG_DEBUG, Using worker file %s.\n, worker_file);
jk_log(logger, JK_LOG_DEBUG, Using worker mount file %s.\n, 
worker_mount_file);
   
  -if(!jk_open_file_logger(logger, log_file, log_level)) {
  -logger = NULL;
  -}
   
   if(map_alloc(map)) {
   if(map_read_properties(map, worker_mount_file)) {
  
  
  



cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2001-09-02 Thread larryi

larryi  01/09/02 00:27:27

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Update to work with recent changes in Ajp13.java.  The absence of
  a content-length header is interpreted to mean an unknown, but non-zero
  length. For a zero length body, a content-length header saying so is now
  required.
  
  The init_ws_service() method now adds a content-length header if not
  present and the length is zero.
  
  Revision  ChangesPath
  1.3   +18 -3 jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- jk_isapi_plugin.c 2000/12/11 21:17:47 1.2
  +++ jk_isapi_plugin.c 2001/09/02 07:27:27 1.3
  @@ -56,7 +56,7 @@
   /***
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.2 $   *
  + * Version: $Revision: 1.3 $   *
***/
   
   #include httpext.h
  @@ -84,6 +84,7 @@
*/
   #define URI_HEADER_NAME (TOMCATURI:)
   #define WORKER_HEADER_NAME  (TOMCATWORKER:)
  +#define CONTENT_LENGTH  (CONTENT_LENGTH:)
   
   #define HTTP_URI_HEADER_NAME (HTTP_TOMCATURI)
   #define HTTP_WORKER_HEADER_NAME  (HTTP_TOMCATWORKER)
  @@ -872,10 +873,12 @@
   char *headers_buf = jk_pool_strdup(private_data-p, huge_buf);
   unsigned i;
   unsigned len_of_http_prefix = strlen(HTTP_);
  +BOOL need_content_length_header = (s-content_length == 0);
   
   cnt -= 2; /* For our two special headers */
  -s-headers_names  = jk_pool_alloc(private_data-p, cnt * sizeof(char 
*));
  -s-headers_values = jk_pool_alloc(private_data-p, cnt * sizeof(char 
*));
  +/* allocate an extra header slot in case we need to add a 
content-length header */
  +s-headers_names  = jk_pool_alloc(private_data-p, (cnt + 1) * 
sizeof(char *));
  +s-headers_values = jk_pool_alloc(private_data-p, (cnt + 1) * 
sizeof(char *));
   
   if(!s-headers_names || !s-headers_values || !headers_buf) {
   return JK_FALSE;
  @@ -890,6 +893,9 @@
   if(!strnicmp(tmp, URI_HEADER_NAME, strlen(URI_HEADER_NAME)) ||
  !strnicmp(tmp, WORKER_HEADER_NAME, strlen(WORKER_HEADER_NAME))) {
   real_header = JK_FALSE;
  +} else if(need_content_length_header 
  +   !strnicmp(tmp, CONTENT_LENGTH, strlen(CONTENT_LENGTH))) {
  +need_content_length_header = FALSE;
   } else {
   s-headers_names[i]  = tmp;
   }
  @@ -928,6 +934,15 @@
   if(real_header) {
   i++;
   }
  +}
  +/* Add a content-length = 0 header if needed.
  + * Ajp13 assumes an absent content-length header means an unknown,
  + * but non-zero length body.
  + */
  +if(need_content_length_header) {
  +s-headers_names[cnt] = content-length;
  +s-headers_values[cnt] = 0;
  +cnt++;
   }
   s-num_headers = cnt;
   } else {
  
  
  



cvs commit: jakarta-tomcat/src/native/mod_jk/iis jk_isapi_plugin.c

2000-12-11 Thread nacho

nacho   00/12/11 13:17:49

  Modified:src/native/mod_jk/iis jk_isapi_plugin.c
  Log:
  Bug #61 http://znutar.cortexity.com/BugRatAdmin/ShowBug/61
  Redirect fails with IE after posting a form to a servlet
  Reported  Solved by Joe Prevo ( [EMAIL PROTECTED]  )
  
  Revision  ChangesPath
  1.2   +3 -3  jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c
  
  Index: jk_isapi_plugin.c
  ===
  RCS file: /home/cvs/jakarta-tomcat/src/native/mod_jk/iis/jk_isapi_plugin.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- jk_isapi_plugin.c 2000/08/26 02:03:51 1.1
  +++ jk_isapi_plugin.c 2000/12/11 21:17:47 1.2
  @@ -56,7 +56,7 @@
   /***
* Description: ISAPI plugin for IIS/PWS   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.1 $   *
  + * Version: $Revision: 1.2 $   *
***/
   
   #include httpext.h
  @@ -235,7 +235,7 @@
   for(i = 0 , len_of_headers = 0 ; i  num_of_headers ; i++) {
   len_of_headers += strlen(header_names[i]);
   len_of_headers += strlen(header_values[i]);
  -len_of_headers += 3; /* extra for : and crlf */
  +len_of_headers += 4; /* extra for colon, space and crlf */
   }
   
   len_of_headers += 3;  /* crlf and terminating null char */
  @@ -244,7 +244,7 @@
   
   for(i = 0 ; i  num_of_headers ; i++) {
   strcat(headers_str, header_names[i]);
  -strcat(headers_str, ":");
  +strcat(headers_str, ": ");
   strcat(headers_str, header_values[i]);
   strcat(headers_str, crlf);
   }