patch to jk_uri_worker_map.c
Hi, I was looking at jk_uri_worker_map.c because my context url maps were not working like expected. I also saw a bunch of posts on the web about this problem. I looked at the source code and I am submitting a patch to this in a different mail. Basically, I am just extracting the sub string before you do the comparison, so that the match will work. For example the current code will not work with this If the JkMount is JkMount /servlet/* worker_name then a url like http://www.xxx.yyy.zzz/myproject/servlet/MyServlet will not match. Only urls like http://www.xxx.yyy.zzz/servlet/MyServlet will match. My patch will allow urls like the first one to work. I am searching the uri string for the uwr-context instead of doing an exact strncmp. I have tested this and it works on my setup. I am sending my patch in the next e-mail. Please let me know if you guys think I should change anything. Also as you guys can probably tell this is my first patch I am submitting to the list :-). What's the right way to get this patch in the source tree. I tried sending messages to [EMAIL PROTECTED] and [EMAIL PROTECTED] and nothing useful came out of it. If this was a planned feature I apologise. Thank you, Aravind Gottipati -- Let me put it this way: today is going to be a learning experience -- Anonymous (seen on slashdot) -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
[PATCH] to jk_uri_worker_map.c (fix url matching for context matches)
Index: jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v retrieving revision 1.13 diff -u -r1.13 jk_uri_worker_map.c --- jk_uri_worker_map.c 7 Dec 2001 00:57:16 - 1.13 +++ jk_uri_worker_map.c 22 Apr 2002 01:27:15 - @@ -469,9 +469,7 @@ continue; /* can not be a best match anyway */ } -if(0 == strncmp(uwr-context, -uri, -uwr-ctxt_len)) { +if (strstr(uri, uwr-context)) { if(MATCH_TYPE_EXACT == uwr-match_type) { if(strlen(uri) == uwr-ctxt_len) { jk_log(l, -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
patch to jk_uri_worker_map.c ApacheConfig.java
Here are my diffs to allow mod_jk to understand URIs of the form /context/*whatever and for ApacheConfig to write entries to mod_jk.conf-auto of the form /context/*j_security_check Combined, these patches should allow form-based authentication to work with Apache+tomcat If anyone sees any glaring problems with the modifications, please let me know and I'll try and fix it. -Mike Jennings - Original Message - From: Michael Jennings [EMAIL PROTECTED] To: Tomcat Developers List [EMAIL PROTECTED] Sent: Friday, November 02, 2001 6:38 PM Subject: Re: patch to jk_uri_worker_map.c - slightly more sophisticated string matching Hi Costin Larry, I'll apply my change to jakarta-tomcat-connectors then send the diff as an attachment. -Mike - Original Message - From: [EMAIL PROTECTED] To: Tomcat Developers List [EMAIL PROTECTED] Sent: Friday, November 02, 2001 12:08 PM Subject: Re: patch to jk_uri_worker_map.c - slightly more sophisticated string matching Mike, Thanks for the patch and your interest. One small problem: the development of jk moved to jakarta-tomcat-connectors. We should do only 'major' bug fixes in j-t/src/native. Of course, all rules have exceptions - but it is extremely painfull to merge and track 2 codebases. Costin On Fri, 2 Nov 2001, Michael Jennings wrote: If anyone sees any glaring problems with the following modification to mod_jk please let me know. -Mike Jennings Index: jakarta-tomcat/src/native/jk/jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_uri_worker_map.c,v retrieving revision 1.3.2.1 diff -r1.3.2.1 jk_uri_worker_map.c 75,77c75,78 #define MATCH_TYPE_EXACT(0) #define MATCH_TYPE_CONTEXT (1) #define MATCH_TYPE_SUFFIX (2) --- #define MATCH_TYPE_EXACT(0) /* match an exact pattern */ #define MATCH_TYPE_CONTEXT (1) /* match all URIs in a given context */ #define MATCH_TYPE_SUFFIX (2) /* match all URIs of the form *.ext */ #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */ 231c232 --- 236,237c237,238 jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); --- jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); 244,245c245,246 * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' --- * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' 247c248,252 asterisk--; --- asterisk--; /* point to char before asterisk */ /* asterisk[0]='/' asterisk[1]='*' asterisk[2]='.' or asterisk[2]='\0' or asterisk[2]!='\0' */ 248a254 asterisk[1] = '\0'; /* terminate the uri pattern at the asterisk */ 251c257 asterisk[1] = asterisk[2] = '\0'; --- asterisk[2] = '\0'; 252a259,260 /* uri-pattern will now contain context only since asterisk[1]='\0' */ 256,258c264,276 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); --- 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); j++; } else if ('\0' != asterisk[2]) { /* general suffix rule */ uw_map-maps[j].worker_name = worker; uw_map-maps[j].context = uri; uw_map-maps[j].suffix = asterisk + 2; uw_map-maps[j].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
patch to jk_uri_worker_map.c - slightly more sophisticated string matching
If anyone sees any glaring problems with the following modification to mod_jk please let me know. -Mike Jennings Index: jakarta-tomcat/src/native/jk/jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_uri_worker_map.c,v retrieving revision 1.3.2.1 diff -r1.3.2.1 jk_uri_worker_map.c 75,77c75,78 #define MATCH_TYPE_EXACT(0) #define MATCH_TYPE_CONTEXT (1) #define MATCH_TYPE_SUFFIX (2) --- #define MATCH_TYPE_EXACT(0) /* match an exact pattern */ #define MATCH_TYPE_CONTEXT (1) /* match all URIs in a given context */ #define MATCH_TYPE_SUFFIX (2) /* match all URIs of the form *.ext */ #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */ 231c232 --- 236,237c237,238 jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); --- jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); 244,245c245,246 * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' --- * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' 247c248,252 asterisk--; --- asterisk--; /* point to char before asterisk */ /* asterisk[0]='/' asterisk[1]='*' asterisk[2]='.' or asterisk[2]='\0' or asterisk[2]!='\0' */ 248a254 asterisk[1] = '\0'; /* terminate the uri pattern at the asterisk */ 251c257 asterisk[1] = asterisk[2] = '\0'; --- asterisk[2] = '\0'; 252a259,260 /* uri-pattern will now contain context only since asterisk[1]='\0' */ 256,258c264,276 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); --- 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); j++; } else if ('\0' != asterisk[2]) { /* general suffix rule */ uw_map-maps[j].worker_name = worker; uw_map-maps[j].context = uri; uw_map-maps[j].suffix = asterisk + 2; uw_map-maps[j].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); 260c278,279 } else { --- } else { 262d280 asterisk[1] = '\0'; 267,269c285,287 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); --- 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); 273c291 /* not leagal !!! */ --- /* not legal !!! */ 275c293 jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a leagal rule\n, --- jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a legal rule\n, 321a340,353 /* 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); } 379a412,419 } else if(MATCH_TYPE_GENERAL_SUFFIX == uw_map-maps[i].match_type) { int suffix_start=last_index_of(uri,uw_map-maps[i].suffix[0]); if (suffix_start=0 0==strcmp(uri+suffix_start,uw_map-maps[i].suffix)) {
RE: patch to jk_uri_worker_map.c - slightly more sophisticated string matching
Hi Michael, FYI: Embedding the patch in the e-mail usually allows linewrap to render the patch useless as far as applying it to a file. It also makes it hard to read. It is better to send the patch as an attachment. Larry -Original Message- From: Michael Jennings [mailto:[EMAIL PROTECTED]] Sent: Friday, November 02, 2001 2:13 PM To: Tomcat Developers List Subject: patch to jk_uri_worker_map.c - slightly more sophisticated string matching If anyone sees any glaring problems with the following modification to mod_jk please let me know. -Mike Jennings Index: jakarta-tomcat/src/native/jk/jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_uri_work er_map.c,v retrieving revision 1.3.2.1 diff -r1.3.2.1 jk_uri_worker_map.c 75,77c75,78 #define MATCH_TYPE_EXACT(0) #define MATCH_TYPE_CONTEXT (1) #define MATCH_TYPE_SUFFIX (2) --- #define MATCH_TYPE_EXACT(0) /* match an exact pattern */ #define MATCH_TYPE_CONTEXT (1) /* match all URIs in a given context */ #define MATCH_TYPE_SUFFIX (2) /* match all URIs of the form *.ext */ #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */ 231c232 --- 236,237c237,238 jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); --- jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); 244,245c245,246 * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' --- * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' 247c248,252 asterisk--; --- asterisk--; /* point to char before asterisk */ /* asterisk[0]='/' asterisk[1]='*' asterisk[2]='.' or asterisk[2]='\0' or asterisk[2]!='\0' */ 248a254 asterisk[1] = '\0'; /* terminate the uri pattern at the asterisk */ 251c257 asterisk[1] = asterisk[2] = '\0'; --- asterisk[2] = '\0'; 252a259,260 /* uri-pattern will now contain context only since asterisk[1]='\0' */ 256,258c264,276 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); --- 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); j++; } else if ('\0' != asterisk[2]) { /* general suffix rule */ uw_map-maps[j].worker_name = worker; uw_map-maps[j].context = uri; uw_map-maps[j].suffix = asterisk + 2; uw_map-maps[j].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); 260c278,279 } else { --- } else { 262d280 asterisk[1] = '\0'; 267,269c285,287 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); --- 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); 273c291 /* not leagal !!! */ --- /* not legal !!! */ 275c293 jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a leagal rule\n, --- jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a legal rule\n, 321a340,353
Re: patch to jk_uri_worker_map.c - slightly more sophisticatedstring matching
Mike, Thanks for the patch and your interest. One small problem: the development of jk moved to jakarta-tomcat-connectors. We should do only 'major' bug fixes in j-t/src/native. Of course, all rules have exceptions - but it is extremely painfull to merge and track 2 codebases. Costin On Fri, 2 Nov 2001, Michael Jennings wrote: If anyone sees any glaring problems with the following modification to mod_jk please let me know. -Mike Jennings Index: jakarta-tomcat/src/native/jk/jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_uri_worker_map.c,v retrieving revision 1.3.2.1 diff -r1.3.2.1 jk_uri_worker_map.c 75,77c75,78 #define MATCH_TYPE_EXACT(0) #define MATCH_TYPE_CONTEXT (1) #define MATCH_TYPE_SUFFIX (2) --- #define MATCH_TYPE_EXACT(0) /* match an exact pattern */ #define MATCH_TYPE_CONTEXT (1) /* match all URIs in a given context */ #define MATCH_TYPE_SUFFIX (2) /* match all URIs of the form *.ext */ #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */ 231c232 --- 236,237c237,238 jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); --- jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); 244,245c245,246 * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' --- * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' 247c248,252 asterisk--; --- asterisk--; /* point to char before asterisk */ /* asterisk[0]='/' asterisk[1]='*' asterisk[2]='.' or asterisk[2]='\0' or asterisk[2]!='\0' */ 248a254 asterisk[1] = '\0'; /* terminate the uri pattern at the asterisk */ 251c257 asterisk[1] = asterisk[2] = '\0'; --- asterisk[2] = '\0'; 252a259,260 /* uri-pattern will now contain context only since asterisk[1]='\0' */ 256,258c264,276 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); --- 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); j++; } else if ('\0' != asterisk[2]) { /* general suffix rule */ uw_map-maps[j].worker_name = worker; uw_map-maps[j].context = uri; uw_map-maps[j].suffix = asterisk + 2; uw_map-maps[j].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); 260c278,279 } else { --- } else { 262d280 asterisk[1] = '\0'; 267,269c285,287 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); --- 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); 273c291 /* not leagal !!! */ --- /* not legal !!! */ 275c293 jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a leagal rule\n, --- jk_uri_worker_map_t::uri_worker_map_open, [%s=%s] not a legal rule\n, 321a340,353 /* 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) {
Re: patch to jk_uri_worker_map.c - slightly more sophisticated string matching
Hi Costin Larry, I'll apply my change to jakarta-tomcat-connectors then send the diff as an attachment. -Mike - Original Message - From: [EMAIL PROTECTED] To: Tomcat Developers List [EMAIL PROTECTED] Sent: Friday, November 02, 2001 12:08 PM Subject: Re: patch to jk_uri_worker_map.c - slightly more sophisticated string matching Mike, Thanks for the patch and your interest. One small problem: the development of jk moved to jakarta-tomcat-connectors. We should do only 'major' bug fixes in j-t/src/native. Of course, all rules have exceptions - but it is extremely painfull to merge and track 2 codebases. Costin On Fri, 2 Nov 2001, Michael Jennings wrote: If anyone sees any glaring problems with the following modification to mod_jk please let me know. -Mike Jennings Index: jakarta-tomcat/src/native/jk/jk_uri_worker_map.c === RCS file: /home/cvspublic/jakarta-tomcat/src/native/jk/Attic/jk_uri_worker_map.c,v retrieving revision 1.3.2.1 diff -r1.3.2.1 jk_uri_worker_map.c 75,77c75,78 #define MATCH_TYPE_EXACT(0) #define MATCH_TYPE_CONTEXT (1) #define MATCH_TYPE_SUFFIX (2) --- #define MATCH_TYPE_EXACT(0) /* match an exact pattern */ #define MATCH_TYPE_CONTEXT (1) /* match all URIs in a given context */ #define MATCH_TYPE_SUFFIX (2) /* match all URIs of the form *.ext */ #define MATCH_TYPE_GENERAL_SUFFIX (3) /* match all URIs of the form *ext */ 231c232 --- 236,237c237,238 jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); --- jk_log(l, JK_LOG_ERROR, jk_uri_worker_map_t::uri_worker_map_open, malloc failed\n); 244,245c245,246 * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' --- * we need to have a '/' then a '*' and the a '.' or a * '/' then a '*' 247c248,252 asterisk--; --- asterisk--; /* point to char before asterisk */ /* asterisk[0]='/' asterisk[1]='*' asterisk[2]='.' or asterisk[2]='\0' or asterisk[2]!='\0' */ 248a254 asterisk[1] = '\0'; /* terminate the uri pattern at the asterisk */ 251c257 asterisk[1] = asterisk[2] = '\0'; --- asterisk[2] = '\0'; 252a259,260 /* uri-pattern will now contain context only since asterisk[1]='\0' */ 256,258c264,276 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); --- 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); j++; } else if ('\0' != asterisk[2]) { /* general suffix rule */ uw_map-maps[j].worker_name = worker; uw_map-maps[j].context = uri; uw_map-maps[j].suffix = asterisk + 2; uw_map-maps[j].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); 260c278,279 } else { --- } else { 262d280 asterisk[1] = '\0'; 267,269c285,287 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); --- 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); 273c291