httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <dgau...@arctic.org>
Subject [PATCH] VirtualHost confusion (fwd)
Date Wed, 26 Feb 1997 22:30:09 GMT
Ben asked for a repost.

Dean

---------- Forwarded message ----------
Date: Sat, 1 Feb 1997 14:16:45 -0800 (PST)
From: Dean Gaudet <dgaudet@arctic.org>
Reply-To: new-httpd@hyperreal.com
To: new-httpd@hyperreal.com
Subject: [PATCH] VirtualHost confusion

On Sat, 1 Feb 1997, Marc Slemko wrote:
>   * user and server get confused over what should be a virtual host
> 	and what is the main server, resulting in access to something
> 	other than the name defined in the virtualhost directive (but
> 	with the same IP address) failing.  
> 		Status: should be looked at, may not be a nice way to fix 
> 			since it is likely not technically a bug.

When I put in the multiple ip support I didn't do multiple name support,
but I put most of the code in that it needed.  I don't remember why I
didn't do the last step... here is a patch which does that last step.  It
treats all the names in a <VirtualHost> statement as if they were
ServerAliased. 

It requires a tweak to mod_rewrite.  I haven't tested this part of the
patch.  Ralf? 

A question (Chuck?):  in check_hostalias() why is the ServerName treated
with a parseuri() while ServerAliases just set r->proxyreq = 0?

Dean

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.97
diff -c -3 -r1.97 http_protocol.c
*** http_protocol.c	1997/01/30 03:46:13	1.97
--- http_protocol.c	1997/02/01 22:10:43
***************
*** 600,607 ****
    r->hostname = host;
  
    for (s = r->server->next; s; s = s->next) {
!     const char *names = s->names;
!     
      if ((!strcasecmp(host, s->server_hostname)) && (port == s->port)) {
        r->server = r->connection->server = s;
        if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
--- 600,608 ----
    r->hostname = host;
  
    for (s = r->server->next; s; s = s->next) {
!     const char *names;
!     server_addr_rec *sar;
! 
      if ((!strcasecmp(host, s->server_hostname)) && (port == s->port)) {
        r->server = r->connection->server = s;
        if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
***************
*** 610,626 ****
        }
      }
  
!     if (!names) continue;
! 
!     while (*names) {
!       char *name = getword_conf (r->pool, &names);
! 
!       if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
! 	  (!strcasecmp(host, name))) {
  	r->server = r->connection->server = s;
! 	if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
  	  r->uri += r->hostlen;
  	  r->proxyreq = 0;
  	}
        }
      }
--- 611,640 ----
        }
      }
  
!     /* search all the names from <VirtualHost> directive */
!     for( sar = s->addrs; sar; sar = sar->next ) {
!       if( !strcasecmp( sar->virthost, host ) ) {
  	r->server = r->connection->server = s;
! 	if( r->hostlen && !strncmp( r->uri, "http://", 7) ) {
  	  r->uri += r->hostlen;
  	  r->proxyreq = 0;
+ 	}
+       }
+     }
+ 
+     /* search all the aliases from ServerAlias directive */
+     names = s->names;
+     if( names ) {
+       while (*names) {
+ 	char *name = getword_conf (r->pool, &names);
+ 
+ 	if ((is_matchexp(name) && !strcasecmp_match(host, name)) ||
+ 	    (!strcasecmp(host, name))) {
+ 	  r->server = r->connection->server = s;
+ 	  if (r->hostlen && !strncmp(r->uri, "http://", 7)) {
+ 	    r->uri += r->hostlen;
+ 	    r->proxyreq = 0;
+ 	  }
  	}
        }
      }
Index: mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
retrieving revision 1.16
diff -c -3 -r1.16 mod_rewrite.c
*** mod_rewrite.c	1997/01/29 23:51:37	1.16
--- mod_rewrite.c	1997/02/01 22:10:45
***************
*** 2925,2930 ****
--- 2925,2938 ----
      }
      else if (r->server->is_virtual) {
          /* virtual servers */
+ 	server_addr_rec *sar;
+ 
+ 	/* check for the names supplied in the VirtualHost directive */
+ 	for( sar = r->server->addrs; sar; sar = sar->next ) {
+ 	    if( !strcasecmp( sar->virthost, testhost ) ) {
+ 		return YES;
+ 	    }
+ 	}
  
          /* check for the virtual-server aliases */
          if (r->server->names != NULL && r->server->names[0] != '\0')
{




Mime
View raw message