brian 96/11/03 12:29:43
Modified: src http_config.h http_config.c http_core.c
http_main.c
Log:
Reviewed by: Brian Behlendorf, Jim Jagielski
Submitted by: Dean Gaudet
Fixed problems related to parsing of <VirtualHost> segments where both
IP-vhosts and name-vhosts were used.
Revision Changes Path
1.18 +2 -2 apache/src/http_config.h
Index: http_config.h
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -C3 -r1.17 -r1.18
*** http_config.h 1996/10/20 18:03:30 1.17
--- http_config.h 1996/11/03 20:29:38 1.18
***************
*** 50,56 ****
*
*/
! /* $Id: http_config.h,v 1.17 1996/10/20 18:03:30 ben Exp $ */
/*
* The central data structures around here...
--- 50,56 ----
*
*/
! /* $Id: http_config.h,v 1.18 1996/11/03 20:29:38 brian Exp $ */
/*
* The central data structures around here...
***************
*** 272,278 ****
char *path, char *file);
const char *srm_command_loop (cmd_parms *parms, void *config);
! server_rec *init_virtual_host (pool *p, const char *hostname);
int is_virtual_server (server_rec *);
void process_resource_config(server_rec *s, char *fname, pool *p, pool
*ptemp);
--- 272,278 ----
char *path, char *file);
const char *srm_command_loop (cmd_parms *parms, void *config);
! server_rec *init_virtual_host (pool *p, const char *hostname, server_rec
*main_server);
int is_virtual_server (server_rec *);
void process_resource_config(server_rec *s, char *fname, pool *p, pool
*ptemp);
1.28 +20 -14 apache/src/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C3 -r1.27 -r1.28
*** http_config.c 1996/10/20 18:03:29 1.27
--- http_config.c 1996/11/03 20:29:38 1.28
***************
*** 50,56 ****
*
*/
! /* $Id: http_config.c,v 1.27 1996/10/20 18:03:29 ben Exp $ */
/*
* http_config.c: once was auxillary functions for reading httpd's config
--- 50,56 ----
*
*/
! /* $Id: http_config.c,v 1.28 1996/11/03 20:29:38 brian Exp $ */
/*
* http_config.c: once was auxillary functions for reading httpd's config
***************
*** 757,768 ****
* paddr is used to create a list in the order of input
* **paddr is the ->next pointer of the last entry (or s->addrs)
* *paddr is the variable used to keep track of **paddr between calls
*/
! static void get_addresses (pool *p, char *w, server_addr_rec ***paddr)
{
struct hostent *hep;
unsigned long my_addr;
- int ports;
server_addr_rec *sar;
char *t;
int i;
--- 757,768 ----
* paddr is used to create a list in the order of input
* **paddr is the ->next pointer of the last entry (or s->addrs)
* *paddr is the variable used to keep track of **paddr between calls
+ * port is the default port to assume
*/
! static void get_addresses (pool *p, char *w, server_addr_rec ***paddr, int
port)
{
struct hostent *hep;
unsigned long my_addr;
server_addr_rec *sar;
char *t;
int i;
***************
*** 770,785 ****
if( *w == 0 ) return;
t = strchr(w, ':');
! ports = 0;
! if (t != NULL && strcmp(t+1, "*") != 0) ports = atoi(t+1);
- if (t != NULL) *t = '\0';
if (strcmp(w, "*") == 0) {
sar = pcalloc( p, sizeof( server_addr_rec ) );
**paddr = sar;
*paddr = &sar->next;
sar->host_addr.s_addr = htonl(INADDR_ANY);
! sar->host_port = ports;
sar->virthost = pstrdup(p, w);
if (t != NULL) *t = ':';
return;
--- 770,792 ----
if( *w == 0 ) return;
t = strchr(w, ':');
! if (t) {
! if( strcmp(t+1,"*") == 0 ) {
! port = 0;
! } else if( (i = atoi(t+1)) ) {
! port = i;
! } else {
! fprintf( stderr, "Port must be numeric\n" );
! }
! *t = 0;
! }
if (strcmp(w, "*") == 0) {
sar = pcalloc( p, sizeof( server_addr_rec ) );
**paddr = sar;
*paddr = &sar->next;
sar->host_addr.s_addr = htonl(INADDR_ANY);
! sar->host_port = port;
sar->virthost = pstrdup(p, w);
if (t != NULL) *t = ':';
return;
***************
*** 795,801 ****
**paddr = sar;
*paddr = &sar->next;
sar->host_addr.s_addr = my_addr;
! sar->host_port = ports;
sar->virthost = pstrdup(p, w);
if (t != NULL) *t = ':';
return;
--- 802,808 ----
**paddr = sar;
*paddr = &sar->next;
sar->host_addr.s_addr = my_addr;
! sar->host_port = port;
sar->virthost = pstrdup(p, w);
if (t != NULL) *t = ':';
return;
***************
*** 813,826 ****
**paddr = sar;
*paddr = &sar->next;
sar->host_addr = *(struct in_addr *)hep->h_addr_list[i];
! sar->host_port = ports;
sar->virthost = pstrdup(p, w);
}
if (t != NULL) *t = ':';
}
! server_rec *init_virtual_host (pool *p, const char *hostname)
{
server_rec *s = (server_rec *)pcalloc (p, sizeof (server_rec));
server_addr_rec **addrs;
--- 820,834 ----
**paddr = sar;
*paddr = &sar->next;
sar->host_addr = *(struct in_addr *)hep->h_addr_list[i];
! sar->host_port = port;
sar->virthost = pstrdup(p, w);
}
if (t != NULL) *t = ':';
}
! server_rec *init_virtual_host (pool *p, const char *hostname,
! server_rec *main_server)
{
server_rec *s = (server_rec *)pcalloc (p, sizeof (server_rec));
server_addr_rec **addrs;
***************
*** 847,853 ****
/* start the list of addreses */
addrs = &s->addrs;
while( hostname[0] ) {
! get_addresses( p, getword_conf( p, &hostname ), &addrs );
}
/* terminate the list */
*addrs = NULL;
--- 855,862 ----
/* start the list of addreses */
addrs = &s->addrs;
while( hostname[0] ) {
! get_addresses( p, getword_conf( p, &hostname ), &addrs,
! main_server->port );
}
/* terminate the list */
*addrs = NULL;
***************
*** 886,894 ****
virt->lookup_defaults =
merge_per_dir_configs (p, main_server->lookup_defaults,
virt->lookup_defaults);
-
- if (virt->port == 0)
- virt->port = main_server->port;
if (virt->server_admin == NULL)
virt->server_admin = main_server->server_admin;
--- 895,900 ----
1.41 +1 -1 apache/src/http_core.c
Index: http_core.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_core.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -C3 -r1.40 -r1.41
*** http_core.c 1996/10/23 14:35:48 1.40
--- http_core.c 1996/11/03 20:29:39 1.41
***************
*** 733,739 ****
if (main_server->is_virtual)
return "<VirtualHost> doesn't nest!";
! s = init_virtual_host (p, arg);
s->next = main_server->next;
main_server->next = s;
--- 733,739 ----
if (main_server->is_virtual)
return "<VirtualHost> doesn't nest!";
! s = init_virtual_host (p, arg, main_server);
s->next = main_server->next;
main_server->next = s;
1.81 +18 -8 apache/src/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -C3 -r1.80 -r1.81
*** http_main.c 1996/10/31 17:51:35 1.80
--- http_main.c 1996/11/03 20:29:40 1.81
***************
*** 50,56 ****
*
*/
! /* $Id: http_main.c,v 1.80 1996/10/31 17:51:35 brian Exp $ */
/*
* httpd.c: simple http daemon for answering WWW file requests
--- 50,56 ----
*
*/
! /* $Id: http_main.c,v 1.81 1996/11/03 20:29:40 brian Exp $ */
/*
* httpd.c: simple http daemon for answering WWW file requests
***************
*** 1263,1269 ****
void default_server_hostnames(server_rec *s)
{
! struct hostent *h, *main;
char *def_hostname;
int n;
server_addr_rec *sar;
--- 1263,1271 ----
void default_server_hostnames(server_rec *s)
{
! struct hostent *h;
! struct in_addr *main_addr;
! int num_addr;
char *def_hostname;
int n;
server_addr_rec *sar;
***************
*** 1277,1299 ****
}
def_hostname = s->server_hostname;
! main = gethostbyname(def_hostname);
! if( main == NULL ) {
fprintf(stderr,"httpd: cannot determine local host name.\n");
fprintf(stderr,"Use ServerName to set it manually.\n");
exit(1);
}
!
/* Then virtual hosts */
for (s = s->next; s; s = s->next) {
/* Check to see if we might be a HTTP/1.1 virtual host - same IP */
has_inaddr_any = 0;
! for (n = 0; main->h_addr_list[n] != NULL; n++) {
for(sar = s->addrs; sar; sar = sar->next) {
! if (sar->host_addr.s_addr ==
! (((struct in_addr *)(main->h_addr_list[n]))->s_addr) &&
s->port == mainport)
s->is_virtual = 2;
if( sar->host_addr.s_addr == htonl(INADDR_ANY) ) {
--- 1279,1309 ----
}
def_hostname = s->server_hostname;
! h = gethostbyname(def_hostname);
! if( h == NULL ) {
fprintf(stderr,"httpd: cannot determine local host name.\n");
fprintf(stderr,"Use ServerName to set it manually.\n");
exit(1);
}
! /* we need to use gethostbyaddr below... and since it shares a static
! area with gethostbyname it'd clobber the value we just got. So
! we need to make a copy. -djg */
! for (num_addr = 0; h->h_addr_list[num_addr] != NULL; num_addr++) {
! /* nop */
! }
! main_addr = palloc( pconf, sizeof( *main_addr ) * num_addr );
! for (n = 0; n < num_addr; n++) {
! main_addr[n] = *(struct in_addr *)h->h_addr_list[n];
! }
/* Then virtual hosts */
for (s = s->next; s; s = s->next) {
/* Check to see if we might be a HTTP/1.1 virtual host - same IP */
has_inaddr_any = 0;
! for (n = 0; n < num_addr; n++) {
for(sar = s->addrs; sar; sar = sar->next) {
! if (sar->host_addr.s_addr == main_addr[n].s_addr &&
s->port == mainport)
s->is_virtual = 2;
if( sar->host_addr.s_addr == htonl(INADDR_ANY) ) {