Skip to content

ModSecurity v2.9.12: find_yajl.m4 fails to detect YAJL installed from source #3457

@weida

Description

@weida

Describe the bug

When building branch v2/master with the latest yajl library 2.1.0 compiled from source, the build fails to detect yajl when provided with the correct path.

Logs and dumps

yajl was compiled from source under /usr/local/yajl-2.1.0, Compiling Modsecurity with --with-yajl=/usr/local/yajl-2.1.0s, reporting that the YAJL library is not found.

checking for libyajl config script... no
checking for yajl install... no
configure: optional yajl library not found

To Reproduce

  1. Install yajl 2.1.0 from source
wget https://github.com/lloyd/yajl/archive/refs/tags/2.1.0.tar.gz -O yajl-2.1.0.tar.gz
tar zxvf yajl-2.1.0.tar.gz
cd yajl-2.1.0
./configure -p /usr/local/yajl-2.1.0
make 
sudo make install 
sudo chmod -R 755 /usr/local/yajl-2.1.0
  1. Run configure with modsecurity-v2.9.12
cd modsecurity-v2.9.12
./autogen.sh
./configure --with-yajl=/usr/local/yajl-2.1.0 --prefix=/usr/local/modsecurity-v2.9.12
  1. Check the outcome of YAJL detection::
checking for libyajl config script... no
checking for yajl install... no
configure: optional yajl library not found

4.The yajl headers and libraries exist:

/usr/local/yajl-2.1.0/include/yajl:
total 36
-rwxr-xr-x 1 root root  363 Nov  1 16:02 yajl_version.h
-rwxr-xr-x 1 root root 7171 Mar 19  2014 yajl_tree.h
-rwxr-xr-x 1 root root 9821 Mar 19  2014 yajl_parse.h
-rwxr-xr-x 1 root root 7060 Mar 19  2014 yajl_gen.h
-rwxr-xr-x 1 root root 2572 Mar 19  2014 yajl_common.h
...
/usr/local/yajl-2.1.0/lib:
total 104
-rwxr-xr-x 1 root root 40688 Nov  1 16:03 libyajl.so.2.1.0
lrwxrwxrwx 1 root root    16 Nov  1 15:13 libyajl.so.2 -> libyajl.so.2.1.0
lrwxrwxrwx 1 root root    12 Nov  1 15:13 libyajl.so -> libyajl.so.2
-rwxr-xr-x 1 root root 65096 Nov  1 16:03 libyajl_s.a

Expected behavior

compile successfully when --with-yajl is specified

Server (please complete the following information):

  • ModSecurity version (and connector): [v2.9.12]
  • WebServer: [Apache 2.4]
  • OS (and distro): [CentOS Linux release 7.8.2003 ]

Additional context

The find_yajl.m4 should correctly detect YAJL header and libraries . Add a check for the lib subdirectory in addition to the top-level path to correctly detect the library.

    dnl Hack to just try to find the lib and include
    AC_MSG_CHECKING([for yajl install])
    for x in ${test_paths}; do
        for y in ${YAJL_SONAMES}; do
           if test -e "${x}/libyajl.${y}"; then
                yajl_lib_path="${x}/"
                yajl_lib_name="yajl"
                break
           elif test -e "${x}/lib/libyajl.${y}"; then
                yajl_lib_path="${x}/lib/"
                yajl_lib_name="yajl"
                break
           else
                yajl_lib_path=""
                yajl_lib_name=""
           fi
        done
        if test -n "$yajl_lib_path"; then
            break
        fi
    done

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.xRelated to ModSecurity version 2.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions