Bug 44478 - Add SetEnvIfIP to set env vars depneding on ip subnet matches
Summary: Add SetEnvIfIP to set env vars depneding on ip subnet matches
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_setenvif (show other bugs)
Version: 2.5-HEAD
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2008-02-24 07:57 UTC by Rainer Jung
Modified: 2012-02-26 16:48 UTC (History)
1 user (show)



Attachments
Add SetEnvIfIP address match to mod_setenvif.c in trunk (12.25 KB, patch)
2008-02-24 07:58 UTC, Rainer Jung
Details | Diff
Add SetEnvIfIP address match to mod_setenvif.c for 2.2.x (12.25 KB, patch)
2008-02-24 07:59 UTC, Rainer Jung
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Jung 2008-02-24 07:57:56 UTC
mod_authz_host allows Allow/Deny to depend on the presence of an environment
variable. Although it would be nice to set appropriate env vars once and then
use the env var in various places inside Allow/Deny, this doesn't really work in
practise, because there is no clean way of setting them w.r.t. IP addresses.

In simple network cases, people use string patterns and setenvif. When more
complex netmasks are involved, string matches against IP addresses don't work well.

The attached patch includes SetEnvIfIP that allows all notations, that
Allow/Deny provide (ful IP, partial IP, network/netmask, network/nnn CIDR).

I provide a patch against trunk (r420983, which is actual today) and one against
2.2 (r421103).

IP matches are allowed against remote_addr and also server_addr (because the
latter was simple, but maybe not really useful), also there are domain name
matches, which are allowed against everything that mod_setenvf accepts.

If there is some interest, I would see, how to also provide this feature as a
RewriteCond fpr mod_rewrite.
Comment 1 Rainer Jung 2008-02-24 07:58:48 UTC
Created attachment 21584 [details]
Add SetEnvIfIP address match to mod_setenvif.c in trunk
Comment 2 Rainer Jung 2008-02-24 07:59:15 UTC
Created attachment 21585 [details]
Add SetEnvIfIP address match to mod_setenvif.c for 2.2.x
Comment 3 Rainer Jung 2008-02-24 08:00:15 UTC
The patch is related to patch

http://issues.apache.org/bugzilla/show_bug.cgi?id=41857

but includes slightly more functionality.
Comment 4 Stefan Fritsch 2010-11-28 16:17:46 UTC
The new SetEnvIfExpr directive allows to match by subnet/netmask.
See r1039900
Comment 5 Stefan Fritsch 2012-02-26 16:48:17 UTC
2.4.1 is released, closing