Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error with LUA for libmodsecurity 3.0 #1622

Closed
luengnat opened this issue Nov 20, 2017 · 5 comments
Closed

Compiler error with LUA for libmodsecurity 3.0 #1622

luengnat opened this issue Nov 20, 2017 · 5 comments

Comments

@luengnat
Copy link

luengnat commented Nov 20, 2017

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
@victorhora
Copy link
Contributor

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.

@luengnat
Copy link
Author

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?

@victorhora
Copy link
Contributor

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)

#1623 should avoid breaking the compilation if LUA 5.1 is being used by disabling LUA support.

If you want to manually disable LUA support use ./configure --without-lua or ./configure --with-lua=no

@dmitryzykov
Copy link

dmitryzykov commented Jan 9, 2018

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

@victorhora
Copy link
Contributor

Thanks for your contribution @dmitryzykov. Your fix have been pushed to #1855 for evaluation.

Also, Lua 5.1 is now officially supported as of dee9898 and LuaJIT support is being evaluated at #1854.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants