httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rodent of Unusual Size <Ken.C...@Golux.Com>
Subject [patch] add 'server_addr' to setenvif specials
Date Wed, 06 Nov 2002 22:01:16 GMT
another case that has come through (hopefully less controversial
than the last one)..  the apparent inability to set envariables
according to the ipa on which the request was received.  we log
it with %A, but currently can't test it.  the patch below adds
'SERVER_ADDR' to the list of specials mod_setenvif understands;
i'm using that name because ap_add_common_vars() sets it, but
much too late for setenvif to be able to use it, and only in certain
cases anyway.

possible usage:

SetEnvIf SERVER_ADDR 127.0.0.1 local_nic=1
<Location /foo>
    Order Deny,Allow
    Satisfy All
    Deny from env=local_nic
</Location>

to keep the /foo location from being accessed through the loopback
address.  (don't ask me why, it's just an example i dreamed up.)

i have a corresponding patch for 1.3 that i would also like
considered, slow though that branch may be. :-)

the patch:

Index: modules/metadata/mod_setenvif.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_setenvif.c,v
retrieving revision 1.37
diff -u -r1.37 mod_setenvif.c
--- modules/metadata/mod_setenvif.c	4 Nov 2002 18:17:50 -0000	1.37
+++ modules/metadata/mod_setenvif.c	6 Nov 2002 21:54:46 -0000
@@ -92,6 +92,8 @@
  *
  * Special values for 'name' are:
  *
+ *   server_addr      	IP address of interface on which request arrived
+ *			(analogous to SERVER_ADDR set in ap_add_common_vars())
  *   remote_host        Remote host name (if available)
  *   remote_addr        Remote IP address
  *   remote_user        Remote authenticated user (if any)
@@ -143,7 +145,8 @@
     SPECIAL_REMOTE_USER,
     SPECIAL_REQUEST_URI,
     SPECIAL_REQUEST_METHOD,
-    SPECIAL_REQUEST_PROTOCOL
+    SPECIAL_REQUEST_PROTOCOL,
+    SPECIAL_SERVER_ADDR
 };
 typedef struct {
     char *name;                 /* header name */
@@ -376,6 +379,9 @@
         else if (!strcasecmp(fname, "request_protocol")) {
             new->special_type = SPECIAL_REQUEST_PROTOCOL;
         }
+        else if (!strcasecmp(fname, "server_addr")) {
+            new->special_type = SPECIAL_SERVER_ADDR;
+        }
         else {
             new->special_type = SPECIAL_NOT;
             /* Handle fname as a regular expression.
@@ -508,6 +514,9 @@
             switch (b->special_type) {
             case SPECIAL_REMOTE_ADDR:
                 val = r->connection->remote_ip;
+                break;
+            case SPECIAL_SERVER_ADDR:
+                val = r->connection->local_ip;
                 break;
             case SPECIAL_REMOTE_HOST:
                 val =  ap_get_remote_host(r->connection, r->per_dir_config,

Mime
View raw message