You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/04/02 12:21:23 UTC
DO NOT REPLY [Bug 18472] -
mod_jk2 doesn't handle vhosts correctly when using the JkUriSet commands
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18472>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=18472
mod_jk2 doesn't handle vhosts correctly when using the JkUriSet commands
------- Additional Comments From david.cassidy@db.com 2003-04-02 10:21 -------
here's an apache2 version
diff -c against the tomcat 4.1.21 release of mod_jk2.c
to fix the same problems as the apache13 version.
(This sets the virtual host in the /jkstatus page as well as the apache13 version)
***
../../jakarta-tomcat-connectors-4.1.21-src-ORIG/jk/native2/server/apache2/mod_jk2.c
2003-02-25 16:30:56.000000000 +0000
--- native2/server/apache2/mod_jk2.c 2003-03-31 10:25:49.000000000 +0100
***************
*** 77,82 ****
--- 77,88 ----
static char file_name[_MAX_PATH];
#endif
+ /* This is used to ensure that jk2_create_dir_config creates unique
+ * dir mappings. This prevents vhost configs as configured through
+ * httpd.conf from getting crossed.
+ */
+ static int dirCounter=0;
+
#define JK_HANDLER ("jakarta-servlet2")
#define JK_MAGIC_TYPE ("application/x-jakarta-servlet2")
***************
*** 171,177 ****
jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)per_dir;
uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean, (char
*)name, (void *)val );
!
/* fprintf(stderr, "JkUriSet %s %s dir=%s args=%s\n", */
/* uriEnv->workerName, cmd->path, */
/* cmd->directive->directive, */
--- 177,211 ----
jk_uriEnv_t *uriEnv=(jk_uriEnv_t *)per_dir;
uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean, (char
*)name, (void *)val );
!
! char *tmp, *tmp2;
! char *tmp_virtual=NULL, *tmp_full_url=NULL;
! server_rec *s = cmd->server;
!
! // all of the objects that get passed in now are unique. create_dir adds a
incrementing counter to the
! // uri that is used to create the object!
! // Here we must now 'fix' the content of the object passed in.
! // Apache doesn't care what we do here as it has the reference to the
unique object that has been
! // created. What we need to do is ensure that the data given to mod_jk2 is
correct. Hopefully in the long run
! // we can ignore some of the mod_jk details...
!
! // if applicable we will set the hostname etc variables.
! if ( s->server_hostname != NULL && (uriEnv->virtual==NULL || !strchr(
uriEnv->virtual, ':') || uriEnv->port != s->port ))
! {
! tmp_virtual = (char *) ap_pcalloc(cmd->pool, sizeof(char *) *
(strlen(s->server_hostname) + 8 )) ;
! tmp_full_url = (char *) ap_pcalloc(cmd->pool, sizeof(char *) *
(strlen(s->server_hostname) + strlen(uriEnv->uri)+8 )) ;
! sprintf(tmp_virtual, "%s:%d", s->server_hostname, s->port);
! sprintf(tmp_full_url, "%s:%d%s", s->server_hostname, s->port,
uriEnv->uri );
!
! uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean,
"uri", tmp_full_url);
! uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean,
"path", cmd->path);
! uriEnv->name=tmp_virtual;
! uriEnv->virtual=tmp_virtual;
!
! }
! // now lets actually add the parameter set in the <Location> block
! uriEnv->mbean->setAttribute( workerEnv->globalEnv, uriEnv->mbean, (char
*)name, (void *)val );
!
/* fprintf(stderr, "JkUriSet %s %s dir=%s args=%s\n", */
/* uriEnv->workerName, cmd->path, */
/* cmd->directive->directive, */
***************
*** 201,212 ****
/* We don't know the vhost yet - so path is not
* unique. We'll have to generate a unique name
*/
jk_bean_t *jkb=workerEnv->globalEnv->createBean2( workerEnv->globalEnv,
workerEnv->pool, "uri",
! (path==NULL)? "":path );
jk_uriEnv_t *newUri = jkb->object;
newUri->workerEnv=workerEnv;
! newUri->mbean->setAttribute( workerEnv->globalEnv, newUri->mbean, "path",
path );
return newUri;
}
--- 235,258 ----
/* We don't know the vhost yet - so path is not
* unique. We'll have to generate a unique name
*/
+ char *tmp=NULL;
+ int a=0;
+
+ path==NULL?a=10:(a=strlen(path)+10);
+ tmp = (char *) ap_pcalloc(p, sizeof(char *) * (a ) ) ;
+ sprintf(tmp, "%s-%d", path==NULL?"":path, dirCounter++);
+
jk_bean_t *jkb=workerEnv->globalEnv->createBean2( workerEnv->globalEnv,
workerEnv->pool, "uri",
! tmp );
jk_uriEnv_t *newUri = jkb->object;
newUri->workerEnv=workerEnv;
! newUri->mbean->setAttribute( workerEnv->globalEnv, newUri->mbean, "path",
tmp );
! // I'm hoping that setting the id won't break anything. I havn't noticed
it breaking anything.
! newUri->mbean->id=(dirCounter -1);
! // this makes the display in the status display make more sense
! newUri->mbean->localName=path;
!
return newUri;
}
***************
*** 215,260 ****
{
jk_uriEnv_t *child =(jk_uriEnv_t *)childv;
jk_uriEnv_t *parent = (jk_uriEnv_t *)parentv;
! if( child->uri==NULL )
! return parentv;
!
! if( child->merged != JK_TRUE ) {
! /* Merge options from parent.
! */
! if( parent->mbean->debug > 0 ) /* Inherit debugging */
! child->mbean->debug = parent->mbean->debug;
!
! if( child->workerName==NULL ) {
! child->workerName=parent->workerName;
! child->worker=parent->worker;
! }
! if( child->virtual==NULL ) {
! child->virtual=parent->virtual;
! child->aliases=parent->aliases;
! }
! if( child->contextPath==NULL ) {
! child->contextPath=parent->contextPath;
! child->ctxt_len=parent->ctxt_len;
! }
! /* XXX Shuld we merge env vars ?
! */
!
! /* When we merged to top - mark and stop duplicating the work
! */
! if( parent->uri == NULL )
! child->merged=JK_TRUE;
!
!
! if( child->mbean->debug > -1 ) {
! fprintf(stderr, "mod_jk2:mergeDirConfig() Merged dir config %#lx
%s %s %s %s\n",
! child, child->uri, parent->uri, child->workerName,
parent->workerName);
! fprintf(stderr, "mod_jk2:mergeDirConfig() Merged dir config %#lx
%s %s %s %s\n",
! child, child->uri, parent->uri, child->workerName,
parent->workerName);
! }
! }
- return childv;
}
/** Basic initialization for jk2.
--- 261,288 ----
{
jk_uriEnv_t *child =(jk_uriEnv_t *)childv;
jk_uriEnv_t *parent = (jk_uriEnv_t *)parentv;
+ jk_uriEnv_t *winner=NULL;
! if ( child == NULL || child->uri==NULL || child->workerName==NULL )
! winner=parent;
! else if ( parent == NULL || parent->uri ==NULL || parent->workerName==NULL )
! winner=child;
! // interresting bit... so far they are equal ...
! else if ( strlen(parent->uri) > strlen(child->uri) )
! winner=parent;
! else
! winner=child;
!
! /*if ( winner == child )
! fprintf(stderr, "Going with the child\n");
! else if ( winner == parent )
! fprintf(stderr, "Going with the parent\n");
! else
! fprintf(stderr, "Going with NULL\n");
! */
!
! return (void *) winner;
}
/** Basic initialization for jk2.
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org