tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r591792 - in /tomcat/connectors/trunk/jk: native/apache-1.3/mod_jk.c native/apache-2.0/mod_jk.c native/common/jk_uri_worker_map.c native/common/jk_uri_worker_map.h native/iis/jk_isapi_plugin.c xdocs/miscellaneous/changelog.xml
Date Sun, 04 Nov 2007 15:53:45 GMT
Author: rjung
Date: Sun Nov  4 07:53:44 2007
New Revision: 591792

URL: http://svn.apache.org/viewvc?rev=591792&view=rev
Log:
Fix BZ 42038: Correct overlay of mounts and unmounts for IIS.

For IIS we check for mounts using two passes, once with the URL with
the vhost name prepended, and if we don't find a match, another pass
with the original URL.

The semantics of unmount are, that first all mounts must be checked,
and after that all unmounts.

Until now, a mount found in IIS during the second pass, will win
over an unmount during the first pass.

We move the two passes into the mapping function and add the vhost
name as another parameter.

Refactored the mapping function a little, by moving out the search for a match,
which we now need to call twice.

Also removed some logging from IIS, because the same infomration gets
logged inside the mapping function on the same level.


Modified:
    tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
    tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
    tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c
    tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h
    tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml

Modified: tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c Sun Nov  4 07:53:44 2007
@@ -2647,7 +2647,7 @@
             }
 
             ap_no2slash(clean_uri);
-            worker = map_uri_to_worker(conf->uw_map, clean_uri, conf->log);
+            worker = map_uri_to_worker(conf->uw_map, clean_uri, NULL, conf->log);
 
             /* Don't know the worker, ForwardDirectories is set, there is a
              * previous request for which the handler is JK_HANDLER (as set by

Modified: tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c Sun Nov  4 07:53:44 2007
@@ -2088,7 +2088,7 @@
                        worker_name, r->uri);
         }
         else {
-            worker_name = map_uri_to_worker(xconf->uw_map, r->uri, xconf->log);
+            worker_name = map_uri_to_worker(xconf->uw_map, r->uri, NULL, xconf->log);
             if (worker_name == NULL && worker_env.num_of_workers) {
                 worker_name = worker_env.worker_list[0];
                 if (JK_IS_DEBUG_LEVEL(xconf->log))
@@ -2919,7 +2919,7 @@
                 }
             }
 
-            worker = map_uri_to_worker(conf->uw_map, r->uri, conf->log);
+            worker = map_uri_to_worker(conf->uw_map, r->uri, NULL, conf->log);
 
             if (worker) {
                 r->handler = apr_pstrdup(r->pool, JK_HANDLER);
@@ -3061,7 +3061,7 @@
                 return DECLINED;
             }
 
-            worker = map_uri_to_worker(conf->uw_map, r->uri, conf->log);
+            worker = map_uri_to_worker(conf->uw_map, r->uri, NULL, conf->log);
 
             if (worker) {
                 r->handler = apr_pstrdup(r->pool, JK_HANDLER);

Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c Sun Nov  4 07:53:44 2007
@@ -484,9 +484,61 @@
     return rc;
 }
 
-static int is_nomap_match(jk_uri_worker_map_t *uw_map,
-                          const char *uri, const char* worker,
-                          jk_logger_t *l)
+static const char *find_match(jk_uri_worker_map_t *uw_map,
+                        const char *url, 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 for match types */
+        if ((uwr->match_type & MATCH_TYPE_DISABLED) ||
+            (uwr->match_type & MATCH_TYPE_NO_MATCH))
+            continue;
+
+        if (JK_IS_DEBUG_LEVEL(l))
+            jk_log(l, JK_LOG_DEBUG, "Attempting to map context URI '%s=%s' source '%s'",
+                   uwr->context, uwr->worker_name, uri_worker_map_get_source(uwr, l));
+
+        if (uwr->match_type & MATCH_TYPE_WILDCHAR_PATH) {
+            /* Map is already sorted by context_len */
+            if (wildchar_match(url, uwr->context,
+#ifdef WIN32
+                               0
+#else
+                               0
+#endif
+                               ) == 0) {
+                    if (JK_IS_DEBUG_LEVEL(l))
+                        jk_log(l, JK_LOG_DEBUG,
+                               "Found a wildchar match '%s=%s'",
+                               uwr->context, uwr->worker_name);
+                    JK_TRACE_EXIT(l);
+                    return uwr->worker_name;
+             }
+        }
+        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'",
+                           uwr->context, uwr->worker_name);
+                JK_TRACE_EXIT(l);
+                return uwr->worker_name;
+            }
+        }
+    }
+
+    JK_TRACE_EXIT(l);
+    return NULL;
+}
+
+static int is_nomatch(jk_uri_worker_map_t *uw_map,
+                      const char *uri, const char* worker,
+                      jk_logger_t *l)
 {
     unsigned int i;
 
@@ -536,9 +588,11 @@
 
 
 const char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
-                              const char *uri, jk_logger_t *l)
+                              const char *uri, const char *vhost,
+                              jk_logger_t *l)
 {
     unsigned int i;
+    unsigned int vhost_len;
     int reject_unsafe;
     const char *rv = NULL;
     char  url[JK_MAX_URI_LEN+1];
@@ -570,10 +624,31 @@
      * everything after the first ';' char.
      */
     reject_unsafe = uw_map->reject_unsafe;
+    vhost_len = 0;
+/*
+ * In case we got a vhost, we prepend a slash
+ * and the vhost to the url in order to enable
+ * vhost mapping rules especially for IIS.
+ */
+    if (vhost) {
+/* Size including leading slash. */
+        vhost_len = strlen(vhost) + 1;
+        if (vhost_len >= JK_MAX_URI_LEN) {
+            vhost_len = 0;
+            jk_log(l, JK_LOG_WARNING,
+                   "Host prefix %s for URI %s is invalid and will be ignored."
+                   " It must be smaller than %d chars",
+                   vhost, JK_MAX_URI_LEN-1);
+        }
+        else {
+            url[0] = '/';
+            strncpy(&url[1], vhost, vhost_len);
+        }
+    }
     for (i = 0; i < strlen(uri); i++) {
         if (i == JK_MAX_URI_LEN) {
             jk_log(l, JK_LOG_WARNING,
-                   "Uri %s is invalid. Uri must be smaller then %d chars",
+                   "URI %s is invalid. URI must be smaller than %d chars",
                    uri, JK_MAX_URI_LEN);
             JK_TRACE_EXIT(l);
             return NULL;
@@ -581,15 +656,15 @@
         if (uri[i] == ';')
             break;
         else {
-            url[i] = uri[i];
-            if (reject_unsafe && (url[i] == '%' || url[i] == '\\')) {
+            url[i + vhost_len] = uri[i];
+            if (reject_unsafe && (uri[i] == '%' || uri[i] == '\\')) {
                 jk_log(l, JK_LOG_INFO, "Potentially unsafe request url '%s' rejected", uri);
                 JK_TRACE_EXIT(l);
                 return NULL;
             }
         }
     }
-    url[i] = '\0';
+    url[i + vhost_len] = '\0';
 
     if (JK_IS_DEBUG_LEVEL(l)) {
         char *url_rewrite = strstr(uri, JK_PATH_SESSION_IDENTIFIER);
@@ -600,64 +675,30 @@
     if (JK_IS_DEBUG_LEVEL(l))
         jk_log(l, JK_LOG_DEBUG, "Attempting to map URI '%s' from %d maps",
                url, uw_map->size);
-
-    for (i = 0; i < uw_map->size; i++) {
-        uri_worker_record_t *uwr = uw_map->maps[i];
-
-        /* Check for match types */
-        if ((uwr->match_type & MATCH_TYPE_DISABLED) ||
-            (uwr->match_type & MATCH_TYPE_NO_MATCH))
-            continue;
-
-        if (JK_IS_DEBUG_LEVEL(l))
-            jk_log(l, JK_LOG_DEBUG, "Attempting to map context URI '%s=%s' source '%s'",
-                   uwr->context, uwr->worker_name, uri_worker_map_get_source(uwr, l));
-
-        if (uwr->match_type & MATCH_TYPE_WILDCHAR_PATH) {
-            const char *wname;
-            /* Map is already sorted by context_len */
-            if (wildchar_match(url, uwr->context,
-#ifdef WIN32
-                               0
-#else
-                               0
-#endif
-                               ) == 0) {
-                    wname = uwr->worker_name;
-                    if (JK_IS_DEBUG_LEVEL(l))
-                        jk_log(l, JK_LOG_DEBUG,
-                               "Found a wildchar match '%s=%s'",
-                               uwr->context, uwr->worker_name);
-                    JK_TRACE_EXIT(l);
-                    rv = wname;
-                    goto cleanup;
-             }
-        }
-        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'",
-                           uwr->context, uwr->worker_name);
-                JK_TRACE_EXIT(l);
-                rv = uwr->worker_name;
-                goto cleanup;
-            }
-        }
+    rv = find_match(uw_map, url, l);
+/* If this doesn't find a match, try without the vhost. */
+    if (! rv && vhost_len) {
+        rv = find_match(uw_map, &url[vhost_len], l);
     }
-    /* No matches found */
-    JK_TRACE_EXIT(l);
 
-cleanup:
+/* In case we found a match, check for the unmounts. */
     if (rv && uw_map->nosize) {
-        if (is_nomap_match(uw_map, url, rv, l)) {
-            if (JK_IS_DEBUG_LEVEL(l))
+/* Again first including vhost. */
+        if (is_nomatch(uw_map, url, rv, l)) {
+            rv = NULL;
+        }
+/* If no unmount was find, try without vhost. */
+        else if (vhost_len && is_nomatch(uw_map, &url[vhost_len], rv, l)) {
+            rv = NULL;
+        }
+        if (rv == NULL && JK_IS_DEBUG_LEVEL(l)) {
                 jk_log(l, JK_LOG_DEBUG,
-                       "Denying matching for worker %s by nomatch rule",
+                       "Denying match for worker %s by nomatch rule",
                        rv);
-            rv = NULL;
         }
     }
+
+    JK_TRACE_EXIT(l);
     return rv;
 }
 

Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h Sun Nov  4 07:53:44 2007
@@ -141,7 +141,8 @@
                        unsigned int source_type, jk_logger_t *l);
 
 const char *map_uri_to_worker(jk_uri_worker_map_t *uw_map,
-                              const char *uri, jk_logger_t *l);
+                              const char *uri, const char *vhost,
+                              jk_logger_t *l);
 
 int uri_worker_map_load(jk_uri_worker_map_t *uw_map,
                         jk_logger_t *l);

Modified: tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c (original)
+++ tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c Sun Nov  4 07:53:44 2007
@@ -1260,19 +1260,10 @@
             }
             if (szHost > 0) {
                 StringCbCat(snuri, INTERNET_MAX_URL_LENGTH, Host);
-                StringCbCat(snuri, INTERNET_MAX_URL_LENGTH, uri);
-                if (JK_IS_DEBUG_LEVEL(logger))
-                    jk_log(logger, JK_LOG_DEBUG,
-                           "Virtual Host redirection of %s",
-                           snuri);
-                worker = map_uri_to_worker(uw_map, snuri, logger);
+                worker = map_uri_to_worker(uw_map, uri, snuri, logger);
             }
-            if (!worker) {
-                if (JK_IS_DEBUG_LEVEL(logger))
-                    jk_log(logger, JK_LOG_DEBUG,
-                           "Default redirection of %s",
-                           uri);
-                worker = map_uri_to_worker(uw_map, uri, logger);
+            else {
+                worker = map_uri_to_worker(uw_map, uri, NULL, logger);
             }
             /*
              * Check if somebody is feading us with his own TOMCAT data headers.

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?rev=591792&r1=591791&r2=591792&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Sun Nov  4 07:53:44 2007
@@ -44,6 +44,9 @@
   <subsection name="Native">
     <changelog>
       <fix>
+        <bug>42038</bug>: Correct overlay of mounts and unmounts for IIS. (rjung)
+      </fix>
+      <fix>
         <bug>43684</bug>: Replace JkMountFile by JkMountFileReload in
         uriworkermap.properties docs. (rjung)
       </fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message