Skip to content

Debian 9 build package fails with undefined reference to lua_* #2039

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

Closed
Metztli opened this issue Mar 5, 2019 · 5 comments
Closed

Debian 9 build package fails with undefined reference to lua_* #2039

Metztli opened this issue Mar 5, 2019 · 5 comments
Assignees
Labels
3.x Related to ModSecurity version 3.x
Milestone

Comments

@Metztli
Copy link

Metztli commented Mar 5, 2019

Debian 9 AMD64 build fails with four(4) undefined reference to lua_* directives

...
Making all in rules-check
make[3]: Entering directory '/usr/src/build/tekitl/ModSecurity/tools/rules-check'
/bin/bash ../../libtool --tag=CXX --mode=link g++ -g -O2 -fdebug-prefix-map=/usr/src/build/tekitl/ModSecurity=. -fstack-protector-strong -Wformat -
Werror=format-security -Wl,-z,relro -lpcre -L/usr/lib/x86_64-linux-gnu/ -L/usr/lib/x86_64-linux-gnu/ -Wl,-z,relro -lpcre -o modsec-rules-check mods
ec_rules_check-rules-check.o ../../src/.libs/libmodsecurity.la -lcurl -lGeoIP -lmaxminddb -lrt -lxml2 -llmdb -lluajit-5.1 -lpcre -lpcre -lfuzzy -lyaj
l
libtool: link: g++ -g -O2 -fdebug-prefix-map=/usr/src/build/tekitl/ModSecurity=. -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z -Wl,r
elro -Wl,-z -Wl,relro -o .libs/modsec-rules-check modsec_rules_check-rules-check.o -L/usr/lib/x86_64-linux-gnu/ ../../src/.libs/libmodsecurity.so /usr
/lib/x86_64-linux-gnu/libcurl-gnutls.so -lGeoIP -lmaxminddb -lrt -lxml2 -llmdb -lluajit-5.1 -lpcre -lfuzzy -lyajl -pthread
../../src/.libs/libmodsecurity.so: undefined reference to lua_setglobal' ../../src/.libs/libmodsecurity.so: undefined reference to lua_pcallk'
../../src/.libs/libmodsecurity.so: undefined reference to lua_getglobal' ../../src/.libs/libmodsecurity.so: undefined reference to lua_rawlen'
collect2: error: ld returned 1 exit status
make[3]: *** [modsec-rules-check] Error 1
Makefile:552: recipe for target 'modsec-rules-check' failed
make[3]: Leaving directory '/usr/src/build/tekitl/ModSecurity/tools/rules-check'
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
dh_auto_build: make -j1 returned exit code 2
Makefile:486: recipe for target 'all-recursive' failed
make[2]: Leaving directory '/usr/src/build/tekitl/ModSecurity/tools'
Makefile:1020: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/usr/src/build/tekitl/ModSecurity'
make: *** [binary-arch] Error 2
debian/rules:9: recipe for target 'binary-arch' failed
dpkg-buildpackage: error: fakeroot debian/rules binary-arch gave error exit status 2

Notice: Be carefully to not leak any confidential information.

To Reproduce
git clone https://github.com/SpiderLabs/ModSecurity
wget http://deb.debian.org/debian/pool/main/m/modsecurity/modsecurity_3.0.3-1.debian.tar.xz

tar -C ModSecurity -xvPf modsecurity_3.0.3-1.debian.tar.xz

cd ModSecurity

cat debian/patches/series
disable-network-dependent-tests.patch
(only above patch applied as the other two are obsolete for this newer ModSecurity)

dpkg-buildpackage -F -us -uc -j1 -T binary-arch,binary-indep

Expected behavior

I expected to generate at least a couple of debian 9 stretch-backports ModSecurity packages.

Server (please complete the following information):
Linux xiuhcohuatl 4.20.0-1+reiser4.0.2-amd64 #1 SMP Debian 4.20.13-1+reiser4.0.2 (2018-12-26) x86_64 GNU/Linux

Thanks

@victorhora victorhora self-assigned this Mar 5, 2019
@victorhora victorhora added the 3.x Related to ModSecurity version 3.x label Mar 5, 2019
@victorhora victorhora added this to the v3.0.4 milestone Mar 5, 2019
@victorhora
Copy link
Contributor

Hi @Metztli,

These error messages related with Lua:

../../src/.libs/libmodsecurity.so: undefined reference to lua_setglobal' ../../src/.libs/libmodsecurity.so: undefined reference to lua_pcallk'
../../src/.libs/libmodsecurity.so: undefined reference to lua_getglobal' ../../src/.libs/libmodsecurity.so: undefined reference to lua_rawlen'

Suggests that the configure script failed to select the proper libLua src/headers and it might be trying to compile with a given feature (e.g. JIT) that is not present.

I suggest checking for the version of libLua installed. You may have issues if you have multiple versions of it installed.

Do you get different results If you try compile without using dpkg-buildpackage, but actually running make yourself?

@Metztli
Copy link
Author

Metztli commented Mar 6, 2019

Niltze, @victorhora-

Thank you for the lua -related hints. I made sure to install/leave only latest and gave the build one more try. Unlike yesterday (where I spent considerable time online searching for a similar error and thus a proper solution) this time build succeeded.

If interested in the log of the build:
https://metztli.it/blog/index.php/amatl/aO0

Once again, thanks Victor.

Best Professional Regards.

@Metztli Metztli closed this as completed Mar 6, 2019
@bbrendon
Copy link

@Metztli can you elaborate on how you resolved this? Did you install an lua package? what do you mean by leave only latest?

@Metztli
Copy link
Author

Metztli commented Jul 21, 2021

If your build is failing, make sure to read the note at the very end of my reply.

Yet, if you need a hint on requirements prior to build ModSecurity 3...

@bbrendon

what do you mean by leave only latest?

i.e.:

I suggest checking for the version of libLua installed. You may have issues if you have multiple versions of it installed.

We fetch Debian packaging for ModSecurity 3 XZ compressed TAR archive, either for Buster, Bullseye, or Sid, from https://packages.debian.org/buster/libmodsecurity3

For instance, we select for Debian 10 Buster stable distribution:
http://deb.debian.org/debian/pool/main/m/modsecurity/modsecurity_3.0.3-1+deb10u2.debian.tar.xz

If you untar the above and view debian/control file, please observe the Build-Depends to fulfill requirements, with liblua5.3-dev (latest for Debian 10 [codename Buster]) being one of those dependencies.

liblua5 3-dev

Important note: if libluajit-5.1-dev is present, make sure to purge[1] it as it conflicts with liblua5.3-dev leading to failed ModSecurity v3 build.

Nginx at Metztli IT: ModSecurity v3 module, Engine X v1.15.9, and libmodsecurity3 Connector, Integrated Hack.

[1] with root privilege, apt-get purge libluajit-5.1-dev

Good luck!

@airween
Copy link
Member

airween commented Jul 21, 2021

Just for the record: if you want to use libmodsecurity3 (and optionally Nginx), you can use this repository.

I try to keep up-to-date all packages (especially now I'm a bit late for all distrib, except Debian 10, which is up-to-date)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Related to ModSecurity version 3.x
Projects
None yet
Development

No branches or pull requests

4 participants