httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cove...@apache.org
Subject svn commit: r1199056 - in /httpd/httpd/trunk: CHANGES include/ap_mmn.h modules/lua/lua_request.c modules/lua/mod_lua.c modules/lua/mod_lua.h
Date Tue, 08 Nov 2011 01:53:16 GMT
Author: covener
Date: Tue Nov  8 01:53:15 2011
New Revision: 1199056

URL: http://svn.apache.org/viewvc?rev=1199056&view=rev
Log:
mod_lua: Expose SSL variables via r:ssl_var_lookup()

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/modules/lua/lua_request.c
    httpd/httpd/trunk/modules/lua/mod_lua.c
    httpd/httpd/trunk/modules/lua/mod_lua.h

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1199056&r1=1199055&r2=1199056&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Nov  8 01:53:15 2011
@@ -16,6 +16,8 @@ Changes with Apache 2.3.15
      core: Fix integer overflow in ap_pregsub. This can be triggered e.g.
      with mod_setenvif via a malicious .htaccess. [Stefan Fritsch]
 
+  *) mod_lua: Expose SSL variables via r:ssl_var_lookup().  [Eric Covener]
+
   *) mod_lua: LuaHook{AccessChecker,AuthChecker,CheckUserID,TranslateName}
      can now additionally be run as "early" or "late" relative to other modules.
      [Eric Covener]

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1199056&r1=1199055&r2=1199056&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Nov  8 01:53:15 2011
@@ -364,6 +364,7 @@
  *                         add ap_pregsub_ex()
  * 20111025.1 (2.3.15-dev) Add ap_escape_urlencoded(), ap_escape_urlencoded_buffer()
  *                         and ap_unescape_urlencoded().
+ * 20111025.2 (2.3.15-dev) Add ap_lua_ssl_val to mod_lua
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -371,7 +372,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20111025
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 1                   /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 2                   /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/modules/lua/lua_request.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/lua_request.c?rev=1199056&r1=1199055&r2=1199056&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/lua_request.c (original)
+++ httpd/httpd/trunk/modules/lua/lua_request.c Tue Nov  8 01:53:15 2011
@@ -217,6 +217,16 @@ static int req_escape_html(lua_State *L)
     lua_pushstring(L, ap_escape_html(r->pool, s));
     return 1;
 }
+/* wrap optional ssl_var_lookup as  r:ssl_var_lookup(String) */
+static int req_ssl_var_lookup(lua_State *L)
+{
+    request_rec *r = ap_lua_check_request_rec(L, 1);
+    const char *s = luaL_checkstring(L, 2);
+    const char *res = ap_lua_ssl_val(r->pool, r->server, r->connection, r, 
+                                     (char *)s);
+    lua_pushstring(L, res);
+    return 1;
+}
 /* BEGIN dispatch mathods for request_rec fields */
 
 /* not really a field, but we treat it like one */
@@ -602,6 +612,8 @@ AP_LUA_DECLARE(void) ap_lua_load_request
                  makefun(&req_construct_url, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "escape_html", APR_HASH_KEY_STRING,
                  makefun(&req_escape_html, APL_REQ_FUNTYPE_LUACFUN, p));
+    apr_hash_set(dispatch, "ssl_var_lookup", APR_HASH_KEY_STRING,
+                 makefun(&req_ssl_var_lookup, APL_REQ_FUNTYPE_LUACFUN, p));
     apr_hash_set(dispatch, "assbackwards", APR_HASH_KEY_STRING,
                  makefun(&req_assbackwards_field, APL_REQ_FUNTYPE_BOOLEAN, p));
     apr_hash_set(dispatch, "status", APR_HASH_KEY_STRING,

Modified: httpd/httpd/trunk/modules/lua/mod_lua.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.c?rev=1199056&r1=1199055&r2=1199056&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.c (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.c Tue Nov  8 01:53:15 2011
@@ -22,6 +22,8 @@
 
 #include "lua_apr.h"
 #include "lua_config.h"
+#include "apr_optional.h"
+#include "mod_ssl.h"
 
 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_lua, AP_LUA, int, lua_open,
                                     (lua_State *L, apr_pool_t *p),
@@ -30,6 +32,7 @@ APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_l
 APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_lua, AP_LUA, int, lua_request,
                                     (lua_State *L, request_rec *r),
                                     (L, r), OK, DECLINED)
+static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *lua_ssl_val = NULL;
 
      module AP_MODULE_DECLARE_DATA lua_module;
 
@@ -1006,6 +1009,13 @@ static const char *register_lua_root(cmd
     cfg->root_path = root;
     return NULL;
 }
+AP_LUA_DECLARE(const char *) ap_lua_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec
*r, const char *var)
+{
+    if (lua_ssl_val) { 
+        return (const char *)lua_ssl_val(p, s, c, r, (char *)var);
+    }
+    return NULL;
+}
 
 /*******************************/
 
@@ -1149,6 +1159,13 @@ static int lua_request_hook(lua_State *L
     return OK;
 }
 
+static int lua_post_config(apr_pool_t *pconf, apr_pool_t *plog,
+                             apr_pool_t *ptemp, server_rec *s)
+{
+    lua_ssl_val = APR_RETRIEVE_OPTIONAL_FN(ssl_var_lookup);
+    return OK;
+}
+
 static void lua_register_hooks(apr_pool_t *p)
 {
     /* ap_register_output_filter("luahood", luahood, NULL, AP_FTYPE_RESOURCE); */
@@ -1196,6 +1213,7 @@ static void lua_register_hooks(apr_pool_
     ap_hook_quick_handler(lua_quick_harness, NULL, NULL, APR_HOOK_FIRST);
 
     ap_hook_translate_name(lua_alias_munger, NULL, NULL, APR_HOOK_MIDDLE);
+    ap_hook_post_config(lua_post_config, NULL, NULL, APR_HOOK_MIDDLE);
 
     APR_OPTIONAL_HOOK(ap_lua, lua_open, lua_open_hook, NULL, NULL,
                       APR_HOOK_REALLY_FIRST);

Modified: httpd/httpd/trunk/modules/lua/mod_lua.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/lua/mod_lua.h?rev=1199056&r1=1199055&r2=1199056&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/lua/mod_lua.h (original)
+++ httpd/httpd/trunk/modules/lua/mod_lua.h Tue Nov  8 01:53:15 2011
@@ -148,4 +148,6 @@ APR_DECLARE_EXTERNAL_HOOK(ap_lua, AP_LUA
 APR_DECLARE_EXTERNAL_HOOK(ap_lua, AP_LUA, int, lua_request,
                           (lua_State *L, request_rec *r))
 
+AP_LUA_DECLARE(const char *) ap_lua_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec
*r, const char *var);
+
 #endif /* !_MOD_LUA_H_ */



Mime
View raw message