From dfcb7f75e1336a0ee104db010fadfc106c995502 Mon Sep 17 00:00:00 2001 From: Rainer Jung Date: Thu, 3 Oct 2013 18:31:22 +0000 Subject: [PATCH] Wildcard name-based vhosts printed twice in apachectl -S PR54948 Proposed by: covener Reviewed by: jim, rjung Backport of r1485675 and r1525000 from trunk. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1528958 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ STATUS | 6 ------ server/vhost.c | 16 +++++++++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 93f025200e..7ea9250595 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.7 + *) core: apachectl -S prints wildcard name-based virtual hosts twice. + PR54948 [Eric Covener] + *) mod_auth_basic: Add AuthBasicUseDigestAlgorithm directive to allow migration of passwords from digest to basic authentication. [Chris Darroch] diff --git a/STATUS b/STATUS index ba0aae346a..bfa98e6472 100644 --- a/STATUS +++ b/STATUS @@ -97,12 +97,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * core: name-based vhosts printed twice in apachectl -S since - dropping NameVirtualHost directive. - trunk patch: http://svn.apache.org/r1485675 , http://svn.apache.org/r1525000 - 2.4.x patch: http://people.apache.org/~covener/patches/httpd-2.4.x-nvh-duplicated.diff - +1: covener, jim, rjung - * worker MPM: Don't forcibly kill worker threads if the child process is exiting gracefully. trunk: http://svn.apache.org/r1526220 diff --git a/server/vhost.c b/server/vhost.c index fd7c0ad646..111311b4bb 100644 --- a/server/vhost.c +++ b/server/vhost.c @@ -577,14 +577,22 @@ AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_s) */ for (s = main_s->next; s; s = s->next) { + server_addr_rec *sar_prev = NULL; has_default_vhost_addr = 0; for (sar = s->addrs; sar; sar = sar->next) { ipaddr_chain *ic; char inaddr_any[16] = {0}; /* big enough to handle IPv4 or IPv6 */ - + /* XXX: this treats 0.0.0.0 as a "default" server which matches no-exact-match for IPv6 */ if (!memcmp(sar->host_addr->ipaddr_ptr, inaddr_any, sar->host_addr->ipaddr_len)) { ic = find_default_server(sar->host_port); - if (!ic || sar->host_port != ic->sar->host_port) { + + if (ic && sar->host_port == ic->sar->host_port) { /* we're a match for an existing "default server" */ + if (!sar_prev || memcmp(sar_prev->host_addr->ipaddr_ptr, inaddr_any, sar_prev->host_addr->ipaddr_len) + || sar_prev->host_port != sar->host_port) { + add_name_vhost_config(p, main_s, s, sar, ic); + } + } + else { /* No default server, or we found a default server but ** exactly one of us is a wildcard port, which means we want ** two ip-based vhosts not an NVH with two names @@ -592,6 +600,7 @@ AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_s) ic = new_ipaddr_chain(p, s, sar); ic->next = default_list; default_list = ic; + add_name_vhost_config(p, main_s, s, sar, ic); } has_default_vhost_addr = 1; } @@ -609,8 +618,9 @@ AP_DECLARE(void) ap_fini_vhost_config(apr_pool_t *p, server_rec *main_s) ic->next = *iphash_table_tail[bucket]; *iphash_table_tail[bucket] = ic; } + add_name_vhost_config(p, main_s, s, sar, ic); } - add_name_vhost_config(p, main_s, s, sar, ic); + sar_prev = sar; } /* Ok now we want to set up a server_hostname if the user was -- 2.50.1