httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: RewriteCond and SSL environment variables
Date Wed, 03 Mar 2004 20:57:11 GMT
On Wed, Mar 03, 2004 at 07:47:21PM +0100, André Malo wrote:
> * Joe Orton <jorton@redhat.com> wrote:
> 
> > > Sounds good. But we'd need to hook the variable creation earlier anyway,
> > > since ssl_var_lookup finally just uses r->subprocess_env.
> > 
> > I don't see how that follows; if you're just trying to retrieve a
> > non-SSL subprocess_env var via ssl_var_lookup(), why would registering
> > the SSL variables earlier make a difference?
> 
> Because ssl_var_lookup uses r->subprocess_env, which is not filled at early
> stage (and never filled without SSLOptions +StdEnvVars) with SSL stuff.

I think you've got it backwards: ssl_var_lookup always generates the SSL
variables on the fly; it is used by the fixup handler to populate
r->subprocess_env if +StdEnvVars, but works exactly the same regardless
of that config option.

What I'm proposing is something as simple as below, which lets you do
"RewriteCond %{SSL:HTTPS} =on" without needing +StdEnvVars...  are we on
the same page?

--- modules/mappers/mod_rewrite.c	9 Feb 2004 20:29:20 -0000	1.252
+++ modules/mappers/mod_rewrite.c	3 Mar 2004 20:54:15 -0000
@@ -89,6 +89,8 @@
 #include "http_protocol.h"
 #include "http_vhost.h"
 
+#include "mod_ssl.h"
+
 #include "mod_rewrite.h"
 
 #if !defined(OS2) && !defined(WIN32) && !defined(BEOS)  && !defined(NETWARE)
@@ -380,6 +382,7 @@
 static apr_global_mutex_t *rewrite_log_lock = NULL;
 #endif
 
+static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *rewrite_ssl_lookup = NULL;
 
 /*
  * +-------------------------------------------------------+
@@ -1610,6 +1613,10 @@
                 result = getenv(var);
             }
         }
+        else if (var[4] && !strncasecmp(var, "SSL", 3)) {
+            result = rewrite_ssl_lookup(r->pool, r->server, r->connection, r,
+                                        var + 4);
+        }
     }
     else if (var[4] == ':') {
         if (var[5]) {
@@ -3995,6 +4002,8 @@
             }
         }
     }
+
+    rewrite_ssl_lookup = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
 
     return OK;
 }

Mime
View raw message