]> granicus.if.org Git - apache/commitdiff
Move AllowCONNECT from mod_proxy to mod_proxy_connect.
authorTakashi Sato <takashi@apache.org>
Tue, 29 Dec 2009 15:39:54 +0000 (15:39 +0000)
committerTakashi Sato <takashi@apache.org>
Tue, 29 Dec 2009 15:39:54 +0000 (15:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@894425 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/CHANGES b/CHANGES
index c1e486a4210f3984ef011a44cc5c66b9876f2830..1d23a11e61b273871a7d9d4b148fbaf66288deea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,9 @@ Changes with Apache 2.3.5
      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
index 9b70efa8f318b6cc47210d32de8cf15ed94863a6..bff8168c0b0fc4c7903d4905401073cf48e241cf 100644 (file)
@@ -1085,33 +1085,6 @@ string in <code>Set-Cookie</code> headers.</p>
 </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
index ed8f07d8454d78c9c371d2a77443dfe18ebb329a..b442008ea36a42c74d243510e48ac2bd7bbff5ed 100644 (file)
 <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>
index 96fe1d147dc34158d699b91c8473554670b76ec2..e53717d22473604e9c113182fcad6feae4b9b511 100644 (file)
  * 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
index 584c385b8f9a5b08ca3960eac2f4f43385812fa4..fd7431d0ec3349d71bf484494e5841fd7d0bde80 100644 (file)
@@ -1085,7 +1085,6 @@ static void * create_proxy_config(apr_pool_t *p, server_rec *s)
     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 @@ static void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
     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 @@ static const char *
     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 @@ static const command_rec proxy_cmds[] =
      "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,
index aebfb12a0438522d18c8e1c37dd1c2981dc00fa0..0dee2402b901dda421f1b55a13808604e70ceef5 100644 (file)
@@ -129,7 +129,6 @@ typedef struct {
     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 */
index 5a99da7161a2287e90283fdfd0b4f7b542755812..8fa2f756b2c155c5435f4ca9f6e0a7d1682168f4 100644 (file)
@@ -46,7 +46,52 @@ module AP_MODULE_DECLARE_DATA proxy_connect_module;
  * 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 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
                                  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 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
     }
 
     /* 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 @@ static int proxy_connect_handler(request_rec *r, proxy_worker *worker,
                  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 @@ static void ap_proxy_connect_register_hook(apr_pool_t *p)
     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 */
 };