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 take 2 (plus mod_rewrite patch)
Date Wed, 05 Mar 1997 21:52:04 GMT
Ralf's mod_rewrite patch included part of the patch required to implement
the virtualhost change.  Here's his patch plus the http_protocol.c change
required.  This is essentially equivalent to what I posted back at the
beginning of Feb... but needs voting again :) 

Dean

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.105
diff -c -3 -r1.105 http_protocol.c
*** http_protocol.c	1997/02/22 00:37:18	1.105
--- http_protocol.c	1997/03/05 21:37:38
***************
*** 650,657 ****
    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)) {
--- 650,658 ----
    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)) {
***************
*** 660,676 ****
        }
      }
  
!     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;
  	}
        }
      }
--- 661,690 ----
        }
      }
  
!     /* 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.20
diff -c -3 -r1.20 mod_rewrite.c
*** mod_rewrite.c	1997/02/26 01:01:12	1.20
--- mod_rewrite.c	1997/03/05 21:37:40
***************
*** 61,67 ****
  **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
  **                       |_____|
  **
! **  URL Rewriting Module, Version 3.0.0 (01-02-1997)
  **
  **  This module uses a rule-based rewriting engine (based on a
  **  regular-expression parser) to rewrite requested URLs on the fly. 
--- 61,67 ----
  **  |_| |_| |_|\___/ \__,_|___|_|  \___| \_/\_/ |_|  |_|\__\___|
  **                       |_____|
  **
! **  URL Rewriting Module, Version 3.0.0 (06-Mar-1997)
  **
  **  This module uses a rule-based rewriting engine (based on a
  **  regular-expression parser) to rewrite requested URLs on the fly. 
***************
*** 98,105 ****
  #include <time.h>
  #include <signal.h>
  #include <errno.h>
- #include <pwd.h>
- #include <grp.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <netinet/in.h>
--- 98,103 ----
***************
*** 135,141 ****
  **  o  Runtime logic of a request is as following:
  **
  **       while(request or subrequest) {
! **           foreach(stage #1...#8) {
  **               foreach(module) { (**)
  **                   try to run hook
  **               }
--- 133,139 ----
  **  o  Runtime logic of a request is as following:
  **
  **       while(request or subrequest) {
! **           foreach(stage #1...#9) {
  **               foreach(module) { (**)
  **                   try to run hook
  **               }
***************
*** 149,160 ****
  **
  **  o  there are two different types of result checking and 
  **     continue processing:
! **     for hook #1,#3,#4,#5,#7:
  **         hook run loop stops on first modules which gives
  **         back a result != DECLINED, i.e. it usually returns OK
  **         which says "OK, module has handled this _stage_" and for #1
  **         this have not to mean "Ok, the filename is now valid".
! **     for hook #2,#6,#8:
  **         all hooks are run, independend of result
  **
  **  o  at the last stage, the core module allways 
--- 147,158 ----
  **
  **  o  there are two different types of result checking and 
  **     continue processing:
! **     for hook #1,#4,#5,#6,#8:
  **         hook run loop stops on first modules which gives
  **         back a result != DECLINED, i.e. it usually returns OK
  **         which says "OK, module has handled this _stage_" and for #1
  **         this have not to mean "Ok, the filename is now valid".
! **     for hook #2,#3,#7,#9:
  **         all hooks are run, independend of result
  **
  **  o  at the last stage, the core module allways 
***************
*** 205,222 ****
     config_server_merge,         /* merge  per-server config structures */
     command_table,               /* table of config file commands */
  
!    handler_table,               /* [#7] table of MIME-typed-dispatched request action handlers
*/
  
     hook_uri2file,               /* [#1] URI to filename translation */
  
!    NULL,                        /* [#3] check_user_id: get and validate user id from the
HTTP request */
!    NULL,                        /* [#4] check_auth:    check if the user is ok _here_ */
     NULL,                        /* [#2] check_access:  check access by host address, etc.
*/
  
!    hook_mimetype,               /* [#5] determine MIME type */
  
!    hook_fixup,                  /* [#6] pre-run fixups */
!    NULL                         /* [#8] log a transaction */
  };
  
      /* the cache */
--- 203,221 ----
     config_server_merge,         /* merge  per-server config structures */
     command_table,               /* table of config file commands */
  
!    handler_table,               /* [#8] table of MIME-typed-dispatched request action handlers
*/
  
     hook_uri2file,               /* [#1] URI to filename translation */
  
!    NULL,                        /* [#4] check_user_id: get and validate user id from the
HTTP request */
!    NULL,                        /* [#5] check_auth:    check if the user is ok _here_ */
     NULL,                        /* [#2] check_access:  check access by host address, etc.
*/
  
!    hook_mimetype,               /* [#6] determine MIME type */
  
!    hook_fixup,                  /* [#7] pre-run fixups */
!    NULL,                        /* [#9] log a transaction */
!    NULL                         /* [#3] header parser */
  };
  
      /* the cache */
***************
*** 226,232 ****
  static int proxy_available;
  
      /* the txt mapfile parsing stuff */
! #define MAPFILE_PATTERN "^([^ ]+) +([^ ]+).*$"
  #define MAPFILE_OUTPUT "$1,$2"
  static regex_t   *lookup_map_txtfile_regexp = NULL;
  static regmatch_t lookup_map_txtfile_regmatch[10];
--- 225,231 ----
  static int proxy_available;
  
      /* the txt mapfile parsing stuff */
! #define MAPFILE_PATTERN "^([^ \t]+)[ \t]+([^ \t]+).*$"
  #define MAPFILE_OUTPUT "$1,$2"
  static regex_t   *lookup_map_txtfile_regexp = NULL;
  static regmatch_t lookup_map_txtfile_regmatch[10];
***************
*** 1123,1131 ****
       *  only do something under runtime if the engine is really enabled,
       *  for this directory, else return immediately!
       */
!     if (!(allow_options(r) & OPT_SYM_LINKS)) {
          /* FollowSymLinks is mandatory! */
!         log_reason("Options FollowSymLinks is off which implies that RewriteRule directive
is forbidden", r->filename, r);
          return FORBIDDEN;
      }
      else {
--- 1122,1130 ----
       *  only do something under runtime if the engine is really enabled,
       *  for this directory, else return immediately!
       */
!     if (!(allow_options(r) & (OPT_SYM_LINKS | OPT_SYM_OWNER))) {
          /* FollowSymLinks is mandatory! */
!         log_reason("Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies
that RewriteRule directive is forbidden", r->filename, r);
          return FORBIDDEN;
      }
      else {
***************
*** 3028,3033 ****
--- 3027,3033 ----
      const char *names;
      char *name;
      int i, j;
+     server_addr_rec *sar;
  
      /* we can check:
         r->
***************
*** 3042,3054 ****
              char *path                name of ServerPath
              int pathlen               len of ServerPath
              char *names               Wildcarded names for ServerAlias servers 
!        under 1.1:
!        r->server->
!             struct in_addr host_addr  The bound address, for this server 
!             short host_port           The bound port, for this server 
!             char *virthost            The name given in <VirtualHost> 
!        under 1.2:
!        r->server->addrs->next...
              struct in_addr host_addr  The bound address, for this server
              short host_port           The bound port, for this server 
              char *virthost            The name given in <VirtualHost> 
--- 3042,3048 ----
              char *path                name of ServerPath
              int pathlen               len of ServerPath
              char *names               Wildcarded names for ServerAlias servers 
!        r->server->addrs->
              struct in_addr host_addr  The bound address, for this server
              short host_port           The bound port, for this server 
              char *virthost            The name given in <VirtualHost> 
***************
*** 3081,3086 ****
--- 3075,3086 ----
      }
      else if (r->server->is_virtual) {
          /* virtual servers */
+ 
+         /* check for the names supplied in the VirtualHost directive */
+         for(sar = r->server->addrs; sar != NULL; sar = sar->next) {
+             if(strcasecmp(sar->virthost, testhost) == 0)
+                 return YES;
+         }
  
          /* check for the virtual-server aliases */
          if (r->server->names != NULL && r->server->names[0] != '\0')
{


Mime
View raw message