Bug 186281 - www/mod_limitipconn2: Add local IP exception patch
Summary: www/mod_limitipconn2: Add local IP exception patch
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Olli Hauer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-30 17:00 UTC by Tilghman Lesher
Modified: 2014-02-02 16:00 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tilghman Lesher 2014-01-30 17:00:00 UTC
This is a request for the port maintainer to include the following patch from the upstream site:
http://dominia.org/djao/limit/contrib/dg/mod_limitipconn_local_IP_patch_2.diff

This patch adds the LocalIP directive, permitting a list of IP addresses from which to exclude the limitation provided elsewhere by the directives in this Apache module.

The patch only needs to be renamed with a patch- prefix and placed in the files/ subdirectory of the port.  It patches and compiles cleanly with no complaints.

Fix: 

N/A
How-To-Repeat: N/A
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2014-01-31 04:36:12 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-ports-bugs

ports PR.
Comment 2 Edwin Groothuis freebsd_committer freebsd_triage 2014-01-31 04:36:34 UTC
Responsible Changed
From-To: freebsd-ports-bugs->apache

apache@ wants this port PRs (via the GNATS Auto Assign Tool)
Comment 3 Edwin Groothuis freebsd_committer freebsd_triage 2014-01-31 04:36:35 UTC
Maintainer of www/mod_limitipconn2,

Please note that PR ports/186281 has just been submitted.

If it contains a patch for an upgrade, an enhancement or a bug fix
you agree on, reply to this email stating that you approve the patch
and a committer will take care of it.

The full text of the PR can be found at:
    http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/186281

-- 
Edwin Groothuis via the GNATS Auto Assign Tool
edwin@FreeBSD.org
Comment 4 Edwin Groothuis freebsd_committer freebsd_triage 2014-01-31 04:36:36 UTC
State Changed
From-To: open->feedback

Awaiting maintainers feedback (via the GNATS Auto Assign Tool)
Comment 5 Olli Hauer freebsd_committer freebsd_triage 2014-01-31 06:07:54 UTC
Responsible Changed
From-To: apache->ohauer

I'll take it
Comment 6 dfilter service freebsd_committer freebsd_triage 2014-02-02 15:57:21 UTC
Author: ohauer
Date: Sun Feb  2 15:57:13 2014
New Revision: 342319
URL: http://svnweb.freebsd.org/changeset/ports/342319
QAT: https://qat.redports.org/buildarchive/r342319/

Log:
  - update to version 0.24
  - add local IP exception patch [1]
    found on upstream (mod_limitipconn_local_IP_patch.diff)
  
  PR:		ports/186281 [1]
  Submitted by:	Tilghman Lesher <tlesher@mtadistributors.com>
  Approved by:	Yuan-Chung Hsiao <ychsiao@gmail.com> (maintainer per PM)

Added:
  head/www/mod_limitipconn2/files/
  head/www/mod_limitipconn2/files/patch-mod_limitipconn.c   (contents, props changed)
Modified:
  head/www/mod_limitipconn2/Makefile
  head/www/mod_limitipconn2/distinfo

Modified: head/www/mod_limitipconn2/Makefile
==============================================================================
--- head/www/mod_limitipconn2/Makefile	Sun Feb  2 15:47:08 2014	(r342318)
+++ head/www/mod_limitipconn2/Makefile	Sun Feb  2 15:57:13 2014	(r342319)
@@ -2,8 +2,7 @@
 # $FreeBSD$
 
 PORTNAME=	mod_limitipconn
-PORTVERSION=	0.23
-PORTREVISION=	3
+PORTVERSION=	0.24
 CATEGORIES=	www
 MASTER_SITES=	http://dominia.org/djao/limit/
 PKGNAMEPREFIX=	${APACHE_PKGNAMEPREFIX}
@@ -15,7 +14,7 @@ COMMENT=	Allows you to limit the number 
 
 LICENSE=	APACHE20
 
-USE_APACHE=	22
+USE_APACHE=	22+
 USE_BZIP2=	yes
 
 AP_FAST_BUILD=	yes

Modified: head/www/mod_limitipconn2/distinfo
==============================================================================
--- head/www/mod_limitipconn2/distinfo	Sun Feb  2 15:47:08 2014	(r342318)
+++ head/www/mod_limitipconn2/distinfo	Sun Feb  2 15:57:13 2014	(r342319)
@@ -1,2 +1,2 @@
-SHA256 (apache2/mod_limitipconn-0.23.tar.bz2) = eca35131e2d17b4499d7be13190cc0cdd5c82d83660b8bc96c79dc617defa6ec
-SIZE (apache2/mod_limitipconn-0.23.tar.bz2) = 9851
+SHA256 (apache2/mod_limitipconn-0.24.tar.bz2) = 69ca8fbf99d4e02db75e129df07d1604db771e9c10c1b199e2accaa96aec2a1f
+SIZE (apache2/mod_limitipconn-0.24.tar.bz2) = 10150

Added: head/www/mod_limitipconn2/files/patch-mod_limitipconn.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/www/mod_limitipconn2/files/patch-mod_limitipconn.c	Sun Feb  2 15:57:13 2014	(r342319)
@@ -0,0 +1,92 @@
+--- ./mod_limitipconn.c.orig	2012-04-26 00:19:48.000000000 +0200
++++ ./mod_limitipconn.c	2014-02-02 16:47:28.000000000 +0100
+@@ -42,6 +42,9 @@
+     /* array of MIME types to limit check; all other types are exempt */
+     apr_array_header_t *excl_limit;
+ 
++    apr_array_header_t *local_ip;   /* array of local ip exempt from limit
++    				checking */
++
+ } limitipconn_config;
+ 
+ static limitipconn_config *create_config(apr_pool_t *p)
+@@ -53,6 +56,7 @@
+     cfg->limit = 0;
+     cfg->no_limit = apr_array_make(p, 0, sizeof(char *));
+     cfg->excl_limit = apr_array_make(p, 0, sizeof(char *));
++    cfg->local_ip = apr_array_make(p, 0, sizeof(char *));
+ 
+     return cfg;
+ }
+@@ -75,6 +79,7 @@
+     /* convert Apache arrays to normal C arrays */
+     char **nolim = (char **) cfg->no_limit->elts;
+     char **exlim = (char **) cfg->excl_limit->elts;
++    char **localip = (char **) cfg->local_ip->elts;
+ 
+     const char *address;
+ 
+@@ -112,7 +117,7 @@
+ 
+     /* Only check the MIME-type if we have MIME-type stuff in our config.
+        The extra subreq can be quite expensive. */
+-    if(cfg->no_limit->nelts > 0 || cfg->excl_limit->nelts > 0) {
++    if(cfg->no_limit->nelts > 0 || cfg->excl_limit->nelts > 0 || cfg->local_ip->nelts) {
+         /* Look up the Content-type of this request. We need a subrequest
+          * here since this module might be called before the URI has been
+          * translated into a MIME type. */
+@@ -129,6 +134,20 @@
+                 "mod_limitipconn: uri: %s  Content-Type: %s", 
+                 r->uri, content_type);
+ 
++     	/* Cycle through the local ip list; if the ip is local,
++     	 * return OK */
++
++     	for (i = 0; i < cfg->local_ip->nelts; i++) {
++	  ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
++	  	"mod_limitipconn: ip check: \"%s\" ? \"%s\"", address, localip[i]);
++     	  if ((ap_strcasecmp_match(address, localip[i]) == 0)
++     	      || (strncmp(localip[i], address, strlen(localip[i])) == 0)) {
++	      ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
++	      	"mod_limitipconn: ip exempt: %s", address);
++     	      return DECLINED;
++     	  }
++     	}
++
+         /* Cycle through the exempt list; if our content_type is exempt,
+          * return OK */
+ #if AP_MODULE_MAGIC_AT_LEAST(20090131, 0)
+@@ -328,6 +347,24 @@
+     return NULL;
+ }
+ 
++/* Parse the LocalIP directive */
++static const char *local_ip_config_cmd(cmd_parms *parms, void *mconfig,
++					 const char *arg)
++{
++    limitipconn_config *cfg = (limitipconn_config *) mconfig;
++    limitipconn_config *scfg = (limitipconn_config *)
++      ap_get_module_config(parms->server->module_config, &limitipconn_module);
++
++    if (parms->path != NULL) {
++      /* Per-directory context */
++      *(char **) apr_array_push(cfg->local_ip) = apr_pstrdup(parms->pool, arg);
++    } else {
++      /* global context */
++      *(char **) apr_array_push(scfg->local_ip) = apr_pstrdup(parms->pool, arg);
++    }
++    return NULL;
++}
++
+ /* Array describing structure of configuration directives */
+ static command_rec limitipconn_cmds[] = {
+     AP_INIT_TAKE1("MaxConnPerIP", limit_config_cmd, NULL, OR_LIMIT|RSRC_CONF,
+@@ -336,6 +373,8 @@
+      "MIME types for which limit checking is disabled"),
+     AP_INIT_ITERATE("OnlyIPLimit", excl_limit_config_cmd, NULL,
+      OR_LIMIT|RSRC_CONF, "restrict limit checking to these MIME types only"),
++     AP_INIT_ITERATE("LocalIP", local_ip_config_cmd, NULL, OR_LIMIT|RSRC_CONF,
++           "no checking on local IP"),
+     {NULL},
+ };
+ 
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 7 Olli Hauer freebsd_committer freebsd_triage 2014-02-02 15:57:40 UTC
State Changed
From-To: feedback->closed

Committed together with an update to version 0.24! 

Thanks for your PR!