You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ta...@apache.org on 2009/12/29 16:39:55 UTC

svn commit: r894425 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mod_proxy.xml docs/manual/mod/mod_proxy_connect.xml include/ap_mmn.h modules/proxy/mod_proxy.c modules/proxy/mod_proxy.h modules/proxy/mod_proxy_connect.c

Author: takashi
Date: Tue Dec 29 15:39:54 2009
New Revision: 894425

URL: http://svn.apache.org/viewvc?rev=894425&view=rev
Log:
Move AllowCONNECT from mod_proxy to mod_proxy_connect.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml
    httpd/httpd/trunk/docs/manual/mod/mod_proxy_connect.xml
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/modules/proxy/mod_proxy.c
    httpd/httpd/trunk/modules/proxy/mod_proxy.h
    httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Dec 29 15:39:54 2009
@@ -7,6 +7,9 @@
      a partial match.  PR 48401.i
      [Dodou Wang <wangdong.08 gmail.com>, Ruediger Pluem]
 
+  *) mod_proxy, mod_proxy_connect: Move AllowCONNECT from mod_proxy to
+     mod_proxy_connect. [Takashi Sato]
+
   *) mod_proxy_balancer: Fix crash in balancer-manager. [Rainer Jung]
 
   *) mod_headers: Ensure that changes to the main request remain valid when

Modified: httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_proxy.xml Tue Dec 29 15:39:54 2009
@@ -1085,33 +1085,6 @@
 </usage>
 </directivesynopsis>
 
-
-<directivesynopsis>
-<name>AllowCONNECT</name>
-<description>Ports that are allowed to <code>CONNECT</code> through the
-proxy</description>
-<syntax>AllowCONNECT <var>port</var> [<var>port</var>] ...</syntax>
-<default>AllowCONNECT 443 563</default>
-<contextlist><context>server config</context><context>virtual host</context>
-</contextlist>
-
-<usage>
-    <p>The <directive>AllowCONNECT</directive> directive specifies a list
-    of port numbers to which the proxy <code>CONNECT</code> method may
-    connect.  Today's browsers use this method when a <code>https</code>
-    connection is requested and proxy tunneling over HTTP is in effect.</p>
-
-    <p>By default, only the default https port (<code>443</code>) and the
-    default snews port (<code>563</code>) are enabled. Use the
-    <directive>AllowCONNECT</directive> directive to override this default and
-    allow connections to the listed ports only.</p>
-
-    <p>Note that you'll need to have <module>mod_proxy_connect</module> present
-    in the server in order to get the support for the <code>CONNECT</code> at
-    all.</p>
-</usage>
-</directivesynopsis>
-
 <directivesynopsis>
 <name>ProxyBlock</name>
 <description>Words, hosts, or domains that are banned from being

Modified: httpd/httpd/trunk/docs/manual/mod/mod_proxy_connect.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_proxy_connect.xml?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_proxy_connect.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_proxy_connect.xml Tue Dec 29 15:39:54 2009
@@ -49,4 +49,26 @@
 <seealso><directive module="mod_proxy">AllowCONNECT</directive></seealso>
 <seealso><module>mod_proxy</module></seealso>
 
+<directivesynopsis>
+<name>AllowCONNECT</name>
+<description>Ports that are allowed to <code>CONNECT</code> through the
+proxy</description>
+<syntax>AllowCONNECT <var>port</var> [<var>port</var>] ...</syntax>
+<default>AllowCONNECT 443 563</default>
+<contextlist><context>server config</context><context>virtual host</context>
+</contextlist>
+
+<usage>
+    <p>The <directive>AllowCONNECT</directive> directive specifies a list
+    of port numbers to which the proxy <code>CONNECT</code> method may
+    connect.  Today's browsers use this method when a <code>https</code>
+    connection is requested and proxy tunneling over HTTP is in effect.</p>
+
+    <p>By default, only the default https port (<code>443</code>) and the
+    default snews port (<code>563</code>) are enabled. Use the
+    <directive>AllowCONNECT</directive> directive to override this default and
+    allow connections to the listed ports only.</p>
+</usage>
+</directivesynopsis>
+
 </modulesynopsis>

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Dec 29 15:39:54 2009
@@ -206,15 +206,17 @@
  * 20091031.0 (2.3.3-dev)  remove public LDAP referral-related macros
  * 20091119.0 (2.3.4-dev)  dav_error interface uses apr_status_t parm, not errno
  * 20091119.1 (2.3.4-dev)  ap_mutex_register(), ap_{proc,global}_mutex_create()
+ * 20091229.0 (2.3.4-dev)  Move allowed_connect_ports from proxy_server_conf
+ *                         to mod_proxy_connect
  *
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
 
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20091119
+#define MODULE_MAGIC_NUMBER_MAJOR 20091229
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.c?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.c Tue Dec 29 15:39:54 2009
@@ -1085,7 +1085,6 @@
     ps->aliases = apr_array_make(p, 10, sizeof(struct proxy_alias));
     ps->noproxies = apr_array_make(p, 10, sizeof(struct noproxy_entry));
     ps->dirconn = apr_array_make(p, 10, sizeof(struct dirconn_entry));
-    ps->allowed_connect_ports = apr_array_make(p, 10, sizeof(int));
     ps->workers = apr_array_make(p, 10, sizeof(proxy_worker));
     ps->balancers = apr_array_make(p, 10, sizeof(proxy_balancer));
     ps->forward = NULL;
@@ -1123,7 +1122,6 @@
     ps->aliases = apr_array_append(p, base->aliases, overrides->aliases);
     ps->noproxies = apr_array_append(p, base->noproxies, overrides->noproxies);
     ps->dirconn = apr_array_append(p, base->dirconn, overrides->dirconn);
-    ps->allowed_connect_ports = apr_array_append(p, base->allowed_connect_ports, overrides->allowed_connect_ports);
     ps->workers = apr_array_append(p, base->workers, overrides->workers);
     ps->balancers = apr_array_append(p, base->balancers, overrides->balancers);
     ps->forward = overrides->forward ? overrides->forward : base->forward;
@@ -1502,24 +1500,6 @@
     return NULL;
 }
 
-/*
- * Set the ports CONNECT can use
- */
-static const char *
-    set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
-{
-    server_rec *s = parms->server;
-    proxy_server_conf *conf =
-        ap_get_module_config(s->module_config, &proxy_module);
-    int *New;
-
-    if (!apr_isdigit(arg[0]))
-        return "AllowCONNECT: port number must be numeric";
-
-    New = apr_array_push(conf->allowed_connect_ports);
-    *New = atoi(arg);
-    return NULL;
-}
 
 /* Similar to set_proxy_exclude(), but defining directly connected hosts,
  * which should never be accessed via the configured ProxyRemote servers
@@ -2109,8 +2089,6 @@
      "A list of domains, hosts, or subnets to which the proxy will connect directly"),
     AP_INIT_TAKE1("ProxyDomain", set_proxy_domain, NULL, RSRC_CONF,
      "The default intranet domain name (in absence of a domain in the URL)"),
-    AP_INIT_ITERATE("AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF,
-     "A list of ports which CONNECT may connect to"),
     AP_INIT_TAKE1("ProxyVia", set_via_opt, NULL, RSRC_CONF,
      "Configure Via: proxy header header to one of: on | off | block | full"),
     AP_INIT_FLAG("ProxyErrorOverride", set_proxy_error_override, NULL, RSRC_CONF,

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy.h?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy.h (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy.h Tue Dec 29 15:39:54 2009
@@ -129,7 +129,6 @@
     apr_array_header_t *aliases;
     apr_array_header_t *noproxies;
     apr_array_header_t *dirconn;
-    apr_array_header_t *allowed_connect_ports;
     apr_array_header_t *workers;
     apr_array_header_t *balancers;
     proxy_worker       *forward;    /* forward proxy worker */

Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c?rev=894425&r1=894424&r2=894425&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c (original)
+++ httpd/httpd/trunk/modules/proxy/mod_proxy_connect.c Tue Dec 29 15:39:54 2009
@@ -46,7 +46,52 @@
  * FIXME: no check for r->assbackwards, whatever that is.
  */
 
-static int allowed_port(proxy_server_conf *conf, int port)
+typedef struct {
+    apr_array_header_t *allowed_connect_ports;
+} connect_conf;
+
+static void *create_config(apr_pool_t *p, server_rec *s)
+{
+    connect_conf *c = apr_pcalloc(p, sizeof(connect_conf));
+    c->allowed_connect_ports = apr_array_make(p, 10, sizeof(int));
+    return c;
+}
+
+static void *merge_config(apr_pool_t *p, void *basev, void *overridesv)
+{
+    connect_conf *c = apr_pcalloc(p, sizeof(connect_conf));
+    connect_conf *base = (connect_conf *) basev;
+    connect_conf *overrides = (connect_conf *) overridesv;
+
+    c->allowed_connect_ports = apr_array_append(p,
+                                                base->allowed_connect_ports,
+                                                overrides->allowed_connect_ports);
+    
+    return c;
+}
+
+
+/*
+ * Set the ports CONNECT can use
+ */
+static const char *
+    set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
+{
+    server_rec *s = parms->server;
+    connect_conf *conf =
+        ap_get_module_config(s->module_config, &proxy_connect_module);
+    int *New;
+
+    if (!apr_isdigit(arg[0]))
+        return "AllowCONNECT: port number must be numeric";
+
+    New = apr_array_push(conf->allowed_connect_ports);
+    *New = atoi(arg);
+    return NULL;
+}
+
+
+static int allowed_port(connect_conf *conf, int port)
 {
     int i;
     int *list = (int *) conf->allowed_connect_ports->elts;
@@ -122,6 +167,9 @@
                                  char *url, const char *proxyname,
                                  apr_port_t proxyport)
 {
+    connect_conf *c_conf =
+        ap_get_module_config(r->server->module_config, &proxy_connect_module);
+
     apr_pool_t *p = r->pool;
     apr_socket_t *sock;
     conn_rec *c = r->connection;
@@ -203,7 +251,7 @@
     }
 
     /* Check if it is an allowed port */
-    if (conf->allowed_connect_ports->nelts == 0) {
+    if (c_conf->allowed_connect_ports->nelts == 0) {
     /* Default setting if not overridden by AllowCONNECT */
         switch (uri.port) {
             case APR_URI_HTTPS_DEFAULT_PORT:
@@ -213,7 +261,7 @@
                  return ap_proxyerror(r, HTTP_FORBIDDEN,
                                       "Connect to remote machine blocked");
         }
-    } else if(!allowed_port(conf, uri.port)) {
+    } else if(!allowed_port(c_conf, uri.port)) {
               return ap_proxyerror(r, HTTP_FORBIDDEN,
                                    "Connect to remote machine blocked");
     }
@@ -442,12 +490,19 @@
     proxy_hook_canon_handler(proxy_connect_canon, NULL, NULL, APR_HOOK_MIDDLE);
 }
 
+static const command_rec cmds[] =
+{
+    AP_INIT_ITERATE("AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF,
+     "A list of ports which CONNECT may connect to"),
+    {NULL}
+};
+
 module AP_MODULE_DECLARE_DATA proxy_connect_module = {
     STANDARD20_MODULE_STUFF,
     NULL,       /* create per-directory config structure */
     NULL,       /* merge per-directory config structures */
-    NULL,       /* create per-server config structure */
-    NULL,       /* merge per-server config structures */
-    NULL,       /* command apr_table_t */
+    create_config,       /* create per-server config structure */
+    merge_config,       /* merge per-server config structures */
+    cmds,       /* command apr_table_t */
     ap_proxy_connect_register_hook  /* register hooks */
 };