Extends Lua implementation to support Lua 5.3

This commit is contained in:
Felipe Zimmerle 2016-01-08 09:24:12 -03:00
parent 74558b42e4
commit 05bcafd4fc
3 changed files with 22 additions and 8 deletions

View File

@ -1,6 +1,8 @@
DD mmm YYYY - X.Y.Z (To be released) DD mmm YYYY - X.Y.Z (To be released)
------------------------------------ ------------------------------------
* Extanded Lua support to include version 5.3
[Issue #837, #762, #814 - Athmane Madjoudj and ModSecurity team]
* mlogc: Allow user to choose between TLS versions (TLSProtocol option * mlogc: Allow user to choose between TLS versions (TLSProtocol option
introduced). introduced).
[Issue #881 - Ishwor Gurung] [Issue #881 - Ishwor Gurung]

View File

@ -112,7 +112,7 @@ char *lua_compile(msc_script **script, const char *filename, apr_pool_t *pool) {
dump.parts = apr_array_make(pool, 128, sizeof(msc_script_part *)); dump.parts = apr_array_make(pool, 128, sizeof(msc_script_part *));
#if LUA_VERSION_NUM >= 503 #if LUA_VERSION_NUM >= 503
lua_dump(L, dump_writer, &dump, 1); lua_dump(L, dump_writer, &dump, 0);
#else #else
lua_dump(L, dump_writer, &dump); lua_dump(L, dump_writer, &dump);
#endif #endif
@ -420,23 +420,32 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
time_before = apr_time_now(); time_before = apr_time_now();
#ifdef CACHE_LUA #ifdef CACHE_LUA
L = msr->L; L = msr->L;
rc = lua_gettop(L); rc = lua_gettop(L);
if(rc) if(rc)
lua_pop(L, rc); lua_pop(L, rc);
#else #else
/* Create new state. */ /* Create new state. */
#if LUA_VERSION_NUM > 501 #if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 501
L = luaL_newstate(); L = luaL_newstate();
#else #elif LUA_VERSION_NUM == 500
L = lua_open(); L = lua_open();
#else
#error We are only tested under Lua 5.0, 5.1, 5.2, or 5.3.
#endif #endif
luaL_openlibs(L); luaL_openlibs(L);
#endif #endif
if(L == NULL) if(L == NULL)
return -1; return -1;
luaL_newmetatable(L, "luaL_msc");
lua_newtable(L);
/* Associate msr with the state. */ /* Associate msr with the state. */
lua_pushlightuserdata(L, (void *)msr); lua_pushlightuserdata(L, (void *)msr);
lua_setglobal(L, "__msr"); lua_setglobal(L, "__msr");
@ -448,13 +457,16 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
} }
/* Register functions. */ /* Register functions. */
#if LUA_VERSION_NUM > 501 #if LUA_VERSION_NUM == 500 || LUA_VERSION_NUM == 501
luaL_setfuncs(L,mylib,0);
lua_setglobal(L,"m");
#else
luaL_register(L, "m", mylib); luaL_register(L, "m", mylib);
#elif LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503
luaL_setfuncs(L, mylib, 0);
#else
#error We are only tested under Lua 5.0, 5.1, 5.2, or 5.3.
#endif #endif
lua_setglobal(L, "m");
rc = lua_restore(L, script); rc = lua_restore(L, script);
if (rc) { if (rc) {
*error_msg = apr_psprintf(msr->mp, "Lua: Failed to restore script with %i.", rc); *error_msg = apr_psprintf(msr->mp, "Lua: Failed to restore script with %i.", rc);

View File

@ -16,7 +16,7 @@ LUA_CPPFLAGS=""
LUA_LDADD="" LUA_LDADD=""
LUA_LDFLAGS="" LUA_LDFLAGS=""
LUA_CONFIG=${PKG_CONFIG} LUA_CONFIG=${PKG_CONFIG}
LUA_PKGNAMES="lua5.1 lua-5.1 lua_5.1 lua-51 lua_51 lua51 lua5 lua" LUA_PKGNAMES="lua5.1 lua-5.1 lua_5.1 lua-51 lua_51 lua51 lua5 lua lua5.2 lua-5.2 lua_5.2 lua-52 lua_52 lua52 lua5.3 lua-5.3 lua_5.3 lua-53 lua_53 lua53 "
LUA_SONAMES="so la sl dll dylib a" LUA_SONAMES="so la sl dll dylib a"
AC_ARG_WITH( AC_ARG_WITH(