Extends Lua implementation to support Lua 5.3

This commit is contained in:
Felipe Zimmerle 2016-01-08 09:24:12 -03:00
Родитель 74558b42e4
Коммит 05bcafd4fc
3 изменённых файлов: 22 добавлений и 8 удалений

Просмотреть файл

@ -1,6 +1,8 @@
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
introduced).
[Issue #881 - Ishwor Gurung]

Просмотреть файл

@ -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 *));
#if LUA_VERSION_NUM >= 503
lua_dump(L, dump_writer, &dump, 1);
lua_dump(L, dump_writer, &dump, 0);
#else
lua_dump(L, dump_writer, &dump);
#endif
@ -420,23 +420,32 @@ int lua_execute(msc_script *script, char *param, modsec_rec *msr, msre_rule *rul
time_before = apr_time_now();
#ifdef CACHE_LUA
L = msr->L;
rc = lua_gettop(L);
if(rc)
lua_pop(L, rc);
#else
/* Create new state. */
#if LUA_VERSION_NUM > 501
#if LUA_VERSION_NUM == 502 || LUA_VERSION_NUM == 503 || LUA_VERSION_NUM == 501
L = luaL_newstate();
#else
#elif LUA_VERSION_NUM == 500
L = lua_open();
#else
#error We are only tested under Lua 5.0, 5.1, 5.2, or 5.3.
#endif
luaL_openlibs(L);
#endif
if(L == NULL)
return -1;
luaL_newmetatable(L, "luaL_msc");
lua_newtable(L);
/* Associate msr with the state. */
lua_pushlightuserdata(L, (void *)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. */
#if LUA_VERSION_NUM > 501
luaL_setfuncs(L,mylib,0);
lua_setglobal(L,"m");
#else
#if LUA_VERSION_NUM == 500 || LUA_VERSION_NUM == 501
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
lua_setglobal(L, "m");
rc = lua_restore(L, script);
if (rc) {
*error_msg = apr_psprintf(msr->mp, "Lua: Failed to restore script with %i.", rc);

Просмотреть файл

@ -16,7 +16,7 @@ LUA_CPPFLAGS=""
LUA_LDADD=""
LUA_LDFLAGS=""
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"
AC_ARG_WITH(