mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Makes YAJL dependency to be optional
This commit is contained in:
parent
cf4377df70
commit
fbf8ea74f3
@ -2,11 +2,16 @@
|
|||||||
ACLOCAL_AMFLAGS = -I build
|
ACLOCAL_AMFLAGS = -I build
|
||||||
|
|
||||||
|
|
||||||
|
if WITH_YAJL
|
||||||
|
WITH_TESTS = tests
|
||||||
|
endif
|
||||||
|
|
||||||
SUBDIRS = \
|
SUBDIRS = \
|
||||||
src \
|
src \
|
||||||
test \
|
|
||||||
doc \
|
doc \
|
||||||
examples
|
examples \
|
||||||
|
$(WITH_TESTS)
|
||||||
|
|
||||||
|
|
||||||
# make clean
|
# make clean
|
||||||
CLEANFILES =
|
CLEANFILES =
|
||||||
|
271
build/yajl.m4
271
build/yajl.m4
@ -1,155 +1,176 @@
|
|||||||
dnl Check for YAJL Libraries
|
dnl Check for YAJL Libraries
|
||||||
dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
|
dnl CHECK_YAJL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
|
||||||
dnl Sets:
|
|
||||||
dnl YAJL_CFLAGS
|
|
||||||
dnl YAJL_LDADD
|
|
||||||
dnl YAJL_LDFLAGS
|
|
||||||
dnl YAJL_LIBS
|
|
||||||
dnl YAJL_VERSION
|
|
||||||
|
|
||||||
AC_DEFUN([PROG_YAJL],
|
AC_DEFUN([PROG_YAJL], [
|
||||||
[dnl
|
|
||||||
|
|
||||||
|
# Needed if pkg-config will be used.
|
||||||
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||||
|
|
||||||
YAJL_CONFIG=""
|
|
||||||
|
# Possible names for the yajl library/package (pkg-config)
|
||||||
|
YAJL_POSSIBLE_LIB_NAMES="yajl2 yajl"
|
||||||
|
|
||||||
|
# Possible extensions for the library
|
||||||
|
YAJL_POSSIBLE_EXTENSIONS="so la sl dll dylib"
|
||||||
|
|
||||||
|
# Possible paths (if pkg-config was not found, proceed with the file lookup)
|
||||||
|
YAJL_POSSIBLE_PATHS="/usr/lib /usr/local/lib /usr/local/libyajl /usr/local/yajl /usr/local /opt/libyajl /opt/yajl /opt /usr"
|
||||||
|
|
||||||
|
# Variables to be set by this very own script.
|
||||||
YAJL_VERSION=""
|
YAJL_VERSION=""
|
||||||
YAJL_CFLAGS=""
|
YAJL_CFLAGS=""
|
||||||
YAJL_CPPFLAGS=""
|
YAJL_CPPFLAGS=""
|
||||||
YAJL_LDADD=""
|
YAJL_LDADD=""
|
||||||
YAJL_LDFLAGS=""
|
YAJL_LDFLAGS=""
|
||||||
YAJL_CONFIG=${PKG_CONFIG}
|
|
||||||
YAJL_PKGNAMES="yajl2 yajl"
|
|
||||||
YAJL_SONAMES="so la sl dll dylib"
|
|
||||||
|
|
||||||
AC_ARG_WITH(
|
AC_ARG_WITH(
|
||||||
yajl,
|
yajl,
|
||||||
[AC_HELP_STRING([--with-yajl=PATH],[Path to yajl prefix or config script])]
|
AC_HELP_STRING(
|
||||||
,, with_yajl=yes)
|
[--with-yajl=PATH],
|
||||||
|
[Path to yajl prefix or config script]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
AS_CASE(["${with_yajl}"],
|
if test "x${with_yajl}" == "xno"; then
|
||||||
[no], [test_paths=],
|
AC_DEFINE(HAVE_GEOIP, 0, [Support for GeoIP was disabled by the utilization of --without-yajl or --with-yajl=no])
|
||||||
[yes], [test_paths="/usr/lib /usr/local/lib /usr/local/libyajl /usr/local/yajl /usr/local /opt/libyajl /opt/yajl /opt /usr"],
|
AC_MSG_NOTICE([Support for GeoIP was disabled by the utilization of --without-yajl or --with-yajl=no])
|
||||||
[test_paths="${with_yajl}"])
|
YAJL_DISABLED=yes
|
||||||
|
else
|
||||||
AS_IF([test "x${test_paths}" != "x"], [
|
if test "x${with_yajl}" == "xyes"; then
|
||||||
AC_MSG_CHECKING([for libyajl config script])
|
YAJL_MANDATORY=yes
|
||||||
for x in ${test_paths}; do
|
AC_MSG_NOTICE([GeoIP support was marked as mandatory by the utilization of --with-yajl=yes])
|
||||||
dnl # Determine if the script was specified and use it directly
|
|
||||||
if test ! -d "$x" -a -e "$x"; then
|
|
||||||
YAJL_CONFIG=$x
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
|
# for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
|
||||||
|
# CHECK_FOR_YAJL_AT(${x})
|
||||||
|
# if test -n "${YAJL_VERSION}"; then
|
||||||
|
# break
|
||||||
|
# fi
|
||||||
|
# done
|
||||||
|
|
||||||
dnl # Try known config script names/locations
|
# if test "x${with_yajl}" != "xyes" or test "x${with_yajl}" == "xyes"; then
|
||||||
for y in $YAJL_CONFIG; do
|
if test "x${with_yajl}" == "x" || test "x${with_yajl}" == "xyes"; then
|
||||||
if test -e "${x}/bin/${y}"; then
|
# Nothing about GeoIP was informed, using the pkg-config to figure things out.
|
||||||
YAJL_CONFIG="${x}/bin/${y}"
|
if test -n "${PKG_CONFIG}"; then
|
||||||
yajl_config="${YAJL_CONFIG}"
|
YAJL_PKG_NAME=""
|
||||||
break
|
for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
|
||||||
elif test -e "${x}/${y}"; then
|
if ${PKG_CONFIG} --exists ${x}; then
|
||||||
YAJL_CONFIG="${x}/${y}"
|
YAJL_PKG_NAME="$x"
|
||||||
yajl_config="${YAJL_CONFIG}"
|
break
|
||||||
break
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
AC_MSG_NOTICE([Nothing about GeoIP was informed during the configure phase. Trying to detect it on the platform...])
|
||||||
|
if test -n "${YAJL_PKG_NAME}"; then
|
||||||
|
# Package was found using the pkg-config scripts
|
||||||
|
YAJL_VERSION="`${PKG_CONFIG} ${YAJL_PKG_NAME} --modversion`"
|
||||||
|
YAJL_CFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --cflags`"
|
||||||
|
YAJL_LDADD="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-l`"
|
||||||
|
YAJL_LDFLAGS="`${PKG_CONFIG} ${YAJL_PKG_NAME} --libs-only-L --libs-only-other`"
|
||||||
|
YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}"
|
||||||
|
else
|
||||||
|
# If pkg-config did not find anything useful, go over file lookup.
|
||||||
|
for x in ${YAJL_POSSIBLE_LIB_NAMES}; do
|
||||||
|
CHECK_FOR_YAJL_AT(${x})
|
||||||
|
if test -n "${YAJL_VERSION}"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
if test "x${with_yajl}" != "x"; then
|
||||||
if test -n "${yajl_config}"; then
|
# An specific path was informed, lets check.
|
||||||
break
|
YAJL_MANDATORY=yes
|
||||||
fi
|
CHECK_FOR_YAJL_AT(${with_yajl})
|
||||||
done
|
|
||||||
|
|
||||||
dnl # Try known package names
|
|
||||||
if test -n "${YAJL_CONFIG}"; then
|
|
||||||
YAJL_PKGNAME=""
|
|
||||||
for x in ${YAJL_PKGNAMES}; do
|
|
||||||
if ${YAJL_CONFIG} --exists ${x}; then
|
|
||||||
YAJL_PKGNAME="$x"
|
|
||||||
break
|
|
||||||
fi
|
fi
|
||||||
done
|
# fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "${YAJL_PKGNAME}"; then
|
if test -z "${YAJL_CFLAGS}"; then
|
||||||
AC_MSG_RESULT([${YAJL_CONFIG}])
|
if test -z "${YAJL_MANDATORY}"; then
|
||||||
YAJL_VERSION="`${YAJL_CONFIG} ${YAJL_PKGNAME} --modversion`"
|
if test -z "${YAJL_DISABLED}"; then
|
||||||
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl VERSION: $YAJL_VERSION); fi
|
AC_MSG_NOTICE([YAJL library was not found])
|
||||||
YAJL_CFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --cflags`"
|
YAJL_FOUND=0
|
||||||
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl CFLAGS: $YAJL_CFLAGS); fi
|
else
|
||||||
YAJL_LDADD="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-l`"
|
YAJL_FOUND=2
|
||||||
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl LDADD: $YAJL_LDADD); fi
|
fi
|
||||||
YAJL_LDFLAGS="`${YAJL_CONFIG} ${YAJL_PKGNAME} --libs-only-L --libs-only-other`"
|
else
|
||||||
if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(yajl LDFLAGS: $YAJL_LDFLAGS); fi
|
AC_MSG_ERROR([YAJL was explicitly referenced but it was not found])
|
||||||
|
YAJL_FOUND=-1
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
AC_MSG_RESULT([no])
|
YAJL_FOUND=1
|
||||||
|
AC_MSG_NOTICE([using YAJL v${YAJL_VERSION}])
|
||||||
|
YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}"
|
||||||
|
YAJL_DISPLAY="${YAJL_LDADD}, ${YAJL_CFLAGS}"
|
||||||
|
AC_SUBST(YAJL_VERSION)
|
||||||
|
AC_SUBST(YAJL_LDADD)
|
||||||
|
AC_SUBST(YAJL_LIBS)
|
||||||
|
AC_SUBST(YAJL_LDFLAGS)
|
||||||
|
AC_SUBST(YAJL_CFLAGS)
|
||||||
|
AC_SUBST(YAJL_DISPLAY)
|
||||||
|
fi
|
||||||
|
|
||||||
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
|
|
||||||
else
|
|
||||||
yajl_lib_path=""
|
|
||||||
yajl_lib_name=""
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
if test -n "$yajl_lib_path"; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
for x in ${test_paths}; do
|
|
||||||
if test -e "${x}/include/yajl_parse.h"; then
|
|
||||||
yajl_inc_path="${x}/include"
|
|
||||||
break
|
|
||||||
elif test -e "${x}/yajl_parse.h"; then
|
|
||||||
yajl_inc_path="${x}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl # Check some sub-paths as well
|
|
||||||
for yajl_pkg_name in ${yajl_lib_name} ${YAJL_PKGNAMES}; do
|
AC_SUBST(YAJL_FOUND)
|
||||||
if test -e "${x}/include/${yajl_pkg_name}/yajl_parse.h"; then
|
|
||||||
yajl_inc_path="${x}/include"
|
]) # AC_DEFUN [PROG_YAJL]
|
||||||
break
|
|
||||||
elif test -e "${x}/${yajl_pkg_name}/yajl_parse.h"; then
|
|
||||||
yajl_inc_path="${x}"
|
AC_DEFUN([CHECK_FOR_YAJL_AT], [
|
||||||
break
|
path=$1
|
||||||
else
|
for y in ${YAJL_POSSIBLE_EXTENSIONS}; do
|
||||||
yajl_inc_path=""
|
for z in ${YAJL_POSSIBLE_LIB_NAMES}; do
|
||||||
fi
|
if test -e "${path}/${z}.${y}"; then
|
||||||
done
|
yajl_lib_path="${path}/"
|
||||||
if test -n "$yajl_inc_path"; then
|
yajl_lib_name="${z}"
|
||||||
break
|
yajl_lib_file="${yajl_lib_path}/${z}.${y}"
|
||||||
fi
|
break
|
||||||
|
fi
|
||||||
|
if test -e "${path}/lib${z}.${y}"; then
|
||||||
|
yajl_lib_path="${path}/"
|
||||||
|
yajl_lib_name="${z}"
|
||||||
|
yajl_lib_file="${yajl_lib_path}/lib${z}.${y}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -e "${path}/lib/lib${z}.${y}"; then
|
||||||
|
yajl_lib_path="${path}/lib/"
|
||||||
|
yajl_lib_name="${z}"
|
||||||
|
yajl_lib_file="${yajl_lib_path}/lib${z}.${y}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -e "${path}/lib/x86_64-linux-gnu/lib${z}.${y}"; then
|
||||||
|
yajl_lib_path="${path}/lib/x86_64-linux-gnu/"
|
||||||
|
yajl_lib_name="${z}"
|
||||||
|
yajl_lib_file="${yajl_lib_path}/lib${z}.${y}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if test -n "$yajl_lib_path"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
if test -e "${path}/include/yajl_parse.h"; then
|
||||||
|
yajl_inc_path="${path}/include"
|
||||||
|
elif test -e "${path}/yajl_parse.h"; then
|
||||||
|
yajl_inc_path="${path}"
|
||||||
|
elif test -e "${path}/include/yajl/yajl_parse.h"; then
|
||||||
|
yajl_inc_path="${path}/include"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "${yajl_lib_path}"; then
|
||||||
|
AC_MSG_NOTICE([YAJL library found at: ${yajl_lib_file}])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -n "${yajl_inc_path}"; then
|
||||||
|
AC_MSG_NOTICE([YAJL headers found at: ${yajl_inc_path}])
|
||||||
|
fi
|
||||||
|
|
||||||
if test -n "${yajl_lib_path}" -a -n "${yajl_inc_path}"; then
|
if test -n "${yajl_lib_path}" -a -n "${yajl_inc_path}"; then
|
||||||
YAJL_CONFIG=""
|
# TODO: Compile a piece of code to check the version.
|
||||||
AC_MSG_RESULT([${yajl_lib_path} ${yajl_inc_path}])
|
|
||||||
YAJL_VERSION="2"
|
|
||||||
YAJL_CFLAGS="-I${yajl_inc_path}"
|
YAJL_CFLAGS="-I${yajl_inc_path}"
|
||||||
YAJL_LDADD="-l${yajl_lib_name}"
|
YAJL_LDADD="-l${yajl_lib_name}"
|
||||||
YAJL_LDFLAGS="-L${yajl_lib_path}"
|
YAJL_LDFLAGS="-L${yajl_lib_path}"
|
||||||
else
|
YAJL_DISPLAY="${yajl_lib_file}, ${yajl_inc_path}"
|
||||||
YAJL_VERSION=""
|
|
||||||
AC_MSG_RESULT([no])
|
|
||||||
fi
|
fi
|
||||||
fi
|
]) # AC_DEFUN [CHECK_FOR_YAJL_AT]
|
||||||
|
|
||||||
])
|
|
||||||
|
|
||||||
YAJL_LIBS=${YAJL_LDADD}
|
|
||||||
AC_SUBST(YAJL_CFLAGS)
|
|
||||||
AC_SUBST(YAJL_VERSION)
|
|
||||||
AC_SUBST(YAJL_LDADD)
|
|
||||||
AC_SUBST(YAJL_LIBS)
|
|
||||||
AC_SUBST(YAJL_LDFLAGS)
|
|
||||||
if test -z "${YAJL_VERSION}"; then
|
|
||||||
ifelse([$2], , AC_MSG_ERROR([*** yajl library not found]), $2)
|
|
||||||
else
|
|
||||||
AC_MSG_NOTICE([using yajl v${YAJL_VERSION}])
|
|
||||||
YAJL_CFLAGS="-DWITH_YAJL ${YAJL_CFLAGS}"
|
|
||||||
ifelse([$1], , , $1)
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
|
19
configure.ac
19
configure.ac
@ -190,6 +190,7 @@ AC_SUBST([MSC_GIT_VERSION])
|
|||||||
|
|
||||||
|
|
||||||
# Files to be generated via autotools.
|
# Files to be generated via autotools.
|
||||||
|
AM_CONDITIONAL([WITH_YAJL], [test "$want_test" = yes])
|
||||||
AC_CONFIG_FILES([\
|
AC_CONFIG_FILES([\
|
||||||
Makefile \
|
Makefile \
|
||||||
doc/Makefile \
|
doc/Makefile \
|
||||||
@ -268,4 +269,22 @@ if test "x$CURL_FOUND" = "x2"; then
|
|||||||
echo " + LibCURL ....disabled"
|
echo " + LibCURL ....disabled"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
## YAJL
|
||||||
|
if test "x$YAJL_FOUND" = "x0"; then
|
||||||
|
echo " + YAJL ....not found"
|
||||||
|
fi
|
||||||
|
if test "x$YAJL_FOUND" = "x1"; then
|
||||||
|
echo -n " + YAJL ....found "
|
||||||
|
if ! test "x$YAJL_VERSION" = "x"; then
|
||||||
|
echo "v${YAJL_VERSION}"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
echo " ${YAJL_DISPLAY}"
|
||||||
|
fi
|
||||||
|
if test "x$YAJL_FOUND" = "x2"; then
|
||||||
|
echo " + YAJL ....disabled"
|
||||||
|
fi
|
||||||
|
|
||||||
echo " "
|
echo " "
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
|
|
||||||
|
#ifdef WITH_YAJL
|
||||||
#include <yajl/yajl_tree.h>
|
#include <yajl/yajl_tree.h>
|
||||||
#include <yajl/yajl_gen.h>
|
#include <yajl/yajl_gen.h>
|
||||||
|
#endif
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -1331,6 +1333,7 @@ std::string Assay::toOldAuditLogFormat(int parts, const std::string &trailer) {
|
|||||||
|
|
||||||
|
|
||||||
std::string Assay::to_json(int parts) {
|
std::string Assay::to_json(int parts) {
|
||||||
|
#ifdef WITH_YAJL
|
||||||
const unsigned char *buf;
|
const unsigned char *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
yajl_gen g = NULL;
|
yajl_gen g = NULL;
|
||||||
@ -1477,6 +1480,9 @@ std::string Assay::to_json(int parts) {
|
|||||||
yajl_gen_free(g);
|
yajl_gen_free(g);
|
||||||
|
|
||||||
return log;
|
return log;
|
||||||
|
#else
|
||||||
|
return std::string("");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
|
|
||||||
#include "common/modsecurity_test.h"
|
#include "common/modsecurity_test.h"
|
||||||
|
|
||||||
|
#ifdef WITH_YAJL
|
||||||
#include <yajl/yajl_tree.h>
|
#include <yajl/yajl_tree.h>
|
||||||
|
#endif
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user