]> granicus.if.org Git - apache/commitdiff
mod_ssl: Extend expression parser registration
authorRainer Jung <rjung@apache.org>
Tue, 6 Oct 2015 11:30:01 +0000 (11:30 +0000)
committerRainer Jung <rjung@apache.org>
Tue, 6 Oct 2015 11:30:01 +0000 (11:30 +0000)
to support ssl variables in any expression
using mod_rewrite syntax "%{SSL:VARNAME}" or
function syntax "ssl(VARIABLE)".

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1707002 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/mod/mod_ssl.xml
modules/ssl/ssl_engine_vars.c

diff --git a/CHANGES b/CHANGES
index 9c055a24767c89e2cc7fb64ecfcd19ebfb058656..3a02b64cbfdc82ca9b1f64196742b2cd89a618ab 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) mod_ssl: Extend expression parser registration to support ssl variables
+     in any expression using mod_rewrite syntax "%{SSL:VARNAME}" or function
+     syntax "ssl(VARIABLE)". [Rainer Jung]
+
   *) core: Extend support for asynchronous write completion from the
      network filter to any connection or request filter. [Graham Leggett]
 
index a640c9f1f55651796cc67d102e7c7942f8c91cba..350a2318b9bed59446bdb958c30146e7d5ac8a17 100644 (file)
@@ -216,6 +216,30 @@ string in <module>mod_log_config</module>.</p>
 
 </section>
 
+<section id="expressionparser"><title>Expression Parser Extension</title>
+
+<p>When <module>mod_ssl</module> is built into Apache or at least
+loaded (under DSO situation) any <a name="envvars">variables</a>
+provided by <module>mod_ssl</module> can be used in expressions
+for the <a href="../expr.html">ap_expr Expression Parser</a>.
+The variables can be referenced using the syntax
+``<code>%{</code><em>varname</em><code>}</code>''. Starting
+with version 2.4.17 one can also use the
+<module>mod_rewrite</module> style syntax
+``<code>%{SSL:</code><em>varname</em><code>}</code>'' or
+the function style syntax
+``<code>ssl(</code><em>varname</em><code>)</code>''.</p>
+<example><title>Example (using <module>mod_headers</module>)</title>
+<highlight language="config">
+Header set X-SSL-PROTOCOL "expr=%{SSL_PROTOCOL}"
+Header set X-SSL-CIPHER "expr=%{SSL:SSL_CIPHER}"
+</highlight>
+</example>
+<p>This feature even works without setting the <code>StdEnvVars</code>
+option of the <directive module="mod_ssl">SSLOptions</directive>
+directive.</p>
+</section>
+
 <section id="authzproviders"><title>Authorization providers for use with Require</title>
 
   <p><module>mod_ssl</module> provides a few authentication providers for use
index f97ce590cadf6332e3549a491459bec2f1c56af2..25e6882dc78767dd5b283cdc40c7fc3f4d000a34 100644 (file)
@@ -149,6 +149,14 @@ static const char *expr_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
     return sslconn ? ssl_var_lookup_ssl(ctx->p, ctx->c, ctx->r, var) : NULL;
 }
 
+static const char *expr_func_fn(ap_expr_eval_ctx_t *ctx, const void *data,
+                                const char *arg)
+{
+    char *var = (char *)arg;
+
+    return var ? ssl_var_lookup(ctx->p, ctx->s, ctx->c, ctx->r, var) : NULL;
+}
+
 static int ssl_expr_lookup(ap_expr_lookup_parms *parms)
 {
     switch (parms->type) {
@@ -163,6 +171,15 @@ static int ssl_expr_lookup(ap_expr_lookup_parms *parms)
             return OK;
         }
         break;
+    case AP_EXPR_FUNC_STRING:
+        /* Function SSL() is implemented by us.
+         */
+        if (strcEQ(parms->name, "SSL")) {
+            *parms->func = expr_func_fn;
+            *parms->data = NULL;
+            return OK;
+        }
+        break;
     case AP_EXPR_FUNC_LIST:
         if (strcEQ(parms->name, "PeerExtList")) {
             *parms->func = expr_peer_ext_list_fn;