I got this error when including Lua in the compilation:
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -std=c++11 -I.. -g -I../others -fPIC -O3 -I../headers -DWITH_GEOIP -I/usr/include/ -DWITH_YAJL -DPCRE_HAVE_JIT -DWITH_LUA -I/usr/include -I/usr/include/libxml2 -DWITH_LIBXML2 -g -O2 -MT engine/libmodsecurity_la-lua.lo -MD -MP -MF engine/.deps/libmodsecurity_la-lua.Tpo -c -o engine/libmodsecurity_la-lua.lo `test -f 'engine/lua.cc' || echo './'`engine/lua.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -std=c++11 -I.. -g -I../others -fPIC -O3 -I../headers -DWITH_GEOIP -I/usr/include/ -DWITH_YAJL -DPCRE_HAVE_JIT -DWITH_LUA -I/usr/include -I/usr/include/libxml2 -DWITH_LIBXML2 -g -O2 -MT engine/libmodsecurity_la-lua.lo -MD -MP -MF engine/.deps/libmodsecurity_la-lua.Tpo -c engine/lua.cc -fPIC -DPIC -o engine/.libs/libmodsecurity_la-lua.o
engine/lua.cc: In member function 'bool modsecurity::engine::Lua::load(std::string, std::string*)':
engine/lua.cc:86:75: error: too many arguments to function 'int lua_dump(lua_State*, lua_Writer, void*)'
if (lua_dump(L, Lua::blob_keeper, reinterpret_cast<void *>(&m_blob), 0)) {
^
In file included from /usr/include/lua.hpp:6:0,
from ../src/engine/lua.h:17,
from engine/lua.cc:17:
/usr/include/lua.h:207:14: note: declared here
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
^
engine/lua.cc: In member function 'int modsecurity::engine::Lua::run(modsecurity::Transaction*)':
engine/lua.cc:136:34: error: 'luaL_setfuncs' was not declared in this scope
luaL_setfuncs(L, mscLuaLib, 0);
^
engine/lua.cc:140:13: error: too many arguments to function 'int lua_load(lua_State*, lua_Reader, void*, const char*)'
NULL);
^
In file included from /usr/include/lua.hpp:6:0,
from ../src/engine/lua.h:17,
from engine/lua.cc:17:
/usr/include/lua.h:204:16: note: declared here
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
^
engine/lua.cc:141:15: error: 'LUA_OK' was not declared in this scope
if (rc != LUA_OK) {
^
engine/lua.cc:151:18: error: 'LUA_ERRGCMM' was not declared in this scope
case LUA_ERRGCMM:
^
engine/lua.cc: In static member function 'static std::string modsecurity::engine::Lua::applyTransformations(lua_State*, modsecurity::Transaction*, int, std::string)':
engine/lua.cc:364:37: error: 'lua_rawlen' was not declared in this scope
int i, n = lua_rawlen(L, idx);
^
make[3]: *** [engine/libmodsecurity_la-lua.lo] Error 1
Dependencies
$ rpm -qa|grep lua
lua-5.1.4-15.el7.x86_64
lua-devel-5.1.4-15.el7.x86_64
rpm -qa|grep gcc
gcc-c++-4.8.5-16.el7.x86_64
gcc-4.8.5-16.el7.x86_64
libgcc-4.8.5-16.el7.x86_64
Hi @luengnat,
As of now libModSecurity is fully compatible with Lua 5.3. I'm currently working on a patch to also add support for Lua 5.2 and avoid these errors when Lua <5.2 is used. Unfortunately Lua 5.1 is unsupported for now.
Try upgrading to Lua 5.3 and you should be good.
The documentation said that it should be compatible with 5.1. Sadly, 5.1 is still popular as it is what being distributed with RHEL 7.4. Is there a way to disable LUA if it's already installed?
Hi @luengnat,
Please do notice that the documentation regarding LUA installation on the manual is referring to ModSecurity 2.x. It has been updated to mention LUA support on libModSecurity.
For now there was make a choice to be made in supporting deprecated LUA 5.1 (latest version release on Feb/2012) or supporting a current version like v5.3 (and now v5.2).
Debian, Ubuntu, Fedora and other major distros supports many versions of Lua in parallel for quite some time. It's unfortunate that RHEL / CentOS is stuck with this old version :(
To have LUA support on your case I would suggest using Lua lib binaries which the installation should be as straight forward as downloading, unzipping and then copying the files to /usr/local (or --with-lua=PATH)
If you want to manually disable LUA support use _./configure --without-lua_ or _./configure --with-lua=no_
My Centos 7 workaround (for people who searched this problem, like me)
install lua 5.3 from IUS repo
yum install https://centos7.iuscommunity.org/ius-release.rpm
yum install lua53u lua53u-devel
in modsecurity configure script add lua-5.3 to LUA_POSSIBLE_LIB_NAMES
sed -i 's/^LUA_POSSIBLE_LIB_NAMES.*/LUA_POSSIBLE_LIB_NAMES="lua lua53 lua5.3 lua52 lua5.2 lua-5.3"/g' configure
after that compilation will be fine with Lua enabled
Thanks for your contribution @dmitryzykov. Your fix have been pushed to https://github.com/SpiderLabs/ModSecurity/pull/1855 for evaluation.
Also, Lua 5.1 is now officially supported as of https://github.com/SpiderLabs/ModSecurity/commit/dee989844914f07e38367fb6b1ead906541c0849 and LuaJIT support is being evaluated at https://github.com/SpiderLabs/ModSecurity/pull/1854.
Most helpful comment
My Centos 7 workaround (for people who searched this problem, like me)
install lua 5.3 from IUS repo
in modsecurity
configurescript addlua-5.3toLUA_POSSIBLE_LIB_NAMESsed -i 's/^LUA_POSSIBLE_LIB_NAMES.*/LUA_POSSIBLE_LIB_NAMES="lua lua53 lua5.3 lua52 lua5.2 lua-5.3"/g' configureafter that compilation will be fine with Lua enabled