Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2005-06-24 Thread Derrick Koes


My apologies, the incorrect dll was being tested.  With so many releases in 
recent months, sometimes they get mixed up.  When can we get this in an 
official release?;-)


Thanks,
Derrick


From: Mladen Turk [EMAIL PROTECTED]
Reply-To: Tomcat Developers List tomcat-dev@jakarta.apache.org
To: Tomcat Developers List tomcat-dev@jakarta.apache.org
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common 
jk_uri_worker_map.c jk_uri_worker_map.h

Date: Thu, 23 Jun 2005 09:43:37 +0200

Derrick Koes wrote:
I tested yesterday's CVS head for compliance with session ID URL 
rewriting.  This fails.  The jsessionid is lost from the URL.




Well, I tested that with the /servlets-examples/servlet/SessionExample
and the jsessionid's *are* preserved.

Can you post the 'JkLogLevel debug' for the requests that are
in your opinion dropping the jsessionid?

Regards,
Mladen.

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





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



Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2005-06-23 Thread Mladen Turk

Derrick Koes wrote:
I tested yesterday's CVS head for compliance with session ID URL 
rewriting.  This fails.  The jsessionid is lost from the URL.




Well, I tested that with the /servlets-examples/servlet/SessionExample
and the jsessionid's *are* preserved.

Can you post the 'JkLogLevel debug' for the requests that are
in your opinion dropping the jsessionid?

Regards,
Mladen.

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



RE: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2005-06-22 Thread Derrick Koes
I tested yesterday's CVS head for compliance with session ID URL rewriting.  
This fails.  The jsessionid is lost from the URL.


Derrick



From: [EMAIL PROTECTED]
Reply-To: Tomcat Developers List tomcat-dev@jakarta.apache.org
To: [EMAIL PROTECTED]
Subject: cvs commit: jakarta-tomcat-connectors/jk/native/common 
jk_uri_worker_map.c jk_uri_worker_map.h

Date: 16 Jun 2005 06:28:38 -

mturk   2005/06/15 23:28:38

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Do not modify the provided uri inplace, but rather use the stack buffer 
for

  that. Also change the map_uri_to_worker to be 'const char'.

  Revision  ChangesPath
  1.56  +17 -12
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c


  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v

  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- jk_uri_worker_map.c   18 May 2005 11:09:55 -  1.55
  +++ jk_uri_worker_map.c   16 Jun 2005 06:28:38 -  1.56
  @@ -411,12 +411,13 @@


   const char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
  -  char *uri, jk_logger_t *l)
  +  const char *uri, jk_logger_t *l)
   {
   unsigned int i;
   char *url_rewrite;
  -char rewrite_char = ';';
   const char *rv = NULL;
  +const char *url = uri;
  +char  buf[JK_MAX_URI_LEN+1];

   JK_TRACE_ENTER(l);
   if (!uw_map || !uri) {
  @@ -432,10 +433,16 @@
   }
   url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
   if (url_rewrite) {
  -rewrite_char = *url_rewrite;
  -*url_rewrite = '\0';
  +size_t len = url_rewrite - uri;
  +if (len  JK_MAX_URI_LEN)
  +len = JK_MAX_URI_LEN;
  +strncpy(buf, uri, len);
  +buf[len] = '\0';
  +url = buf[0];
  +if (JK_IS_DEBUG_LEVEL(l))
  +jk_log(l, JK_LOG_DEBUG, Removing Session path '%s' URI 
'%s',

  +   url_rewrite, url);
   }
  -
   if (uw_map-fname)
   uri_worker_map_update(uw_map, l);
   if (JK_IS_DEBUG_LEVEL(l))
  @@ -456,7 +463,7 @@
   if (uwr-match_type  MATCH_TYPE_WILDCHAR_PATH) {
   const char *wname;
   /* Map is already sorted by context_len */
  -if (wildchar_match(uri, uwr-context,
  +if (wildchar_match(url, uwr-context,
   #ifdef WIN32
  1
   #else
  @@ -473,8 +480,8 @@
   goto cleanup;
}
   }
  -else if (JK_STRNCMP(uwr-context, uri, uwr-context_len) == 0) 
{

  -if (strlen(uri) == uwr-context_len) {
  +else if (JK_STRNCMP(uwr-context, url, uwr-context_len) == 0) 
{

  +if (strlen(url) == uwr-context_len) {
   if (JK_IS_DEBUG_LEVEL(l))
   jk_log(l, JK_LOG_DEBUG,
  Found an exact match %s - %s,
  @@ -489,10 +496,8 @@
   JK_TRACE_EXIT(l);

   cleanup:
  -if (url_rewrite)
  -*url_rewrite = rewrite_char;
   if (rv  uw_map-nosize) {
  -if (is_nomap_match(uw_map, uri, rv, l)) {
  +if (is_nomap_match(uw_map, url, rv, l)) {
   if (JK_IS_DEBUG_LEVEL(l))
   jk_log(l, JK_LOG_DEBUG,
  Denying matching for worker %s by nomatch 
rule,




  1.20  +3 -2  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h


  Index: jk_uri_worker_map.h
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h,v

  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- jk_uri_worker_map.h   26 Apr 2005 15:28:18 -  1.19
  +++ jk_uri_worker_map.h   16 Jun 2005 06:28:38 -  1.20
  @@ -52,6 +52,7 @@
   #define MATCH_TYPE_DISABLED 0x2000
   #define MATCH_TYPE_STOPPED  0x4000

  +#define JK_MAX_URI_LEN  4095
   struct uri_worker_record
   {
   /* Original uri for logging */
  @@ -113,7 +114,7 @@
  const char *puri, const char *pworker, 
jk_logger_t *l);


   const char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
  -  char *uri, jk_logger_t *l);
  +  const char *uri, jk_logger_t *l);

   int uri_worker_map_load(jk_uri_worker_map_t *uw_map,
   jk_logger_t *l);




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





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

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-05-18 Thread mturk
mturk   2005/05/18 04:03:32

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Log invalid uri map request as warning rather then error.
  No functional change.
  
  Revision  ChangesPath
  1.54  +3 -3  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- jk_uri_worker_map.c   13 Apr 2005 11:04:10 -  1.53
  +++ jk_uri_worker_map.c   18 May 2005 11:03:31 -  1.54
  @@ -425,8 +425,8 @@
   return NULL;
   }
   if (*uri != '/') {
  -jk_log(l, JK_LOG_ERROR,
  -uri must start with /);
  +jk_log(l, JK_LOG_WARNING,
  +Uri %s is invalid. Uri must start with /);
   JK_TRACE_EXIT(l);
   return NULL;
   }
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-05-18 Thread mturk
mturk   2005/05/18 04:09:55

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Log invalid uri map request as warning rather then error.
  No functional change.
  
  Revision  ChangesPath
  1.55  +2 -2  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- jk_uri_worker_map.c   18 May 2005 11:03:31 -  1.54
  +++ jk_uri_worker_map.c   18 May 2005 11:09:55 -  1.55
  @@ -426,7 +426,7 @@
   }
   if (*uri != '/') {
   jk_log(l, JK_LOG_WARNING,
  -Uri %s is invalid. Uri must start with /);
  +Uri %s is invalid. Uri must start with /, uri);
   JK_TRACE_EXIT(l);
   return NULL;
   }
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-04-13 Thread mturk
mturk   2005/04/13 04:04:10

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Fix bug in parsing multimatches.
  
  Revision  ChangesPath
  1.53  +1 -3  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- jk_uri_worker_map.c   11 Apr 2005 06:41:24 -  1.52
  +++ jk_uri_worker_map.c   13 Apr 2005 11:04:10 -  1.53
  @@ -240,7 +240,6 @@
   JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
  -uwr-suffix = NULL;
   
   uri = jk_pool_strdup(uw_map-p, puri);
   if (!uri || !worker) {
  @@ -533,7 +532,6 @@
   jk_log(l, JK_LOG_ERROR,
   invalid mapping rule %s-%s, r, w);
   }
  -s++;
   for (; *s; s++)
  *(s - 1) = *s;
   *(s - 1) = '\0';
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-04-11 Thread mturk
mturk   2005/04/10 23:41:24

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Fix compile warnings about unused function and undefined operation.
  
  Revision  ChangesPath
  1.52  +4 -16 
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- jk_uri_worker_map.c   28 Mar 2005 06:34:09 -  1.51
  +++ jk_uri_worker_map.c   11 Apr 2005 06:41:24 -  1.52
  @@ -360,18 +360,6 @@
   return rc;
   }
   
  -/* returns the index of the last occurrence of the 'ch' character
  -   if ch=='\0' returns the length of the string str  */
  -static int last_index_of(const char *str, char ch)
  -{
  -const char *str_minus_one = str - 1;
  -const char *s = str + strlen(str);
  -while (s != str_minus_one  ch != *s) {
  ---s;
  -}
  -return (s - str);
  -}
  -
   static int is_nomap_match(jk_uri_worker_map_t *uw_map,
 const char *uri, const char* worker,
 jk_logger_t *l)
  @@ -539,15 +527,15 @@
   if (strchr(u, '|')) {
   char *s, *r = strdup(u);
   s = strchr(r, '|');
  -*s = '\0';
  +*(s++) = '\0';
   /* Add first mapping */
   if (!uri_worker_map_add(uw_map, r, w, l)) {
   jk_log(l, JK_LOG_ERROR,
   invalid mapping rule %s-%s, r, w);
   }
   s++;
  -while (*s)
  -   *(s - 1) = *s++;
  +for (; *s; s++)
  +   *(s - 1) = *s;
   *(s - 1) = '\0';
   /* add second mapping */
   if (!uri_worker_map_add(uw_map, r, w, l)) {
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-03-27 Thread mturk
mturk   2005/03/27 22:34:09

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Major uri worker mapping simplification. Sice we have wildchar
  matching it can be used for any use case except exact matching.
  Also added option to use 'double' mappings
  'JkMount 'application|/*' will create two mappings at once:
  'JkMount /applicantion' and 'JkMount /application/*'.
  
  Revision  ChangesPath
  1.51  +60 -345   
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- jk_uri_worker_map.c   21 Feb 2005 11:18:48 -  1.50
  +++ jk_uri_worker_map.c   28 Mar 2005 06:34:09 -  1.51
  @@ -74,63 +74,15 @@
   return -1;
   }
   else if (exp[y] != '?') {
  -if (icase  tolower(str[x]) != tolower(exp[y]))
  +if (icase  (tolower(str[x]) != tolower(exp[y])))
   return 1;
   else if (!icase  str[x] != exp[y])
   return 1;
   }
   }
   return (str[x] != '\0');
  -} 
  -
  -/*
  - * We are now in a security nightmare, it maybe that somebody sent 
  - * us a uri that looks like /top-secret.jsp. and the web server will 
  - * fumble and return the jsp content. 
  - *
  - * To solve that we will check for path info following the suffix, we 
  - * will also check that the end of the uri is not .suffix.,
  - * .suffix/, or .suffix .
  - */
  -static int check_security_fraud(jk_uri_worker_map_t *uw_map, const char *uri)
  -{
  -unsigned i;
  -
  -for (i = 0; i  uw_map-size; i++) {
  -if (uw_map-maps[i]-match_type == MATCH_TYPE_SUFFIX) {
  -char *suffix_start;
  -for (suffix_start = strstr(uri, uw_map-maps[i]-suffix);
  - suffix_start;
  - suffix_start =
  - strstr(suffix_start + 1, uw_map-maps[i]-suffix)) {
  -
  -if ('.' != *(suffix_start - 1)) {
  -continue;
  -}
  -else {
  -char *after_suffix =
  -suffix_start + strlen(uw_map-maps[i]-suffix);
  -
  -if ((('.' == *after_suffix) || ('/' == *after_suffix)
  - || (' ' == *after_suffix))
  - (0 ==
  -JK_STRNCMP(uw_map-maps[i]-context, uri,
  -   uw_map-maps[i]-context_len))) {
  -/* 
  - * Security violation !!!
  - * this is a fraud.
  - */
  -return i;
  -}
  -}
  -}
  -}
  -}
  -
  -return -1;
   }
   
  -
   int uri_worker_map_alloc(jk_uri_worker_map_t **uw_map,
jk_map_t *init_data, jk_logger_t *l)
   {
  @@ -249,8 +201,8 @@
   match_type |= MATCH_TYPE_NO_MATCH;
   puri++;
   }
  -
  -/* Find if duplicate entry */
  +
  +/* Find if duplicate entry */
   for (i = 0; i  uw_map-size; i++) {
   uwr = uw_map-maps[i];
   if (strcmp(uwr-uri, puri) == 0) {
  @@ -289,7 +241,7 @@
   return JK_FALSE;
   }
   uwr-suffix = NULL;
  -
  +
   uri = jk_pool_strdup(uw_map-p, puri);
   if (!uri || !worker) {
   jk_log(l, JK_LOG_ERROR,
  @@ -298,99 +250,28 @@
   return JK_FALSE;
   }
   
  -if (uri[0] == '/') {
  -char *asterisk = strchr(uri, '*');
  -
  -if ((asterisk  strchr(asterisk + 1, '*')) ||
  +if (*uri == '/') {
  +if (strchr(uri, '*') ||
   strchr(uri, '?')) {
  -uwr-uri = uri;
  -/* Lets check if we have multiple
  - * asterixes in the uri like:
  +/* Something like
* /context/ * /user/ *
  + * /context/ *.suffix
*/
  -uwr-context = uri;
   match_type |= MATCH_TYPE_WILDCHAR_PATH;
   jk_log(l, JK_LOG_DEBUG,
  -wild chars path rule %s=%s was added,
  +wildchar rule %s=%s was added,
   uri, worker);
   
   }
  -else if (asterisk) {
  -uwr-uri = jk_pool_strdup(uw_map-p, uri);
  -
  -if (!uwr-uri) {
  -jk_log(l, JK_LOG_ERROR,
  -   can't alloc uri string);
  -JK_TRACE_EXIT(l);
  -return JK_FALSE;
  -}
  -/*
  - * Now, lets check that the pattern is /context/asterisk.suffix
  - * or /context/asterisk
  - * we need to have a 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2005-02-21 Thread mturk
mturk   2005/02/21 00:27:13

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Add functions for dynamic loading of uriworkermap files. Default
  interval is 60 s. If file is modified then reload its content and update
  uri mappings.
  
  Revision  ChangesPath
  1.49  +93 -11
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- jk_uri_worker_map.c   20 Feb 2005 18:31:21 -  1.48
  +++ jk_uri_worker_map.c   21 Feb 2005 08:27:13 -  1.49
  @@ -24,6 +24,8 @@
   
   #include jk_pool.h
   #include jk_util.h
  +#include jk_map.h
  +#include jk_mt.h
   #include jk_uri_worker_map.h
   
   #ifdef WIN32
  @@ -135,10 +137,19 @@
   JK_TRACE_ENTER(l);
   
   if (init_data  uw_map) {
  -int rc = uri_worker_map_open(*uw_map =
  - (jk_uri_worker_map_t *)
  - malloc(sizeof(jk_uri_worker_map_t)),
  - init_data, l);
  +int rc;
  +*uw_map = (jk_uri_worker_map_t *)calloc(1, 
sizeof(jk_uri_worker_map_t));
  +
  +JK_INIT_CS(((*uw_map)-cs), rc);
  +if (rc == JK_FALSE) {
  +jk_log(l, JK_LOG_ERROR,
  +   creating thread lock errno=%d,
  +   errno);
  +JK_TRACE_EXIT(l);
  +return JK_FALSE;
  +}
  +
  +rc = uri_worker_map_open(*uw_map, init_data, l);
   JK_TRACE_EXIT(l);
   return rc;
   }
  @@ -154,6 +165,8 @@
   JK_TRACE_ENTER(l);
   
   if (uw_map) {
  +int i;
  +JK_DELETE_CS((uw_map-cs), i);
   jk_close_pool(uw_map-p);
   JK_TRACE_EXIT(l);
   return JK_TRUE;
  @@ -225,8 +238,16 @@
   
   JK_TRACE_ENTER(l);
   
  +if (*puri == '-') {
  +/* Disable urimap.
  + * This way you can disable already mounted
  + * context.
  + */
  +match_type = MATCH_TYPE_DISABLED;
  +puri++;
  +}
   if (*puri == '!') {
  -match_type = MATCH_TYPE_NO_MATCH;
  +match_type |= MATCH_TYPE_NO_MATCH;
   puri++;
   }
   
  @@ -234,6 +255,11 @@
   for (i = 0; i  uw_map-size; i++) {
   uwr = uw_map-maps[i];
   if (strcmp(uwr-uri, puri) == 0) {
  +/* Update disabled flag */
  +if (match_type  MATCH_TYPE_DISABLED)
  +uwr-match_type |= MATCH_TYPE_DISABLED;
  +else
  +uwr-match_type = ~MATCH_TYPE_DISABLED;
   if (strcmp(uwr-worker_name, worker) == 0) {
   jk_log(l, JK_LOG_DEBUG,
  map rule %s=%s already exists,
  @@ -245,7 +271,7 @@
   jk_log(l, JK_LOG_DEBUG,
  changing map rule %s=%s ,
  puri, worker);
  -uwr-worker_name = worker;
  +uwr-worker_name = jk_pool_strdup(uw_map-p, worker);
   JK_TRACE_EXIT(l);
   return JK_TRUE;
   }
  @@ -366,7 +392,7 @@
  exact rule %s=%s was added,
  uri, worker);
   }
  -uwr-worker_name = worker;
  +uwr-worker_name = jk_pool_strdup(uw_map-p, worker);
   uwr-context_len = strlen(uwr-context);
   }
   else {
  @@ -640,7 +666,9 @@
*/
   jk_no2slash(uri);
   #endif
  -
  +
  +if (uw_map-fname)
  +uri_worker_map_update(uw_map, l);
   if (JK_IS_DEBUG_LEVEL(l))
   jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s' from %d maps,
  uri, uw_map-size);
  @@ -792,11 +820,65 @@
   if (is_nomap_match(uw_map, uri, rv, l)) {
   if (JK_IS_DEBUG_LEVEL(l))
   jk_log(l, JK_LOG_DEBUG,
  -Denying matching for worker %s by nomatch rule,
  -rv);
  +   Denying matching for worker %s by nomatch rule,
  +   rv);
   JK_TRACE_EXIT(l);
   rv = NULL;
   }
   }
   return rv;
   }
  +
  +int uri_worker_map_load(jk_uri_worker_map_t *uw_map,
  +jk_logger_t *l)
  +{
  +int rc = JK_FALSE;
  +jk_map_t *map;
  +
  +jk_map_alloc(map);
  +if (jk_map_read_properties(map, uw_map-fname,
  +   uw_map-modified)) {
  +int i;
  +for (i = 0; i  jk_map_size(map); i++) {
  +const char *u = jk_map_name_at(map, i);
  +const char *w = jk_map_value_at(map, i);
  +if (!uri_worker_map_add(uw_map, u, w, l)) {
  +jk_log(l, JK_LOG_ERROR,
 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-02-20 Thread mturk
mturk   2005/02/20 04:48:51

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Ensure there are no duplicates entries for uriworker map.
  
  Revision  ChangesPath
  1.47  +34 -12
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- jk_uri_worker_map.c   20 Feb 2005 12:21:10 -  1.46
  +++ jk_uri_worker_map.c   20 Feb 2005 12:48:51 -  1.47
  @@ -95,7 +95,7 @@
   unsigned i;
   
   for (i = 0; i  uw_map-size; i++) {
  -if (MATCH_TYPE_SUFFIX == uw_map-maps[i]-s-match_type) {
  +if (uw_map-maps[i]-s-match_type == MATCH_TYPE_SUFFIX) {
   char *suffix_start;
   for (suffix_start = strstr(uri, uw_map-maps[i]-suffix);
suffix_start;
  @@ -217,19 +217,46 @@
   int uri_worker_map_add(jk_uri_worker_map_t *uw_map,
  const char *puri, const char *worker, jk_logger_t *l)
   {
  -uri_worker_record_t *uwr;
  +uri_worker_record_t *uwr = NULL;
   char *uri;
   unsigned int match_type = 0;
  +unsigned int i;
  +int allocated = 0;
   
   JK_TRACE_ENTER(l);
  +
  +if (*puri == '!') {
  +match_type = MATCH_TYPE_NO_MATCH;
  +puri++;
  +}
  +
  +/* Find if duplicate entry */
  +for (i = 0; i  uw_map-size; i++) {
  +uwr = uw_map-maps[i];
  +if (strcmp(uwr-uri, puri) == 0) {
  +if (strcmp(uwr-worker_name, worker) == 0) {
  +jk_log(l, JK_LOG_DEBUG,
  +   map rule %s=%s already exists,
  +   puri, worker);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +else {
  +jk_log(l, JK_LOG_DEBUG,
  +   changing map rule %s=%s ,
  +   puri, worker);
  +uwr-worker_name = worker;
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +}
  +}
   if (uri_worker_map_realloc(uw_map) == JK_FALSE) {
   JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
  -uwr =
  -(uri_worker_record_t *) jk_pool_alloc(uw_map-p,
  -  sizeof(uri_worker_record_t));
  -
  +uwr = (uri_worker_record_t *)jk_pool_alloc(uw_map-p,
  +sizeof(uri_worker_record_t));
   if (!uwr) {
   jk_log(l, JK_LOG_ERROR,
  can't alloc map entry);
  @@ -238,11 +265,6 @@
   }
   uwr-suffix = NULL;
   
  -if (*puri == '!') {
  -match_type = MATCH_TYPE_NO_MATCH;
  -puri++;
  -}
  -
   uri = jk_pool_strdup(uw_map-p, puri);
   if (!uri || !worker) {
   jk_log(l, JK_LOG_ERROR,
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2005-02-12 Thread mturk
mturk   2005/02/12 11:29:08

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Remove assigments that can be set at global level.
  
  Revision  ChangesPath
  1.45  +4 -20 
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- jk_uri_worker_map.c   12 Feb 2005 11:55:33 -  1.44
  +++ jk_uri_worker_map.c   12 Feb 2005 19:29:08 -  1.45
  @@ -294,6 +294,7 @@
   JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
  +uwr-suffix = NULL;
   
   if (*puri == '!') {
   uwr-no_match = 1;
  @@ -317,21 +318,12 @@
   
   if ((asterisk  strchr(asterisk + 1, '*')) ||
   strchr(uri, '?')) {
  -uwr-uri = jk_pool_strdup(uw_map-p, uri);
  -
  -if (!uwr-uri) {
  -jk_log(l, JK_LOG_ERROR,
  -   can't alloc uri string);
  -JK_TRACE_EXIT(l);
  -return JK_FALSE;
  -}
  +uwr-uri = uri;
   /* Lets check if we have multiple
* asterixes in the uri like:
* /context/ * /user/ *
*/
  -uwr-worker_name = worker;
   uwr-context = uri;
  -uwr-suffix = NULL;
   uwr-match_type = MATCH_TYPE_WILDCHAR_PATH;
   jk_log(l, JK_LOG_DEBUG,
   wild chars path rule %s=%s was added,
  @@ -358,7 +350,6 @@
   if (0 == strncmp(/*/, uri, 3)) {
   /* general context path */
   asterisk[1] = '\0';
  -uwr-worker_name = worker;
   uwr-context = uri;
   uwr-suffix = asterisk + 2;
   uwr-match_type = MATCH_TYPE_CONTEXT_PATH;
  @@ -369,7 +360,6 @@
   else if ('.' == asterisk[2]) {
   /* suffix rule */
   asterisk[1] = asterisk[2] = '\0';
  -uwr-worker_name = worker;
   uwr-context = uri;
   uwr-suffix = asterisk + 3;
   uwr-match_type = MATCH_TYPE_SUFFIX;
  @@ -380,7 +370,6 @@
   else if ('\0' != asterisk[2]) {
   /* general suffix rule */
   asterisk[1] = '\0';
  -uwr-worker_name = worker;
   uwr-context = uri;
   uwr-suffix = asterisk + 2;
   uwr-match_type = MATCH_TYPE_GENERAL_SUFFIX;
  @@ -391,9 +380,7 @@
   else {
   /* context based */
   asterisk[1] = '\0';
  -uwr-worker_name = worker;
   uwr-context = uri;
  -uwr-suffix = NULL;
   uwr-match_type = MATCH_TYPE_CONTEXT;
   jk_log(l, JK_LOG_DEBUG,
  match rule %s=%s was added, uri, worker);
  @@ -402,9 +389,7 @@
   else {
   /* Something like : JkMount /servlets/exampl* ajp13 */
   uwr-uri = uri;
  -uwr-worker_name = worker;
   uwr-context = uri;
  -uwr-suffix = NULL;
   uwr-match_type = MATCH_TYPE_EXACT;
   jk_log(l, JK_LOG_DEBUG,
  exact rule %s=%s was added,
  @@ -415,14 +400,13 @@
   else {
   /* Something like:  JkMount /login/j_security_check ajp13 */
   uwr-uri = uri;
  -uwr-worker_name = worker;
   uwr-context = uri;
  -uwr-suffix = NULL;
   uwr-match_type = MATCH_TYPE_EXACT;
   jk_log(l, JK_LOG_DEBUG,
  exact rule %s=%s was added,
  uri, worker);
   }
  +uwr-worker_name = worker;
   uwr-ctxt_len = strlen(uwr-context);
   }
   else {
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2005-01-12 Thread mturk
mturk   2005/01/12 23:20:56

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Remove forward declarations for static functions.
  
  Revision  ChangesPath
  1.41  +17 -17
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- jk_uri_worker_map.c   17 Dec 2004 14:58:37 -  1.40
  +++ jk_uri_worker_map.c   13 Jan 2005 07:20:56 -  1.41
  @@ -206,6 +206,22 @@
   return JK_FALSE;
   }
   
  +static int uri_worker_map_close(jk_uri_worker_map_t *uw_map, jk_logger_t *l)
  +{
  +JK_TRACE_ENTER(l);
  +
  +if (uw_map) {
  +jk_close_pool(uw_map-p);
  +jk_close_pool(uw_map-tp);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +
  +JK_LOG_NULL_PARAMS(l);
  +JK_TRACE_EXIT(l);
  +return JK_FALSE;
  +}
  +
   int uri_worker_map_free(jk_uri_worker_map_t **uw_map, jk_logger_t *l)
   {
   JK_TRACE_ENTER(l);
  @@ -508,22 +524,6 @@
   --s;
   }
   return (s - str);
  -}
  -
  -static int uri_worker_map_close(jk_uri_worker_map_t *uw_map, jk_logger_t *l)
  -{
  -JK_TRACE_ENTER(l);
  -
  -if (uw_map) {
  -jk_close_pool(uw_map-p);
  -jk_close_pool(uw_map-tp);
  -JK_TRACE_EXIT(l);
  -return JK_TRUE;
  -}
  -
  -JK_LOG_NULL_PARAMS(l);
  -JK_TRACE_EXIT(l);
  -return JK_FALSE;
   }
   
   static void jk_no2slash(char *name)
  
  
  
  1.12  +1 -5  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h
  
  Index: jk_uri_worker_map.h
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- jk_uri_worker_map.h   8 Nov 2004 13:33:55 -   1.11
  +++ jk_uri_worker_map.h   13 Jan 2005 07:20:56 -  1.12
  @@ -47,10 +47,6 @@
   int uri_worker_map_add(jk_uri_worker_map_t *uw_map,
  char *puri, char *pworker, jk_logger_t *l);
   
  -int uri_worker_map_close(jk_uri_worker_map_t *uw_map, jk_logger_t *l);
  -
  -void jk_no2slash(char *name);
  -
   char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
   char *uri, jk_logger_t *l);
   
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread mturk
mturk   2004/12/17 03:24:38

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Fix url rewrite for jksessionid. It should fix all jksessionid bugs, cause
  previous implemantation didn't handle that properly.
  
  Revision  ChangesPath
  1.39  +19 -8 
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- jk_uri_worker_map.c   13 Dec 2004 16:59:58 -  1.38
  +++ jk_uri_worker_map.c   17 Dec 2004 11:24:38 -  1.39
  @@ -659,7 +659,9 @@
   unsigned int i;
   int best_match = -1;
   unsigned int longest_match = 0;
  -char *url_rewrite;
  +char *url_rewrite = NULL;
  +char rewrite_char;
  +char *rv = NULL;
   
   JK_TRACE_ENTER(l);
   if (!uw_map || !uri) {
  @@ -675,6 +677,7 @@
   }
   url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
   if (url_rewrite) {
  +rewrite_char = *url_rewrite;
   *url_rewrite = '\0'; 
   }
   jk_no2slash(uri);
  @@ -686,7 +689,7 @@
   if (uw_map-no_size  is_nomap_match(uw_map, uri, l)) {
   /* Found a no match */
   JK_TRACE_EXIT(l);
  -return NULL;
  +goto cleanup;;
   }
   for (i = 0; i  uw_map-size; i++) {
   uri_worker_record_t *uwr = uw_map-maps[i];
  @@ -713,7 +716,8 @@
  Found a wildchar match %s - %s\n,
  uwr-worker_name, uwr-context);
   JK_TRACE_EXIT(l);
  -return wname;
  +rv = wname;
  +goto cleanup;
}
   }
   else if (JK_STRNCMP(uwr-context, uri, uwr-ctxt_len) == 0) {
  @@ -723,7 +727,8 @@
   Found an exact match %s - %s\n,
   uwr-worker_name, uwr-context);
   JK_TRACE_EXIT(l);
  -return uwr-worker_name;
  +rv = uwr-worker_name;
  +goto cleanup;
   }
   }
   else if (uwr-match_type == MATCH_TYPE_CONTEXT) {
  @@ -792,7 +797,8 @@
   
   if (best_match != -1) {
   JK_TRACE_EXIT(l);
  -return uw_map-maps[best_match]-worker_name;
  +rv = uw_map-maps[best_match]-worker_name;
  +goto cleanup;
   }
   else {
   /*
  @@ -810,9 +816,14 @@
   Found a security fraud in '%s'\n,
   uri);
   JK_TRACE_EXIT(l);
  -return uw_map-maps[fraud]-worker_name;
  +rv = uw_map-maps[fraud]-worker_name;
  +goto cleanup;
   }
   }
   JK_TRACE_EXIT(l);
  -return NULL;
  +
  +cleanup:
  +if (url_rewrite)
  +*url_rewrite = rewrite_char;
  +return rv;
   }
  
  
  

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



Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Bill Barker
- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 17, 2004 3:24 AM
Subject: cvs commit: jakarta-tomcat-connectors/jk/native/common 
jk_uri_worker_map.c


mturk   2004/12/17 03:24:38
 Modified:jk/native/common jk_uri_worker_map.c
 Log:
 Fix url rewrite for jksessionid. It should fix all jksessionid bugs, 
cause
 previous implemantation didn't handle that properly.

I'm -1 on this patch.  map_uri_to_worker doesn't need all of this spaghetti 
just because IIS is broken. 


This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.
In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.

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

Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
I'm -1 on this patch.  map_uri_to_worker doesn't need all of this 
spaghetti just because IIS is broken.

No, it's not related to IIS at all.
The previous implementation was taking the uri an cut out the
';jseessionid=...' from the url.
Take a look at JK2 and it's jk_uriMap.c:
url is rewritten, but restored on exit that jk did not do.
That is exactly what this patch does.
Regards,
Mladen
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
I'm -1 on this patch.  map_uri_to_worker doesn't need all of this 
spaghetti just because IIS is broken.

Continuing from last reply...
Also, I'm stunned with the fact that there is no reports in
Bugzilla about that.
I mean we have used the uri:
/uri;jsessionid=?params
and made:
url_rewrite = strstr(uri, ;jsessionid')
then
*url = '\0';
Thus cutting everything including jsessionid.
The JK2 allways restored that on exit
(take a look at '*url_rewrite = origChar').
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:

I'm -1 on this patch.  map_uri_to_worker doesn't need all of this 
spaghetti just because IIS is broken.

Also you can see the difference with Apache2.
Open http://host/servlets-examples/servlet/SessionExample
Now, click on the 'Url encoded' link.
You will see the ';jsessionid=' in the url.
Click the 'refresh' without the patch and you'll loose
everything after ';'.
Use the patch, and the url will be preserved.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Bill Barker
- Original Message - 
From: Mladen Turk [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Sent: Friday, December 17, 2004 8:06 AM
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common 
jk_uri_worker_map.c


Bill Barker wrote:
I'm -1 on this patch.  map_uri_to_worker doesn't need all of this 
spaghetti just because IIS is broken.

No, it's not related to IIS at all.
Of course it is related to IIS, since IIS is the only one that (wrongly) 
doesn't pass a copy of the URI to map_uri_to_worker

The previous implementation was taking the uri an cut out the
';jseessionid=...' from the url.
Take a look at JK2 and it's jk_uriMap.c:
url is rewritten, but restored on exit that jk did not do.
That is exactly what this patch does.
Yeah, well, JK2 is hardly a shining example of how things should be done 
;-).  jk_uriMap.c is well known to be seriously broken.


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


This message is intended only for the use of the person(s) listed above as 
the intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.
In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.

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

Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
No, it's not related to IIS at all.
Of course it is related to IIS, since IIS is the only one that (wrongly) 
doesn't pass a copy of the URI to map_uri_to_worker

OK. Seems that you catch me on that :).
But since the request is supposed to be atomic why to strdup an uri?
I'd rather remove
char *uri = apr_pstrdup(r-pool, r-uri);
before calling map_uri_to_worker then adding strdup to IIS.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Bill Barker

- Original Message -
From: Mladen Turk [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Sent: Friday, December 17, 2004 9:34 AM
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common
jk_uri_worker_map.c


 Bill Barker wrote:
 
  No, it's not related to IIS at all.
 
 
  Of course it is related to IIS, since IIS is the only one that (wrongly)
  doesn't pass a copy of the URI to map_uri_to_worker
 

 OK. Seems that you catch me on that :).

 But since the request is supposed to be atomic why to strdup an uri?
 I'd rather remove
 char *uri = apr_pstrdup(r-pool, r-uri);
 before calling map_uri_to_worker then adding strdup to IIS.


It was done to fix a '//' bypass traversal bug (e.g.
http://myserver/myapp//foo.jsp would serve the source of the JSP).
map_uri_to_worker calls jk_no2slash, which modifies the URI in ways that are
hard to undo.  The reason that the call is done outside of map_uri_to_worker
is simply that apr_pstrdup is better than jk_pool_strdup.  Otherwise, it's
trying to be like location_walk in Apache.

In the case of IIS, something like:
  char temp_uri[INTERNET_MAX_URL_LENGTH];
  strcpy(temp_uri, uri);
  worker = map_uri_to_worker(uw_map, temp_uri, logger);

is probably no worse than the rest of the code :).  However, I kept breaking
IIS whenever I tried to change things in it, so I just gave up at some
point.


 Regards,
 Mladen.

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




This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.


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

Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
But since the request is supposed to be atomic why to strdup an uri?
I'd rather remove
char *uri = apr_pstrdup(r-pool, r-uri);
before calling map_uri_to_worker then adding strdup to IIS.
It was done to fix a '//' bypass traversal bug (e.g.
http://myserver/myapp//foo.jsp would serve the source of the JSP).
Yep, but is that really the responsibility of the JK?
The jk is supposed to be a proxy, so as less intervention in the
protocol the better results will be.
I have comment out the jk_no2slash checking inside map_uri_to_worker
cause found no difference with or without it.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Bill Barker

- Original Message -
From: Mladen Turk [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Sent: Friday, December 17, 2004 11:59 AM
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common
jk_uri_worker_map.c


 Bill Barker wrote:
 But since the request is supposed to be atomic why to strdup an uri?
 I'd rather remove
 char *uri = apr_pstrdup(r-pool, r-uri);
 before calling map_uri_to_worker then adding strdup to IIS.
 
 
  It was done to fix a '//' bypass traversal bug (e.g.
  http://myserver/myapp//foo.jsp would serve the source of the JSP).

 Yep, but is that really the responsibility of the JK?
 The jk is supposed to be a proxy, so as less intervention in the
 protocol the better results will be.


It's consistant with location_walk in Apache, so at least for mod_jk.so is
seems to be pretty important that the uri mapping rules work the same way.
Without the consistancy, configuration for JK becomes even harder than for
JK2 :(.

 I have comment out the jk_no2slash checking inside map_uri_to_worker
 cause found no difference with or without it.


Try with only:
JkMount /myapp/*.jsp

and requesting:
http://myserver//myapp/index.jsp

 Regards,
 Mladen.

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




This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.


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

another data point RE: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Derrick Koes

The fix made early this morning (~7-8am Eastern) works to fix the problem I was 
having with URL rewriting.
I'll grab the latest code set again soon and retry.

Thanks for your fast response on this Mladen.  JK2s eol is the impetus for my 
usage of JK and this is the one glaring defect/difference I've found to this 
point.

Derrick



-Original Message-
From: Mladen Turk [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 17, 2004 2:59 PM
To: Tomcat Developers List
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common 
jk_uri_worker_map.c

Bill Barker wrote:
But since the request is supposed to be atomic why to strdup an uri?
I'd rather remove
char *uri = apr_pstrdup(r-pool, r-uri); before calling 
map_uri_to_worker then adding strdup to IIS.

 
 It was done to fix a '//' bypass traversal bug (e.g.
 http://myserver/myapp//foo.jsp would serve the source of the JSP).

Yep, but is that really the responsibility of the JK?
The jk is supposed to be a proxy, so as less intervention in the protocol the 
better results will be.

I have comment out the jk_no2slash checking inside map_uri_to_worker cause 
found no difference with or without it.

Regards,
Mladen.

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





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



Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
Try with only:
JkMount /myapp/*.jsp
and requesting:
http://myserver//myapp/index.jsp
Yes I did, and it really doesn't mater.
Well my jsp's are inside tomcat application, so I admit
there can be problems if the .jsp is hanging around
somewhere outside web application :).
Also I've tried that with 5.0/5.5, so if it breaks
some older tomcat versions feel free to include the
jk_no2slash checking again, and compare every char
with the slash in the uri on the each request made.
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: another data point RE: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Derrick Koes wrote:
The fix made early this morning (~7-8am Eastern) works to fix the problem I was 
having with URL rewriting.
I'll grab the latest code set again soon and retry.
Cool, those are really good news!
Glad that it works finally :).
Regards,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Bill Barker

- Original Message -
From: Mladen Turk [EMAIL PROTECTED]
To: Tomcat Developers List [EMAIL PROTECTED]
Sent: Friday, December 17, 2004 12:47 PM
Subject: Re: cvs commit: jakarta-tomcat-connectors/jk/native/common
jk_uri_worker_map.c


 Bill Barker wrote:
 
  Try with only:
  JkMount /myapp/*.jsp
 
  and requesting:
  http://myserver//myapp/index.jsp
 

 Yes I did, and it really doesn't mater.
 Well my jsp's are inside tomcat application, so I admit
 there can be problems if the .jsp is hanging around
 somewhere outside web application :).

It's for when you want Apache to act as the default servlet, so you have:
  Alias /myapp/ /path/to/myapp/
  JkMount /myapp/*.jsp ajp13


 Also I've tried that with 5.0/5.5, so if it breaks
 some older tomcat versions feel free to include the
 jk_no2slash checking again, and compare every char
 with the slash in the uri on the each request made.


All of the Tomcat mappers from 3.3 up will handle the request fine if it
ever sees it.  However,  with the code as it is now, mod_jk will refuse the
request.

Now that mod_jk is hopelessly broken, I guess I'll just have to wait for
proxy_ajp before upgrading.


 Regards,
 Mladen.

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




This message is intended only for the use of the person(s) listed above as the 
intended recipient(s), and may contain information that is PRIVILEGED and 
CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or 
distribute this message or any attachment. If you received this communication 
in error, please notify us immediately by e-mail and then delete all copies of 
this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through 
the Internet is not secure. Do not send confidential or sensitive information, 
such as social security numbers, account numbers, personal identification 
numbers and passwords, to us via ordinary (unencrypted) e-mail.


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

Re: cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-17 Thread Mladen Turk
Bill Barker wrote:
and requesting:
http://myserver//myapp/index.jsp
Yes I did, and it really doesn't mater.
Well my jsp's are inside tomcat application, so I admit
there can be problems if the .jsp is hanging around
somewhere outside web application :).

It's for when you want Apache to act as the default servlet, so you have:
  Alias /myapp/ /path/to/myapp/
  JkMount /myapp/*.jsp ajp13
First of all it has nothing to do with the two slashes in the url.
I agree:
Alias /foo/ /opt/tomcat/webapps/jsp-examples
JkMount /foo/*.jsp wlb
Produces Tomcat returning 404 error page (Tomcat).
But that is exactly how jk 1.2.6 behaves.
So I really do not understand your post.
Regrads,
Mladen.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-13 Thread mturk
mturk   2004/12/13 09:00:00

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Remove more '/*' within comment.
  
  Revision  ChangesPath
  1.38  +3 -3  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- jk_uri_worker_map.c   13 Dec 2004 16:57:39 -  1.37
  +++ jk_uri_worker_map.c   13 Dec 2004 16:59:58 -  1.38
  @@ -332,8 +332,8 @@
   return JK_FALSE;
   }
   /*
  - * Now, lets check that the pattern is /context/*.suffix
  - * or /context/*
  + * Now, lets check that the pattern is /context/asterisk.suffix
  + * or /context/asterisk
* we need to have a '/' then a '*' and the a '.' or a
* '/' then a '*'
*/
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-13 Thread mturk
mturk   2004/12/13 08:57:39

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Remove '/*' within comment.
  
  Revision  ChangesPath
  1.37  +2 -9  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- jk_uri_worker_map.c   13 Dec 2004 07:41:07 -  1.36
  +++ jk_uri_worker_map.c   13 Dec 2004 16:57:39 -  1.37
  @@ -16,17 +16,10 @@
   
   /***
* Description: URI to worker map object.  *
  - * Maps can be *
  - * *
  - * Exact Context - /exact/uri=worker e.g. /examples/do*=ajp12 *
  - * Context Based - /context/*=worker e.g. /examples/*=ajp12   *
  - * Context and suffix -/context/*.suffix=worker e.g. /examples/*.jsp=ajp12*
  - * *
  - * This lets us either partition the work among the web server and the *
  - * servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision$   *
  + * Author:  Mladen Turk [EMAIL PROTECTED] *
  + * Version: $Revision$  *
***/
   
   #include jk_pool.h
  
  
  

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


cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-12 Thread mturk
mturk   2004/12/12 23:41:07

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Use case insensitive mapping for WIN32, cause Admin equals admin on
  windows. Also force nomatces before any other mappings.
  
  Revision  ChangesPath
  1.36  +138 -62   
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- jk_uri_worker_map.c   7 Dec 2004 14:30:23 -   1.35
  +++ jk_uri_worker_map.c   13 Dec 2004 07:41:07 -  1.36
  @@ -42,6 +42,14 @@
   /* match multiple wild characters (*) and (?) */
   #define MATCH_TYPE_WILDCHAR_PATH (5)
   
  +#ifdef WIN32
  +#define JK_STRCMP   strcasecmp
  +#define JK_STRNCMP  strnicmp
  +#else
  +#define JK_STRCMP   strcmp
  +#define JK_STRNCMP  strncmp
  +#endif
  +
   struct uri_worker_record
   {
   /* Original uri for logging */
  @@ -81,10 +89,13 @@
   uri_worker_record_t **maps;
   
   /* Map Number */
  -unsigned size;
  +unsigned int size;
   
   /* Map Capacity */
  -unsigned capacity;
  +unsigned int capacity;
  +
  +/* NoMap Number */
  +unsigned int no_size;
   };
   
   static int worker_compare(const void *elem1, const void *elem2)
  @@ -165,8 +176,8 @@
   if ((('.' == *after_suffix) || ('/' == *after_suffix)
|| (' ' == *after_suffix))
(0 ==
  -strncmp(uw_map-maps[i]-context, uri,
  -uw_map-maps[i]-ctxt_len))) {
  +JK_STRNCMP(uw_map-maps[i]-context, uri,
  +   uw_map-maps[i]-ctxt_len))) {
   /* 
* Security violation !!!
* this is a fraud.
  @@ -421,7 +432,10 @@
   
   uw_map-maps[uw_map-size] = uwr;
   uw_map-size++;
  -
  +if (uwr-no_match) {
  +/* If we split the mappings this one will be calculated */
  +uw_map-no_size++;
  +}
   worker_qsort(uw_map);
   JK_TRACE_EXIT(l);
   return JK_TRUE;
  @@ -543,6 +557,108 @@
   *d = '\0';
   }
   
  +static int is_nomap_match(jk_uri_worker_map_t *uw_map,
  +  const char *uri, jk_logger_t *l)
  +{
  +unsigned int i;
  +
  +JK_TRACE_ENTER(l);
  +
  +for (i = 0; i  uw_map-size; i++) {
  +uri_worker_record_t *uwr = uw_map-maps[i];
  +
  +/* Check only nomatch mappings */
  +if (!uwr-no_match)
  +continue;
  +
  +if (uwr-match_type == MATCH_TYPE_WILDCHAR_PATH) {
  +char *wname;
  +/* Map is already sorted by ctxt_len */
  +if (wildchar_match(uri, uwr-context,
  +#ifdef WIN32
  +   1
  +#else
  +   0
  +#endif
  +   ) == 0) {
  +wname = uwr-worker_name;
  +jk_log(l, JK_LOG_DEBUG,
  +   Found a wildchar no match %s - %s\n,
  +   uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  + }
  +}
  +else if (JK_STRNCMP(uwr-context, uri, uwr-ctxt_len) == 0) {
  +if (uwr-match_type == MATCH_TYPE_EXACT) {
  +if (strlen(uri) == uwr-ctxt_len) {
  +jk_log(l, JK_LOG_DEBUG,
  +   Found an exact no match %s - %s\n,
  +uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +}
  +else if (uwr-match_type == MATCH_TYPE_CONTEXT) {
  +jk_log(l, JK_LOG_DEBUG,
  +   Found a context no match %s - %s\n,
  +   uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +else if (uwr-match_type == MATCH_TYPE_GENERAL_SUFFIX) {
  +int suffix_start = last_index_of(uri, uwr-suffix[0]);
  +if (suffix_start = 0
  + 0 == JK_STRCMP(uri + suffix_start, uwr-suffix)) {
  +jk_log(l, JK_LOG_DEBUG,
  +   Found a general no suffix match for %s - 
%s\n,
  +   uwr-worker_name, uwr-uri);
  +JK_TRACE_EXIT(l);
  +return JK_TRUE;
  +}
  +}
  +else if (uwr-match_type == MATCH_TYPE_CONTEXT_PATH) {
  +char *suffix_path = NULL;
  +if (strlen(uri)  1

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-12-07 Thread mturk
mturk   2004/12/07 06:30:23

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Add more verbose to debug message
  
  Revision  ChangesPath
  1.35  +3 -2  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- jk_uri_worker_map.c   7 Dec 2004 13:23:14 -   1.34
  +++ jk_uri_worker_map.c   7 Dec 2004 14:30:23 -   1.35
  @@ -570,7 +570,8 @@
   }
   jk_no2slash(uri);
   
  -jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
  +jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s' from %d maps\n,
  +   uri, uw_map-size);
   for (i = 0; i  uw_map-size; i++) {
   uri_worker_record_t *uwr = uw_map-maps[i];
   
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-11-29 Thread mturk
mturk   2004/11/29 08:50:18

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Use the decreasing sort order by context length.
  
  Revision  ChangesPath
  1.31  +2 -2  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- jk_uri_worker_map.c   25 Nov 2004 13:00:43 -  1.30
  +++ jk_uri_worker_map.c   29 Nov 2004 16:50:18 -  1.31
  @@ -87,7 +87,7 @@
   {
   uri_worker_record_t *e1 = *(uri_worker_record_t **)elem1;
   uri_worker_record_t *e2 = *(uri_worker_record_t **)elem2;
  -return ((int)e1-ctxt_len - (int)e2-ctxt_len);
  +return ((int)e2-ctxt_len - (int)e1-ctxt_len);
   }
   
   static void worker_qsort(jk_uri_worker_map_t *uw_map)
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-11-29 Thread mturk
mturk   2004/11/29 09:04:10

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Add logging for uri - context uri match loop.
  
  Revision  ChangesPath
  1.32  +3 -1  
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- jk_uri_worker_map.c   29 Nov 2004 16:50:18 -  1.31
  +++ jk_uri_worker_map.c   29 Nov 2004 17:04:10 -  1.32
  @@ -566,6 +566,8 @@
   if (uwr-ctxt_len  longest_match) {
   continue;   /* can not be a best match anyway */
   }
  +jk_log(l, JK_LOG_DEBUG, Attempting to map context URI '%s'\n, 
uwr-uri);
  +
   if (uwr-match_type == MATCH_TYPE_WILDCHAR_PATH) {
   /* Map is already sorted by ctxt_len */
   if (wildchar_match(uri, uwr-context,
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-11-29 Thread mturk
mturk   2004/11/29 23:30:42

  Modified:jk/native/apache-1.3 mod_jk.c
   jk/native/apache-2.0 mod_jk.c
   jk/native/common jk_uri_worker_map.c
  Log:
  Add JkUnMount for blocking context. This is something from JK2.
  
  Revision  ChangesPath
  1.53  +36 -2 jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c
  
  Index: mod_jk.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- mod_jk.c  12 Nov 2004 18:45:24 -  1.52
  +++ mod_jk.c  30 Nov 2004 07:30:41 -  1.53
  @@ -673,7 +673,7 @@
 jk_module);
   char *old;
   if (context[0] != '/')
  -return Context should start with /;
  +return Mount context should start with /;
   
   /*
* Add the new worker to the alias map.
  @@ -683,6 +683,33 @@
   }
   
   /*
  + * JkUnMount directive handling
  + *
  + * JkUnMount URI(context) worker
  + */
  +
  +static const char *jk_unmount_context(cmd_parms * cmd,
  +  void *dummy,
  +  const char *context,
  +  const char *worker,
  +  const char *maybe_cookie)
  +{
  +server_rec *s = cmd-server;
  +jk_server_conf_t *conf =
  +(jk_server_conf_t *) ap_get_module_config(s-module_config,
  +  jk_module);
  +char *old , *uri;
  +if (context[0] != '/')
  +return Unmount context should start with /;
  +uri = ap_pstrcat(cmd-temp_pool, !, context, NULL);
  +/*
  + * Add the new worker to the alias map.
  + */
  +jk_map_put(conf-uri_to_context, uri, worker, (void **)old);
  +return NULL;
  +}
  +
  +/*
* JkAutoMount directive handling 
*
* JkAutoMount worker [virtualhost]
  @@ -1430,6 +1457,13 @@
A mount point from a context to a servlet-engine worker},
   
   /*
  + * JkUnMount unmounts a url prefix to a worker (the worker need to be
  + * defined in the worker properties file.
  + */
  +{JkUnMount, jk_unmount_context, NULL, RSRC_CONF, TAKE23,
  + A no mount point from a context to a servlet-engine worker},
  +
  + /*
* JkMountCopy specifies if mod_jk should copy the mount points
* from the main server to the virtual servers.
*/
  
  
  
  1.102 +36 -2 jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c
  
  Index: mod_jk.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v
  retrieving revision 1.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- mod_jk.c  12 Nov 2004 18:45:24 -  1.101
  +++ mod_jk.c  30 Nov 2004 07:30:42 -  1.102
  @@ -714,7 +714,7 @@
 jk_module);
   char *old;
   if (context[0] != '/')
  -return Context should start with /;
  +return Mount xontext should start with /;
   
   /*
* Add the new worker to the alias map.
  @@ -723,6 +723,33 @@
   return NULL;
   }
   
  +/*
  + * JkUnMount directive handling
  + *
  + * JkUnMount URI(context) worker
  + */
  +
  +static const char *jk_unmount_context(cmd_parms * cmd,
  +  void *dummy,
  +  const char *context,
  +  const char *worker,
  +  const char *maybe_cookie)
  +{
  +server_rec *s = cmd-server;
  +jk_server_conf_t *conf =
  +(jk_server_conf_t *) ap_get_module_config(s-module_config,
  +  jk_module);
  +char *old , *uri;
  +if (context[0] != '/')
  +return Unmount context should start with /;
  +uri = apr_pstrcat(cmd-temp_pool, !, context, NULL);
  +/*
  + * Add the new worker to the alias map.
  + */
  +jk_map_put(conf-uri_to_context, uri, worker, (void **)old);
  +return NULL;
  +}
  +
   
   /*
* JkAutoMount directive handling
  @@ -1529,6 +1556,13 @@
*/
   AP_INIT_TAKE23(JkMount, jk_mount_context, NULL, RSRC_CONF,
  A mount point from a context to a Tomcat worker),
  +
  +/*
  + * JkUnMount unmounts a url prefix to a worker (the worker need to be
  + * defined in the worker properties file.
  + */
  +AP_INIT_TAKE23(JkUnMount, jk_unmount_context, NULL, RSRC_CONF,
  +   A no mount point from a context to a Tomcat worker),
   
   /*
* JkMountCopy specifies if mod_jk should copy the mount points
  
  
  
  1.33  +67 -10

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-11-25 Thread mturk
mturk   2004/11/25 04:02:24

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  No functional change, just add more logging and proper
  variable declartions.
  
  Revision  ChangesPath
  1.29  +100 -95   
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- jk_uri_worker_map.c   11 Nov 2004 19:11:55 -  1.28
  +++ jk_uri_worker_map.c   25 Nov 2004 12:02:24 -  1.29
  @@ -465,133 +465,138 @@
   char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
   char *uri, jk_logger_t *l)
   {
  +unsigned int i;
  +unsigned int best_match = -1;
  +unsigned int longest_match = 0;
  +char *url_rewrite;
  +
   JK_TRACE_ENTER(l);
  +if (!uw_map || !uri) {
  +JK_LOG_NULL_PARAMS(l);
  +JK_TRACE_EXIT(l);
  +return NULL;
  +}
  +if (*uri != '/') {
  +jk_log(l, JK_LOG_ERROR,
  +uri must start with /\n);
  +JK_TRACE_EXIT(l);
  +return NULL;
  +}
  +url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
  +if (url_rewrite) {
  +*url_rewrite = '\0'; 
  +}
  +jk_no2slash(uri);
   
  -if (uw_map  uri  '/' == uri[0]) {
  -unsigned i;
  -unsigned best_match = -1;
  -unsigned longest_match = 0;
  -char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
  +jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
  +for (i = 0; i  uw_map-size; i++) {
  +uri_worker_record_t *uwr = uw_map-maps[i];
   
  -if (url_rewrite) {
  -*url_rewrite = '\0';
  +if (uwr-ctxt_len  longest_match) {
  +continue;   /* can not be a best match anyway */
   }
  -jk_no2slash(uri);
   
  -jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
  -for (i = 0; i  uw_map-size; i++) {
  -uri_worker_record_t *uwr = uw_map-maps[i];
  -
  -if (uwr-ctxt_len  longest_match) {
  -continue;   /* can not be a best match anyway */
  +if (0 == strncmp(uwr-context, uri, uwr-ctxt_len)) {
  +if (uwr-match_type == MATCH_TYPE_EXACT) {
  +if (strlen(uri) == uwr-ctxt_len) {
  +jk_log(l, JK_LOG_DEBUG,
  +Found an exact match %s - %s\n,
  +uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
  +return uwr-worker_name;
  +}
   }
  -
  -if (0 == strncmp(uwr-context, uri, uwr-ctxt_len)) {
  -if (MATCH_TYPE_EXACT == uwr-match_type) {
  -if (strlen(uri) == uwr-ctxt_len) {
  -jk_log(l, JK_LOG_DEBUG,
  -   Found an exact match %s - %s\n,
  -   uwr-worker_name, uwr-context);
  -JK_TRACE_EXIT(l);
  -return uwr-worker_name;
  -}
  +else if (uwr-match_type == MATCH_TYPE_CONTEXT) {
  +if (uwr-ctxt_len  longest_match) {
  +jk_log(l, JK_LOG_DEBUG,
  +Found a context match %s - %s\n,
  +uwr-worker_name, uwr-context);
  +longest_match = uwr-ctxt_len;
  +best_match = i;
   }
  -else if (MATCH_TYPE_CONTEXT == uwr-match_type) {
  -if (uwr-ctxt_len  longest_match) {
  +}
  +else if (uwr-match_type == MATCH_TYPE_GENERAL_SUFFIX) {
  +int suffix_start = last_index_of(uri, uwr-suffix[0]);
  +if (suffix_start = 0
  + 0 == strcmp(uri + suffix_start, uwr-suffix)) {
  +if (uwr-ctxt_len = longest_match) {
   jk_log(l, JK_LOG_DEBUG,
  -   Found a context match %s - %s\n,
  -   uwr-worker_name, uwr-context);
  +Found a general suffix match %s - *%s\n,
  +uwr-worker_name, uwr-suffix);
   longest_match = uwr-ctxt_len;
   best_match = i;
   }
   }
  -else if (MATCH_TYPE_GENERAL_SUFFIX == uwr-match_type) {
  -int suffix_start = last_index_of(uri, uwr-suffix[0]);
  -if (suffix_start = 0
  - 0 == strcmp(uri + suffix_start, uwr-suffix)) {
  +}
  +else if (uwr-match_type == 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-11-25 Thread mturk
mturk   2004/11/25 05:00:43

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Added wildchar matching for uri's that allows multiple aterikses in
  mount directives. Also added sorting for uri map by context length.
  
  Revision  ChangesPath
  1.30  +91 -4 
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- jk_uri_worker_map.c   25 Nov 2004 12:02:24 -  1.29
  +++ jk_uri_worker_map.c   25 Nov 2004 13:00:43 -  1.30
  @@ -39,6 +39,8 @@
   #define MATCH_TYPE_GENERAL_SUFFIX (3)   /* match all URIs of the form *ext */
   /* match all context path URIs with a path component suffix */
   #define MATCH_TYPE_CONTEXT_PATH (4)
  +/* match multiple wild characters (*) and (?) */
  +#define MATCH_TYPE_WILDCHAR_PATH (5)
   
   struct uri_worker_record
   {
  @@ -81,6 +83,52 @@
   unsigned capacity;
   };
   
  +static int worker_compare(const void *elem1, const void *elem2)
  +{
  +uri_worker_record_t *e1 = *(uri_worker_record_t **)elem1;
  +uri_worker_record_t *e2 = *(uri_worker_record_t **)elem2;
  +return ((int)e1-ctxt_len - (int)e2-ctxt_len);
  +}
  +
  +static void worker_qsort(jk_uri_worker_map_t *uw_map)
  +{
  +
  +   /* Sort remaining args using Quicksort algorithm: */
  +   qsort((void *)uw_map-maps, uw_map-size,
  + sizeof(uri_worker_record_t *), worker_compare );
  +
  +}
  +
  +/* Match = 0, NoMatch = 1, Abort = -1
  + * Based loosely on sections of wildmat.c by Rich Salz
  + */
  +static int wildchar_match(const char *str, const char *exp, int icase)
  +{
  +int x, y;
  +
  +for (x = 0, y = 0; exp[y]; ++y, ++x) {
  +if (!str[x]  exp[y] != '*')
  +return -1;
  +if (exp[y] == '*') {
  +while (exp[++y] == '*');
  +if (!exp[y])
  +return 0;
  +while (str[x]) {
  +int ret;
  +if ((ret = wildchar_match(str[x++], exp[y], icase)) != 1)
  +return ret;
  +}
  +return -1;
  +}
  +else if (exp[y] != '?') {
  +if (icase  tolower(str[x]) != tolower(exp[y]))
  +return 1;
  +else if (!icase  str[x] != exp[y])
  +return 1;
  +}
  +}
  +return (str[x] != '\0');
  +} 
   
   /*
* We are now in a security nightmare, it maybe that somebody sent 
  @@ -235,8 +283,9 @@
   
   if ('/' == uri[0]) {
   char *asterisk = strchr(uri, '*');
  -
  -if (asterisk) {
  +
  +if (asterisk  strchr(asterisk + 1, '*') ||
  +strchr(uri, '?')) {
   uwr-uri = jk_pool_strdup(uw_map-p, uri);
   
   if (!uwr-uri) {
  @@ -245,7 +294,28 @@
   JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
  +/* Lets check if we have multiple
  + * asterixes in the uri like:
  + * /context/ * /user/ *
  + */
  +uwr-worker_name = worker;
  +uwr-context = uri;
  +uwr-suffix = NULL;
  +uwr-match_type = MATCH_TYPE_WILDCHAR_PATH;
  +jk_log(l, JK_LOG_DEBUG,
  +wild chars path rule %s=%s was added\n,
  +uri, worker);
   
  +}
  +else if (asterisk) {
  +uwr-uri = jk_pool_strdup(uw_map-p, uri);
  +
  +if (!uwr-uri) {
  +jk_log(l, JK_LOG_ERROR,
  +   can't alloc uri string\n);
  +JK_TRACE_EXIT(l);
  +return JK_FALSE;
  +}
   /*
* Now, lets check that the pattern is /context/*.suffix
* or /context/*
  @@ -340,7 +410,8 @@
   
   uw_map-maps[uw_map-size] = uwr;
   uw_map-size++;
  -
  +
  +worker_qsort(uw_map);
   JK_TRACE_EXIT(l);
   return JK_TRUE;
   }
  @@ -495,8 +566,24 @@
   if (uwr-ctxt_len  longest_match) {
   continue;   /* can not be a best match anyway */
   }
  +if (uwr-match_type == MATCH_TYPE_WILDCHAR_PATH) {
  +/* Map is already sorted by ctxt_len */
  +if (wildchar_match(uri, uwr-context,
  +#ifdef WIN32
  +   1
  +#else
  +   0
  +#endif
  +   ) == 0) {
   
  -if (0 == strncmp(uwr-context, uri, uwr-ctxt_len)) {
  +jk_log(l, JK_LOG_DEBUG,
  +Found an wildchar match %s - %s\n,
  +uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
  +return 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_worker.c

2004-11-11 Thread mturk
mturk   2004/11/11 11:11:56

  Modified:jk/native/common jk_uri_worker_map.c jk_worker.c
  Log:
  Add new trace macros and clean up some log messages.
  
  Revision  ChangesPath
  1.28  +20 -7 
jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- jk_uri_worker_map.c   11 Nov 2004 09:45:23 -  1.27
  +++ jk_uri_worker_map.c   11 Nov 2004 19:11:55 -  1.28
  @@ -136,13 +136,16 @@
   JK_TRACE_ENTER(l);
   
   if (init_data  uw_map) {
  -return uri_worker_map_open(*uw_map =
  -   (jk_uri_worker_map_t *)
  -   malloc(sizeof(jk_uri_worker_map_t)),
  -   init_data, l);
  +int rc = uri_worker_map_open(*uw_map =
  + (jk_uri_worker_map_t *)
  + malloc(sizeof(jk_uri_worker_map_t)),
  + init_data, l);
  +JK_TRACE_EXIT(l);
  +return rc;
   }
   
   JK_LOG_NULL_PARAMS(l);
  +JK_TRACE_EXIT(l);
   
   return JK_FALSE;
   }
  @@ -161,6 +164,7 @@
   else
   JK_LOG_NULL_PARAMS(l);
   
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -204,9 +208,10 @@
   char *worker;
   
   JK_TRACE_ENTER(l);
  -if (uri_worker_map_realloc(uw_map) == JK_FALSE)
  +if (uri_worker_map_realloc(uw_map) == JK_FALSE) {
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
  -
  +}
   uwr =
   (uri_worker_record_t *) jk_pool_alloc(uw_map-p,
 sizeof(uri_worker_record_t));
  @@ -214,6 +219,7 @@
   if (!uwr) {
   jk_log(l, JK_LOG_ERROR,
  can't alloc map entry\n);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -223,6 +229,7 @@
   if (!uri || !worker) {
   jk_log(l, JK_LOG_ERROR,
  can't alloc uri/worker strings\n);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -235,6 +242,7 @@
   if (!uwr-uri) {
   jk_log(l, JK_LOG_ERROR,
  can't alloc uri string\n);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -326,6 +334,7 @@
   jk_log(l, JK_LOG_ERROR,
  invalid context %s\n,
  uri);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -423,6 +432,7 @@
   }
   
   JK_LOG_NULL_PARAMS(l);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -482,6 +492,7 @@
   jk_log(l, JK_LOG_DEBUG,
  Found an exact match %s - %s\n,
  uwr-worker_name, uwr-context);
  +JK_TRACE_EXIT(l);
   return uwr-worker_name;
   }
   }
  @@ -554,6 +565,7 @@
   }
   
   if (-1 != best_match) {
  +JK_TRACE_EXIT(l);
   return uw_map-maps[best_match]-worker_name;
   }
   else {
  @@ -571,6 +583,7 @@
   jk_log(l, JK_LOG_EMERG,
  Found a security fraud in '%s'\n,
  uri);
  +JK_TRACE_EXIT(l);
   return uw_map-maps[fraud]-worker_name;
   }
   }
  
  
  
  1.23  +16 -7 jakarta-tomcat-connectors/jk/native/common/jk_worker.c
  
  Index: jk_worker.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_worker.c,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- jk_worker.c   11 Nov 2004 09:45:23 -  1.22
  +++ jk_worker.c   11 Nov 2004 19:11:56 -  1.23
  @@ -43,15 +43,18 @@
   JK_TRACE_ENTER(l);
   
   if (!jk_map_alloc(worker_map)) {
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
   if (!jk_get_worker_list(init_data, worker_list, num_of_workers)) {
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
   if (!build_worker_map(init_data, worker_list, num_of_workers, we, l)) {
   close_workers(l);
  +JK_TRACE_EXIT(l);
   return JK_FALSE;
   }
   
  @@ -75,15 +78,15 @@
   
   JK_TRACE_ENTER(l);
   if (!name) {
  -jk_log(l, JK_LOG_ERROR, wc_get_worker_for_name NULL name\n);
  +JK_LOG_NULL_PARAMS(l);
  +JK_TRACE_EXIT(l);
  +return NULL;
   }
   
  -jk_log(l, JK_LOG_DEBUG, Into wc_get_worker_for_name %s\n, name);
  -
   rc 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2004-10-08 Thread mturk
mturk   2004/10/08 00:19:34

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Untabify the source.
  
  Revision  ChangesPath
  1.22  +58 -59jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- jk_uri_worker_map.c   24 Feb 2004 08:45:46 -  1.21
  +++ jk_uri_worker_map.c   8 Oct 2004 07:19:34 -   1.22
  @@ -90,8 +90,7 @@
* .suffix/, or .suffix .
*/
   static int check_security_fraud(jk_uri_worker_map_t *uw_map, 
  -const char *uri, 
  -jk_logger_t *l)
  +const char *uri)
   {
   unsigned i;
   
  @@ -153,10 +152,10 @@
   uri_worker_map_close(*uw_map, l);  
   free(*uw_map);
   *uw_map = NULL;
  - return JK_TRUE;
  +return JK_TRUE;
   }
   else 
  - jk_log(l, JK_LOG_ERROR, 
  +jk_log(l, JK_LOG_ERROR, 
  In jk_uri_worker_map_t::uri_worker_map_free, NULL parameters\n);
   
   return JK_FALSE;
  @@ -257,30 +256,30 @@
   uwr-match_type  = MATCH_TYPE_SUFFIX;
   jk_log(l, JK_LOG_DEBUG,
  Into jk_uri_worker_map_t::uri_worker_map_open, 
  -suffix rule %s.%s=%s was added\n,
  +   suffix rule %s.%s=%s was added\n,
   uri, asterisk + 3, worker); 
  - } else if ('\0' != asterisk[2]) {
  - /* general suffix rule */
  - asterisk[1] = '\0';
  - uwr-worker_name = worker;
  - uwr-context = uri;
  - uwr-suffix  = asterisk + 2;
  - uwr-match_type = MATCH_TYPE_GENERAL_SUFFIX;
  - jk_log(l, JK_LOG_DEBUG,
  -Into jk_uri_worker_map_t::uri_worker_map_open, 
  -general suffix rule %s*%s=%s was added\n,
  -uri, asterisk + 2, worker);
  - } else {
  - /* context based */
  - asterisk[1]  = '\0';
  - uwr-worker_name = worker;
  - uwr-context = uri;
  - uwr-suffix  = NULL;
  - uwr-match_type  = MATCH_TYPE_CONTEXT;
  - jk_log(l, JK_LOG_DEBUG,
  -Into jk_uri_worker_map_t::uri_worker_map_open, 
  -match rule %s=%s was added\n,
  -uri, worker);
  +} else if ('\0' != asterisk[2]) {
  +/* general suffix rule */
  +asterisk[1] = '\0';
  +uwr-worker_name = worker;
  +uwr-context = uri;
  +uwr-suffix  = asterisk + 2;
  +uwr-match_type = MATCH_TYPE_GENERAL_SUFFIX;
  +jk_log(l, JK_LOG_DEBUG,
  +   Into jk_uri_worker_map_t::uri_worker_map_open, 
  +   general suffix rule %s*%s=%s was added\n,
  +   uri, asterisk + 2, worker);
  +} else {
  +/* context based */
  +asterisk[1]  = '\0';
  +uwr-worker_name = worker;
  +uwr-context = uri;
  +uwr-suffix  = NULL;
  +uwr-match_type  = MATCH_TYPE_CONTEXT;
  +jk_log(l, JK_LOG_DEBUG,
  +   Into jk_uri_worker_map_t::uri_worker_map_open, 
  +   match rule %s=%s was added\n,
  +   uri, worker);
   }
   } else {
   /* Something like : JkMount /servlets/exampl* ajp13 */
  @@ -389,7 +388,7 @@
   const char *str_minus_one=str-1;
   const char *s=str+strlen(str);
   while(s!=str_minus_one  ch!=*s) {
  - --s;
  +--s;
   }
   return (s-str);
   }
  @@ -403,7 +402,7 @@
   if(uw_map) {
   jk_close_pool(uw_map-p);
   jk_close_pool(uw_map-tp);
  - return JK_TRUE;
  +return JK_TRUE;
   }
   
   jk_log(l, JK_LOG_ERROR, 
  @@ -469,38 +468,38 @@
   uwr-ctxt_len)) {
   if(MATCH_TYPE_EXACT == uwr-match_type) {
   if(strlen(uri) == uwr-ctxt_len) {
  - jk_log(l,
  -JK_LOG_DEBUG,
  -jk_uri_worker_map_t::map_uri_to_worker, 
  -Found an exact match %s - %s\n,
  -uwr-worker_name,
  -uwr-context );
  +jk_log(l,
  +   JK_LOG_DEBUG,
  +   jk_uri_worker_map_t::map_uri_to_worker, 
  +   Found an exact match %s - %s\n,
  +   uwr-worker_name,
 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2003-08-26 Thread billbarker
billbarker2003/08/25 21:20:04

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Changing the contract for map_uri_to_worker, as discussed on tomcat-dev.
  
  The 'uri' parameter is now considered to be modifiable by this routine.  This fixes 
a multi-threading problem when using Apache2 on high-end machines.
  
  Reported by: Marc Saegesser
  
  Revision  ChangesPath
  1.18  +3 -9  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jk_uri_worker_map.c   6 Aug 2003 12:19:55 -   1.17
  +++ jk_uri_worker_map.c   26 Aug 2003 04:20:04 -  1.18
  @@ -490,14 +490,12 @@
   unsigned i;
   unsigned best_match = -1;
   unsigned longest_match = 0;
  -char *clean_uri = jk_pool_strdup(uw_map-tp,uri);
  -char *url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
  +char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
   
   if(url_rewrite) {
   *url_rewrite = '\0';
   }
  -jk_no2slash(clean_uri);
  -uri = clean_uri;
  +jk_no2slash(uri);
   
   jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
   for(i = 0 ; i  uw_map-size ; i++) {
  @@ -518,7 +516,6 @@
   Found an exact match %s - %s\n,
   uwr-worker_name,
   uwr-context );
  -jk_reset_pool(uw_map-tp);
   return uwr-worker_name;
   }
   } else if(MATCH_TYPE_CONTEXT == uwr-match_type) {
  @@ -594,7 +591,6 @@
   }
   
   if(-1 != best_match) {
  -jk_reset_pool(uw_map-tp);
   return uw_map-maps[best_match]-worker_name;
   } else {
   /*
  @@ -611,10 +607,8 @@
   jk_log(l, JK_LOG_EMERG, 
  In jk_uri_worker_map_t::map_uri_to_worker, found a security 
fraud in '%s'\n,
  uri);
  -jk_reset_pool(uw_map-tp);
   return uw_map-maps[fraud]-worker_name;
   }
  -jk_reset_pool(uw_map-tp);
  }
   } else {
   jk_log(l, JK_LOG_ERROR, 
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2003-08-14 Thread glenn
glenn   2003/08/06 05:19:55

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  minor style cleanup
  
  Revision  ChangesPath
  1.17  +2 -2  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- jk_uri_worker_map.c   28 Jun 2003 02:55:55 -  1.16
  +++ jk_uri_worker_map.c   6 Aug 2003 12:19:55 -   1.17
  @@ -490,7 +490,7 @@
   unsigned i;
   unsigned best_match = -1;
   unsigned longest_match = 0;
  -char * clean_uri = jk_pool_strdup(uw_map-tp,uri);
  +char *clean_uri = jk_pool_strdup(uw_map-tp,uri);
   char *url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
   
   if(url_rewrite) {
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2003-06-30 Thread billbarker
billbarker2003/06/30 22:16:47

  Modified:jk/native/apache-1.3 Tag: coyote_10 mod_jk.c
   jk/native/apache-2.0 Tag: coyote_10 mod_jk.c
   jk/native/common Tag: coyote_10 jk_uri_worker_map.c
jk_uri_worker_map.h
  Log:
  Port patch for // from HEAD branch.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.35.2.1  +6 -4  jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c
  
  Index: mod_jk.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c,v
  retrieving revision 1.35
  retrieving revision 1.35.2.1
  diff -u -r1.35 -r1.35.2.1
  --- mod_jk.c  7 Jan 2003 01:27:11 -   1.35
  +++ mod_jk.c  1 Jul 2003 05:16:46 -   1.35.2.1
  @@ -1842,15 +1842,17 @@
   r-handler = ap_pstrdup(r-pool, JK_HANDLER);
   ap_table_setn(r-notes, JK_WORKER_ID, worker);
   } else if(conf-alias_dir != NULL) {
  +char *clean_uri = ap_pstrdup(r-pool, r-uri);
  +ap_no2slash(clean_uri);
   /* Automatically map uri to a context static file */
   jk_log(l, JK_LOG_DEBUG,
   mod_jk::jk_translate, check alias_dir: %s\n,conf-alias_dir);
  -if (strlen(r-uri)  1) {
  +if (strlen(clean_uri)  1) {
   /* Get the context directory name */
   char *context_dir = NULL;
   char *context_path = NULL;
   char *child_dir = NULL;
  -char *index = r-uri;
  +char *index = clean_uri;
   char *suffix = strchr(index+1,'/');
   if( suffix != NULL ) {
   int size = suffix - index;
  @@ -1887,7 +1889,7 @@
   if( context_path != NULL ) {
   DIR *dir = ap_popendir(r-pool,context_path);
   if( dir != NULL ) {
  -char *escurl = ap_os_escape_path(r-pool, r-uri, 1);
  +char *escurl = ap_os_escape_path(r-pool, clean_uri, 1);
   char *ret = 
ap_pstrcat(r-pool,conf-alias_dir,escurl,NULL);
   ap_pclosedir(r-pool,dir);
   /* Add code to verify real path ap_os_canonical_name */
  
  
  
  No   revision
  
  
  No   revision
  
  
  1.65.2.1  +6 -4  jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c
  
  Index: mod_jk.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v
  retrieving revision 1.65
  retrieving revision 1.65.2.1
  diff -u -r1.65 -r1.65.2.1
  --- mod_jk.c  7 Jan 2003 01:27:11 -   1.65
  +++ mod_jk.c  1 Jul 2003 05:16:47 -   1.65.2.1
  @@ -2134,16 +2134,18 @@
   
   return OK;
   } else if(conf-alias_dir != NULL) {
  +char *clean_uri = ap_pstrdup(r-pool, r-uri);
  +ap_no2slash(clean_uri);
   /* Automatically map uri to a context static file */
   jk_log(conf-log, JK_LOG_DEBUG,
   mod_jk::jk_translate, check alias_dir: %s\n,
   conf-alias_dir);
  -if (strlen(r-uri)  1) {
  +if (strlen(clean_uri)  1) {
   /* Get the context directory name */
   char *context_dir = NULL;
   char *context_path = NULL;
   char *child_dir = NULL;
  -char *index = r-uri;
  +char *index = clean_uri;
   char *suffix = strchr(index+1,'/');
   if( suffix != NULL ) {
   int size = suffix - index;
  @@ -2181,7 +2183,7 @@
   finfo.filetype = APR_NOFILE;
   apr_stat(finfo,context_path,APR_FINFO_TYPE,r-pool);
   if( finfo.filetype == APR_DIR ) {
  -char *escurl = ap_os_escape_path(r-pool, r-uri, 1);
  +char *escurl = ap_os_escape_path(r-pool, clean_uri, 1);
   char *ret = 
ap_pstrcat(r-pool,conf-alias_dir,escurl,NULL);
   /* Add code to verify real path ap_os_canonical_name */
   if( ret != NULL ) {
  
  
  
  No   revision
  
  
  No   revision
  
  
  1.14.2.1  +31 -7 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: 

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2003-06-27 Thread billbarker
billbarker2003/06/27 19:55:55

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Reverting to the httpd symbol.
  
  Having thought about this, I think that supporting UNC paths in mod_jk doesn't have 
a valid use case, and is only likely to cause problems on Windows.  Since this part of 
the code doesn't include the httpd headers, the symbol is always undefined unless 
someone explicitly adds it to their build.
  
  Revision  ChangesPath
  1.16  +2 -2  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- jk_uri_worker_map.c   27 Jun 2003 02:54:17 -  1.15
  +++ jk_uri_worker_map.c   28 Jun 2003 02:55:55 -  1.16
  @@ -459,7 +459,7 @@
   
   s = d = name;
   
  -#if defined(WIN32)
  +#if defined(HAVE_UNC_PATHS) 
   /* Check for UNC names.  Leave leading two slashes. */
   if (s[0] == '/'  s[1] == '/')
   *d++ = *s++;
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2003-06-26 Thread billbarker
billbarker2003/06/26 19:54:18

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Fix problem with URLs that contain //.
  
  This is essentially what Apache/httpd does in location_walk.
  
  Reported by: Palle Girgensohn [EMAIL PROTECTED]
  
  Revision  ChangesPath
  1.15  +32 -7 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- jk_uri_worker_map.c   21 Apr 2002 22:57:11 -  1.14
  +++ jk_uri_worker_map.c   27 Jun 2003 02:54:17 -  1.15
  @@ -453,6 +453,32 @@
   return JK_FALSE;
   }
   
  +void jk_no2slash(char *name)
  +{
  +char *d, *s;
  +
  +s = d = name;
  +
  +#if defined(WIN32)
  +/* Check for UNC names.  Leave leading two slashes. */
  +if (s[0] == '/'  s[1] == '/')
  +*d++ = *s++;
  +#endif
  +
  +while (*s) {
  +if ((*d++ = *s) == '/') {
  +do {
  +++s;
  +} while (*s == '/');
  +}
  +else {
  +++s;
  +}
  +}
  +*d = '\0';
  +}
  +
  +
   char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
   const char *uri,
   jk_logger_t *l)
  @@ -464,17 +490,16 @@
   unsigned i;
   unsigned best_match = -1;
   unsigned longest_match = 0;
  -char * clean_uri = NULL;
  -char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
  +char * clean_uri = jk_pool_strdup(uw_map-tp,uri);
  +char *url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
   
   if(url_rewrite) {
  -clean_uri = jk_pool_strdup(uw_map-tp,uri);
  -url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
   *url_rewrite = '\0';
  -uri = clean_uri;
   }
  +jk_no2slash(clean_uri);
  +uri = clean_uri;
   
  - jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
  +jk_log(l, JK_LOG_DEBUG, Attempting to map URI '%s'\n, uri);
   for(i = 0 ; i  uw_map-size ; i++) {
   uri_worker_record_t *uwr = uw_map-maps[i];
   
  
  
  
  1.6   +3 -1  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h
  
  Index: jk_uri_worker_map.h
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_uri_worker_map.h   4 Dec 2001 19:44:23 -   1.5
  +++ jk_uri_worker_map.h   27 Jun 2003 02:54:17 -  1.6
  @@ -95,6 +95,8 @@
   int uri_worker_map_close(jk_uri_worker_map_t *uw_map,
jk_logger_t *l);
   
  +void jk_no2slash(char *name);
  +
   char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
   const char *uri,
   jk_logger_t *l);
  
  
  

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



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2001-12-06 Thread larryi

larryi  01/12/06 16:57:16

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Restore patch supplied by Michael Jennings,
  
  Revision  ChangesPath
  1.13  +57 -15jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- jk_uri_worker_map.c   2001/12/04 19:44:23 1.12
  +++ jk_uri_worker_map.c   2001/12/07 00:57:16 1.13
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.12 $   *
  + * Version: $Revision: 1.13 $   *
***/
   
   #include jk_pool.h
  @@ -77,6 +77,7 @@
   #define MATCH_TYPE_EXACT(0)
   #define MATCH_TYPE_CONTEXT  (1)
   #define MATCH_TYPE_SUFFIX   (2)
  +#define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */
   
   struct uri_worker_record {
   /* Original uri for logging */
  @@ -283,18 +284,31 @@
   uwr-suffix  = asterisk + 3;
   uwr-match_type  = MATCH_TYPE_SUFFIX;
   jk_log(l, JK_LOG_DEBUG,
  -   Into jk_uri_worker_map_t::uri_worker_map_open, suffix 
rule %s.%s=%s was added\n,
  -uri, asterisk + 3, worker);
  -} else {
  -/* context based */
  -asterisk[1]  = '\0';
  -uwr-worker_name = worker;
  -uwr-context = uri;
  -uwr-suffix  = NULL;
  -uwr-match_type  = MATCH_TYPE_CONTEXT;
  -jk_log(l, JK_LOG_DEBUG,
  -  Into jk_uri_worker_map_t::uri_worker_map_open, match 
rule %s=%s was added\n,
  -   uri, worker);
  +   Into jk_uri_worker_map_t::uri_worker_map_open, 
  +suffix rule %s.%s=%s was added\n,
  +uri, asterisk + 3, worker); 
  + } else if ('\0' != asterisk[2]) {
  + /* general suffix rule */
  + asterisk[1] = '\0';
  + uwr-worker_name = worker;
  + uwr-context = uri;
  + uwr-suffix  = asterisk + 2;
  + uwr-match_type = MATCH_TYPE_GENERAL_SUFFIX;
  + jk_log(l, JK_LOG_DEBUG,
  +Into jk_uri_worker_map_t::uri_worker_map_open, 
  +general suffix rule %s*%s=%s was added\n,
  +uri, asterisk + 2, worker);
  + } else {
  + /* context based */
  + asterisk[1]  = '\0';
  + uwr-worker_name = worker;
  + uwr-context = uri;
  + uwr-suffix  = NULL;
  + uwr-match_type  = MATCH_TYPE_CONTEXT;
  + jk_log(l, JK_LOG_DEBUG,
  +Into jk_uri_worker_map_t::uri_worker_map_open, 
  +match rule %s=%s was added\n,
  +uri, worker);
   }
   } else {
   /* Something like : JkMount /servlets/exampl* ajp13 */
  @@ -396,6 +410,18 @@
   return rc;
   }
   
  +/* returns the index of the last occurrence of the 'ch' character
  +   if ch=='\0' returns the length of the string str  */
  +int last_index_of(const char *str,char ch)
  +{
  +const char *str_minus_one=str-1;
  +const char *s=str+strlen(str);
  +while(s!=str_minus_one  ch!=*s) {
  + --s;
  +}
  +return (s-str);
  +}
  +
   int uri_worker_map_close(jk_uri_worker_map_t *uw_map,
jk_logger_t *l)
   {
  @@ -450,7 +476,8 @@
   if(strlen(uri) == uwr-ctxt_len) {
jk_log(l,
   JK_LOG_DEBUG,
  -jk_uri_worker_map_t::map_uri_to_worker, Found an exact 
match %s - %s\n,
  +jk_uri_worker_map_t::map_uri_to_worker, 
  +Found an exact match %s - %s\n,
   uwr-worker_name,
   uwr-context );
   jk_reset_pool(uw_map-tp);
  @@ -460,11 +487,26 @@
   if(uwr-ctxt_len  longest_match) {
jk_log(l,
   JK_LOG_DEBUG,
  -  

cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2001-11-16 Thread costin

costin  01/11/16 14:37:13

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Get the number of mappings in uri_worker_map, quick exit if none.
  
  ( it is possible to configure mod_jk using setHandler, we don't want extra overhead )
  
  Revision  ChangesPath
  1.11  +10 -1 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- jk_uri_worker_map.c   2001/11/07 21:54:45 1.10
  +++ jk_uri_worker_map.c   2001/11/16 22:37:13 1.11
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.10 $   *
  + * Version: $Revision: 1.11 $   *
***/
   
   #include jk_pool.h
  @@ -118,7 +118,13 @@
   unsignedcapacity;
   };
   
  +int uri_worker_map_size(jk_uri_worker_map_t *uw_map ) {
  +if( uw_map == NULL ) 
  + return 0;
  +return uw_map-size;
  +} 
   
  +
   /*
* We are now in a security nightmare, it maybe that somebody sent 
* us a uri that looks like /top-secret.jsp. and the web server will 
  @@ -444,6 +450,9 @@
   const char *uri,
   jk_logger_t *l)
   {
  +if( uri_worker_map_size( uw_map ) = 0 )
  + return NULL;
  +
   jk_log(l, JK_LOG_DEBUG, 
  Into jk_uri_worker_map_t::map_uri_to_worker\n);
   
  
  
  
  1.4   +4 -1  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h
  
  Index: jk_uri_worker_map.h
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_uri_worker_map.h   2001/07/02 21:13:00 1.3
  +++ jk_uri_worker_map.h   2001/11/16 22:37:13 1.4
  @@ -58,7 +58,7 @@
   /***
* Description: URI to worker mapper header file   *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.3 $   *
  + * Version: $Revision: 1.4 $   *
***/
   
   #ifndef JK_URI_WORKER_MAP_H
  @@ -91,6 +91,9 @@
  char *puri,
  char *pworker,
  jk_logger_t *l);
  +
  +int uri_worker_map_size(jk_uri_worker_map_t *uw_map );
  +
   
   int uri_worker_map_close(jk_uri_worker_map_t *uw_map,
jk_logger_t *l);
  
  
  

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




cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2001-09-27 Thread hgomez

hgomez  01/09/27 03:42:26

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  BackPort security fix from TC 3.3 to J-T-C
  
  Revision  ChangesPath
  1.8   +5 -3  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jk_uri_worker_map.c   2001/08/06 17:31:45 1.7
  +++ jk_uri_worker_map.c   2001/09/27 10:42:26 1.8
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.7 $   *
  + * Version: $Revision: 1.8 $   *
***/
   
   #include jk_pool.h
  @@ -413,11 +413,11 @@
   unsigned i;
   unsigned best_match = -1;
   unsigned longest_match = 0;
  -char clean_uri[4096];
  +char clean_uri = NULL;
   char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
   
   if(url_rewrite) {
  -strcpy(clean_uri, uri);
  +clean_uri = strdup(uri);
   url_rewrite = strstr(clean_uri, JK_PATH_SESSION_IDENTIFIER);
   *url_rewrite = '\0';
   uri = clean_uri;
  @@ -485,6 +485,7 @@
   }
   
   if(-1 != best_match) {
  +free(clean_uri);
   return uw_map-maps[best_match]-worker_name;
   } else {
   /*
  @@ -501,6 +502,7 @@
   jk_log(l, JK_LOG_EMERG, 
  In jk_uri_worker_map_t::map_uri_to_worker, found a security 
fraud in '%s'\n,
  uri);
  +free(clean_uri);
   return uw_map-maps[fraud]-worker_name;
   }
  }
  
  
  



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2001-08-06 Thread jfclere

jfclere 01/08/06 02:46:56

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Fix the comment!
  
  Revision  ChangesPath
  1.6   +2 -2  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- jk_uri_worker_map.c   2001/08/03 15:00:53 1.5
  +++ jk_uri_worker_map.c   2001/08/06 09:46:56 1.6
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.5 $   *
  + * Version: $Revision: 1.6 $   *
***/
   
   #include jk_pool.h
  @@ -309,7 +309,7 @@
   /*
* JFC: please check...
* Not sure what to do, but I try to prevent problems.
  - * I have fixed jk_mount_context() in apache*/mod_jk.c so we should
  + * I have fixed jk_mount_context() in apaches/mod_jk.c so we should
* not arrive here when using Apache.
*/
   jk_log(l, JK_LOG_ERROR,
  
  
  



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c

2001-08-06 Thread jfclere

jfclere 01/08/06 10:31:45

  Modified:jk/native/common jk_uri_worker_map.c
  Log:
  Arrange JkMount for entries like:
  JkMount  /examples/servlet/HelloWorldExample example
  Note that things like /examples/servlet/Hello* example are not working...
  
  Revision  ChangesPath
  1.7   +13 -2 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- jk_uri_worker_map.c   2001/08/06 09:46:56 1.6
  +++ jk_uri_worker_map.c   2001/08/06 17:31:45 1.7
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.6 $   *
  + * Version: $Revision: 1.7 $   *
***/
   
   #include jk_pool.h
  @@ -293,6 +293,7 @@
  uri, worker);
   }
   } else {
  +/* Something like : JkMount /servlets/exampl* ajp13 */
   uwr-uri = uri;
   uwr-worker_name = worker;
   uwr-context = uri;
  @@ -303,8 +304,18 @@
   uri, worker);
   }
   
  -uwr-ctxt_len = strlen(uwr-context);
  +} else {
  +/* Something like:  JkMount /login/j_security_check ajp13 */
  +uwr-uri = uri;
  +uwr-worker_name = worker;
  +uwr-context = uri;
  +uwr-suffix  = NULL;
  +uwr-match_type  = MATCH_TYPE_EXACT;
  +jk_log(l, JK_LOG_DEBUG,
  +   Into jk_uri_worker_map_t::uri_worker_map_open, exact rule %s=%s 
was added\n,
  +uri, worker);
   }
  +uwr-ctxt_len = strlen(uwr-context);
   } else {
   /*
* JFC: please check...
  
  
  



cvs commit: jakarta-tomcat-connectors/jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h

2001-07-02 Thread hgomez

hgomez  01/07/02 14:13:04

  Modified:jk/native/common jk_uri_worker_map.c jk_uri_worker_map.h
  Log:
  Little rework of uri mappings.
  Will allow dynamic add of URI/WORKERs
  
  Revision  ChangesPath
  1.4   +176 -133  jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c
  
  Index: jk_uri_worker_map.c
  ===
  RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- jk_uri_worker_map.c   2001/06/18 14:16:09 1.3
  +++ jk_uri_worker_map.c   2001/07/02 21:12:59 1.4
  @@ -67,7 +67,7 @@
* servlet container.  *
* *
* Author:  Gal Shachor [EMAIL PROTECTED]   *
  - * Version: $Revision: 1.3 $   *
  + * Version: $Revision: 1.4 $   *
***/
   
   #include jk_pool.h
  @@ -99,11 +99,18 @@
   typedef struct uri_worker_record uri_worker_record_t;
   
   struct jk_uri_worker_map {
  -jk_pool_t p;
  -jk_pool_atom_t buf[SMALL_POOL_SIZE];
  +/* Memory Pool */
  +jk_pool_t   p;
  +jk_pool_atom_t  buf[SMALL_POOL_SIZE];
   
  -uri_worker_record_t *maps;
  -unsigned size;
  +/* map URI-WORKER */
  +uri_worker_record_t **maps;
  +
  +/* Map Number */
  +unsignedsize;
  +
  +/* Map Capacity */
  +unsignedcapacity;
   };
   
   
  @@ -123,19 +130,19 @@
   unsigned i;
   
   for(i = 0 ; i  uw_map-size ; i++) {
  -if(MATCH_TYPE_SUFFIX == uw_map-maps[i].match_type) {
  +if(MATCH_TYPE_SUFFIX == uw_map-maps[i]-match_type) {
   char *suffix_start;
  -for(suffix_start = strstr(uri, uw_map-maps[i].suffix) ;
  +for(suffix_start = strstr(uri, uw_map-maps[i]-suffix) ;
   suffix_start ;
  -suffix_start = strstr(suffix_start + 1, uw_map-maps[i].suffix)) {
  +suffix_start = strstr(suffix_start + 1, uw_map-maps[i]-suffix)) {
   
   if('.' != *(suffix_start - 1)) {
   continue;
   } else {
  -char *after_suffix = suffix_start + 
strlen(uw_map-maps[i].suffix);
  +char *after_suffix = suffix_start + 
strlen(uw_map-maps[i]-suffix);
   
   if((('.' == *after_suffix) || ('/' == *after_suffix) || (' ' == 
*after_suffix)) 
  -   (0 == strncmp(uw_map-maps[i].context, uri, 
uw_map-maps[i].ctxt_len))) {
  +   (0 == strncmp(uw_map-maps[i]-context, uri, 
uw_map-maps[i]-ctxt_len))) {
   /* 
* Security violation !!!
* this is a fraud.
  @@ -189,135 +196,170 @@
   return JK_FALSE;
   }
   
  +/*
  + * Ensure there will be memory in context info to store Context Bases
  + */
  +
  +#define UW_INC_SIZE 4   /* 4 URI-WORKER STEP */
  +
  +static int uri_worker_map_realloc(jk_uri_worker_map_t *uw_map)
  +{
  +if (uw_map-size == uw_map-capacity) {
  +uri_worker_record_t **uwr;
  +int  capacity = uw_map-capacity + UW_INC_SIZE;
  +
  +uwr = (uri_worker_record_t **)jk_pool_alloc(uw_map-p, 
sizeof(uri_worker_record_t *) * capacity);
  +
  +if (! uwr)
  +return JK_FALSE;
  +
  +if (uw_map-capacity  uw_map-maps)
  +memcpy(uwr, uw_map-maps, sizeof(uri_worker_record_t *) * 
uw_map-capacity);
  +
  +uw_map-maps = uwr;
  +uw_map-capacity = capacity;
  +}
  +
  +return JK_TRUE;
  +}
  +
  +
  +int uri_worker_map_add(jk_uri_worker_map_t *uw_map, 
  +   char *puri, 
  +   char *pworker,
  +   jk_logger_t *l)
  +{
  +uri_worker_record_t *uwr;
  +char*uri;
  +char*worker;
  +
  +if (uri_worker_map_realloc(uw_map) == JK_FALSE)
  +return JK_FALSE;
  +
  +uwr = (uri_worker_record_t *)jk_pool_alloc(uw_map-p, 
sizeof(uri_worker_record_t));
  +
  +if (! uwr) {
  +jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_add, can't 
alloc map entry\n);
  +return JK_FALSE;
  +}
  +
  +uri = jk_pool_strdup(uw_map-p, puri);
  +worker = jk_pool_strdup(uw_map-p, pworker);
  +
  +if (!uri || ! worker) {
  +jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_add, can't 
alloc uri/worker strings\n);
  +return JK_FALSE;
  +}
  +
  +if ('/' == uri[0]) {
  +char *asterisk = strchr(uri, '*');
  +
  +if (asterisk) {