httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From poir...@apache.org
Subject svn commit: r990844 - in /httpd/httpd/trunk: CHANGES server/vhost.c
Date Mon, 30 Aug 2010 16:09:50 GMT
Author: poirier
Date: Mon Aug 30 16:09:50 2010
New Revision: 990844

URL: http://svn.apache.org/viewvc?rev=990844&view=rev
Log:
Fail startup for vhost configuration problems, rather than
running with a configuration with undefined behavior.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/server/vhost.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=990844&r1=990843&r2=990844&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Aug 30 16:09:50 2010
@@ -2,6 +2,14 @@
 
 Changes with Apache 2.3.9
 
+  *) vhosts: Do not allow _default_ in NameVirtualHost, or mixing *
+     and non-* ports on NameVirtualHost, or multiple NameVirtualHost
+     directives for the same address:port, or NameVirtualHost
+     directives with no matching VirtualHosts, or multiple ip-based
+     VirtualHost sections for the same address:port.  These were
+     previously accepted with a warning, but the behavior was
+     undefined.  [Dan Poirier]
+
   *) mod_remoteip: Fix a segfaulti when using mod_remoteip in conjunction with
      Allow/Deny. PR 49838.  [Andrew Skalski <voltara gmail.com>]
 

Modified: httpd/httpd/trunk/server/vhost.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/vhost.c?rev=990844&r1=990843&r2=990844&view=diff
==============================================================================
--- httpd/httpd/trunk/server/vhost.c (original)
+++ httpd/httpd/trunk/server/vhost.c Mon Aug 30 16:09:50 2010
@@ -97,6 +97,13 @@ static ipaddr_chain *default_list;
 static server_addr_rec *name_vhost_list;
 static server_addr_rec **name_vhost_list_tail;
 
+/* whether a config error was seen */
+static int config_error = 0;
+
+/* config check function */
+static int vhost_check_config(apr_pool_t *p, apr_pool_t *plog,
+                              apr_pool_t *ptemp, server_rec *s);
+
 /*
  * How it's used:
  *
@@ -127,6 +134,7 @@ AP_DECLARE(void) ap_init_vhost_config(ap
     default_list = NULL;
     name_vhost_list = NULL;
     name_vhost_list_tail = &name_vhost_list;
+    ap_hook_check_config(vhost_check_config, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
 
@@ -255,6 +263,11 @@ AP_DECLARE_NONSTD(const char *)ap_set_na
                                                         void *dummy,
                                                         const char *arg)
 {
+    if (0 == strcasecmp(arg, "_default_")
+        || 0 == strncasecmp(arg, "_default_:", 10)) {
+        return "_default_ is not allowed in NameVirtualHost directive";
+    }
+
     /* use whatever port the main server has at this point */
     return get_addresses(cmd->pool, arg, &name_vhost_list_tail,
                          cmd->server->port);
@@ -510,9 +523,9 @@ static int add_name_vhost_config(apr_poo
             ap_log_error(APLOG_MARK, APLOG_ERR, 0, main_s,
                          "VirtualHost %s:%u -- mixing * "
                          "ports and non-* ports with "
-                         "a NameVirtualHost address is not supported,"
-                         " proceeding with undefined results",
+                         "a NameVirtualHost address is not supported",
                          sar->virthost, sar->host_port);
+            config_error = 1;
         }
         return 1;
     }
@@ -528,11 +541,12 @@ static void remove_unused_name_vhosts(se
         ipaddr_chain *ic = *pic;
 
         if (ic->server == NULL) {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, 0, main_s,
+            ap_log_error(APLOG_MARK, APLOG_ERR, 0, main_s,
                          "Either NameVirtualHost %s:%u has no VirtualHosts,"
                          " or there is more than one identical NameVirtualHost line,"
                          " or your VirtualHost declarations do not match the NameVirtualHost
line",
                          ic->sar->virthost, ic->sar->host_port);
+            config_error = 1;
             *pic = ic->next;
         }
         else {
@@ -610,10 +624,10 @@ AP_DECLARE(void) ap_fini_vhost_config(ap
                 ic = find_default_server(sar->host_port);
                 if (!ic || !add_name_vhost_config(p, main_s, s, sar, ic)) {
                     if (ic && ic->sar->host_port != 0) {
-                        ap_log_error(APLOG_MARK, APLOG_WARNING,
+                        ap_log_error(APLOG_MARK, APLOG_ERR,
                                      0, main_s, "_default_ VirtualHost "
-                                     "overlap on port %u, the first has "
-                                     "precedence", sar->host_port);
+                                     "overlap on port %u", sar->host_port);
+                        config_error = 1;
                     }
                     ic = new_ipaddr_chain(p, s, sar);
                     ic->next = default_list;
@@ -633,13 +647,14 @@ AP_DECLARE(void) ap_fini_vhost_config(ap
                     *iphash_table_tail[bucket] = ic;
                 }
                 else if (!add_name_vhost_config(p, main_s, s, sar, ic)) {
-                    ap_log_error(APLOG_MARK, APLOG_WARNING,
+                    ap_log_error(APLOG_MARK, APLOG_ERR,
                                  0, main_s, "VirtualHost %s:%u overlaps "
                                  "with VirtualHost %s:%u, the first has "
                                  "precedence, perhaps you need a "
                                  "NameVirtualHost directive",
                                  sar->virthost, sar->host_port,
                                  ic->sar->virthost, ic->sar->host_port);
+                    config_error = 1;
                     ic->sar = sar;
                     ic->server = s;
                 }
@@ -706,6 +721,11 @@ AP_DECLARE(void) ap_fini_vhost_config(ap
     }
 }
 
+static int vhost_check_config(apr_pool_t *p, apr_pool_t *plog,
+                              apr_pool_t *ptemp, server_rec *s)
+{
+    return config_error ? !OK : OK;
+}
 
 /*****************************************************************************
  * run-time vhost matching functions



Mime
View raw message