diff options
author | Jurijs Klopovskis <jurijs.klopovskis@zabbix.com> | 2022-06-16 16:45:56 +0300 |
---|---|---|
committer | Jurijs Klopovskis <jurijs.klopovskis@zabbix.com> | 2022-06-16 16:45:56 +0300 |
commit | 726926a1abef88ae4ba0aa03972785f509a6bac6 (patch) | |
tree | e2ae9f73b0a8a02013a3f1e1e15e1804a0c7c5c7 | |
parent | 32683f1dc857f853112721bd56efdd6166776c51 (diff) | |
parent | 58a3ef49d1c32fcf8c6f9e6e225810be4ce35235 (diff) |
....I..... [ZBX-21064] added various autoconf/automake fixes
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-20105 | 1 | ||||
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-21064 | 1 | ||||
-rw-r--r-- | ChangeLog.d/bugfix/ZBX-21066 | 1 | ||||
-rw-r--r-- | configure.ac | 81 | ||||
-rw-r--r-- | include/common.h | 5 | ||||
-rw-r--r-- | m4/libmodbus.m4 | 14 | ||||
-rw-r--r-- | m4/libopenssl.m4 | 21 | ||||
-rw-r--r-- | m4/libxml2.m4 | 2 | ||||
-rw-r--r-- | m4/pcre.m4 | 333 | ||||
-rw-r--r-- | m4/pcre2.m4 | 333 | ||||
-rw-r--r-- | src/libs/zbxcommon/comms.c | 92 | ||||
-rw-r--r-- | src/zabbix_js/Makefile.am | 6 | ||||
-rw-r--r-- | src/zabbix_proxy/Makefile.am | 1 | ||||
-rw-r--r-- | src/zabbix_server/Makefile.am | 1 | ||||
-rw-r--r-- | src/zabbix_server/trapper/Makefile.am | 3 | ||||
-rw-r--r-- | src/zabbix_server/trapper/trapper.c | 92 |
16 files changed, 617 insertions, 370 deletions
diff --git a/ChangeLog.d/bugfix/ZBX-20105 b/ChangeLog.d/bugfix/ZBX-20105 new file mode 100644 index 00000000000..1a01268aeb3 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-20105 @@ -0,0 +1 @@ +...GI..PS. [ZBX-20105] removed bogus dependency on libxml2 from agent (yurii) diff --git a/ChangeLog.d/bugfix/ZBX-21064 b/ChangeLog.d/bugfix/ZBX-21064 new file mode 100644 index 00000000000..93ee548d79f --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-21064 @@ -0,0 +1 @@ +....I..... [ZBX-21064] rewrote pcre.m4 and pcre2.m4 file (yurii) diff --git a/ChangeLog.d/bugfix/ZBX-21066 b/ChangeLog.d/bugfix/ZBX-21066 new file mode 100644 index 00000000000..f035e7f06b8 --- /dev/null +++ b/ChangeLog.d/bugfix/ZBX-21066 @@ -0,0 +1 @@ +....I..... [ZBX-21066] fixed libopenssl.m4 when dealing with lib/64 in openssl 3 (yurii) diff --git a/configure.ac b/configure.ac index 01f64d6dc56..dc5da59a5d3 100644 --- a/configure.ac +++ b/configure.ac @@ -153,6 +153,9 @@ AC_CHECK_HEADERS(libperfstat.h, [], [], [ #endif ]) +dnl Kluge for building wihout pkg-config +m4_ifdef([PKG_PROG_PKG_CONFIG], [], [ AC_DEFUN([PKG_PROG_PKG_CONFIG], []) ]) + dnl ***************************************************************** dnl * * dnl * Checks for libraries * @@ -1320,6 +1323,10 @@ AC_ARG_ENABLE(static-libs,[ --enable-static-libs Build statically linked bin *) AC_MSG_ERROR([bad value ${enableval} for --enable-static-libs]) ;; esac]) +if test "x#static_linking" = "xyes" && test "x$static_linking_libs" = "xyes"; then + AC_MSG_ERROR([cannot use --static and --static-libs at the same time]) +fi + AC_ARG_ENABLE(server,[ --enable-server Turn on build of Zabbix server], [case "${enableval}" in yes) server=yes ;; @@ -1543,9 +1550,12 @@ if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then have_libxml2="yes" fi fi - - LDFLAGS="$LDFLAGS $LIBXML2_LDFLAGS" - LIBS="$LIBS $LIBXML2_LIBS" + + SERVER_LDFLAGS="$SERVER_LDFLAGS $LIBXML2_LDFLAGS" + SERVER_LIBS="$SERVER_LIBS $LIBXML2_LIBS" + + PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBXML2_LDFLAGS" + PROXY_LIBS="$PROXY_LIBS $LIBXML2_LIBS" AC_SUBST(LIBXML2_CFLAGS) @@ -1871,36 +1881,22 @@ ZBXJS_LDFLAGS="$ZBXJS_LDFLAGS $LIBCURL_LDFLAGS" ZBXJS_LIBS="$ZBXJS_LIBS $LIBCURL_LIBS" if test "x$server" = "xyes" || test "x$proxy" = "xyes" || test "x$agent" = "xyes" || test "x$agent2" = "xyes"; then -dnl Check for libpcre or libpcre2, used by Zabbix for regular expressions -dnl Must check for both pcre and pcre2 to check if both were selected by the user and produce an error in that case -LIBPCRE_CHECK_CONFIG([no]) -if test "x$enable_static_libs" != "xyes" || test "x$found_libpcre" != "xyes"; then -LIBPCRE2_CHECK_CONFIG([no]) -fi -if test "x$want_libpcre2" = "xyes"; then - if test "x$want_libpcre" = "xyes"; then - AC_MSG_ERROR([Cannot use both pcre and pcre2 at the same time!]) - fi +LIBPCRE_CHECK_CONFIG([flags-only]) +LIBPCRE2_CHECK_CONFIG([flags-only]) - if test "x$found_libpcre2" != "xyes"; then - AC_MSG_ERROR([Unable to use libpcre2 (libpcre2 check failed)]) +if test "x$want_libpcre2" = "xno"; then # default to old pcre + if test "x$want_libpcre" = "xno"; then + AC_MSG_NOTICE([using old pcre library by default]) fi - CFLAGS="$CFLAGS $LIBPCRE2_CFLAGS" - LDFLAGS="$LDFLAGS $LIBPCRE2_LDFLAGS" - if test "x$ARCH" = "xosx"; then - LIBS="$LIBPCRE2_LIBS $LIBS" - else - LIBS="$LIBS $LIBPCRE2_LIBS" - fi + LIBPCRE_CHECK_CONFIG([mandatory]) - AC_DEFINE([HAVE_PCRE2_H], 1, [Define to 1 if you have the 'libpcre2' library (-lpcre2-8)]) - have_pcre2=1 -else if test "x$found_libpcre" != "xyes"; then - AC_MSG_ERROR([Unable to use libpcre (libpcre check failed)]) + AC_MSG_ERROR([unable to use libpcre (libpcre check failed)]) fi + LIBPCRE_CHECK_CONFIG([no]) + CFLAGS="$CFLAGS $LIBPCRE_CFLAGS" LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS" if test "x$ARCH" = "xosx"; then @@ -1911,6 +1907,31 @@ else AC_DEFINE([HAVE_PCRE_H], 1, [Define to 1 if you have the 'libpcre' library (-lpcre)]) have_pcre=1 +else + if test "x$want_libpcre" != "xno"; then + AC_MSG_ERROR([cannot use both pcre and pcre2 at the same time]) + fi + + LIBPCRE2_CHECK_CONFIG([mandatory]) + + if test "x$found_libpcre2" != "xyes"; then + AC_MSG_ERROR([unable to use libpcre2 (libpcre2 check failed)]) + fi + + CFLAGS="$CFLAGS $LIBPCRE2_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPCRE2_LDFLAGS" + if test "x$ARCH" = "xosx"; then + LIBS="$LIBPCRE2_LIBS $LIBS" + else + LIBS="$LIBS $LIBPCRE2_LIBS" + fi + + AC_DEFINE([HAVE_PCRE2_H], 1, [Define to 1 if you have the 'libpcre2' library (-lpcre2-8)]) + have_pcre2=1 +fi + +if test "x$have_pcre" != "x1" && test "x$have_pcre2" != "x1"; then + AC_MSG_ERROR([cannot build with libpcre or libpcre2]) fi fi @@ -2219,6 +2240,14 @@ if test "x$DB_CFLAGS" != "x"; then echo " database: ${DB_CFLAGS}" fi +if test "x$LIBPCRE_CFLAGS" != "x"; then + echo " libpcre: ${LIBPCRE_CFLAGS}" +fi + +if test "x$LIBPCRE2_CFLAGS" != "x"; then + echo " libpcre2: ${LIBPCRE2_CFLAGS}" +fi + if test "x$LIBXML2_CFLAGS" != "x"; then echo " libXML2: ${LIBXML2_CFLAGS}" fi diff --git a/include/common.h b/include/common.h index 513d00d84bc..35d9b84d089 100644 --- a/include/common.h +++ b/include/common.h @@ -1253,11 +1253,6 @@ void xml_free_data_dyn(char **data); char *xml_escape_dyn(const char *data); void xml_escape_xpath(char **data); -int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size_t key_len, - char *data, size_t data_len, char *lastlogsize, size_t lastlogsize_len, - char *timestamp, size_t timestamp_len, char *source, size_t source_len, - char *severity, size_t severity_len); - /* misc functions */ int is_ip6(const char *ip); int is_ip4(const char *ip); diff --git a/m4/libmodbus.m4 b/m4/libmodbus.m4 index ad03bd6044d..7700f71813b 100644 --- a/m4/libmodbus.m4 +++ b/m4/libmodbus.m4 @@ -91,16 +91,18 @@ AC_HELP_STRING([--with-libmodbus@<:@=DIR@:>@],[use MODBUS package @<:@default=no if test "x$want_libmodbus" = "xyes"; then AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - PKG_PROG_PKG_CONFIG() + m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:]) test -z "$PKG_CONFIG" && AC_MSG_ERROR([Not found pkg-config library]) m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) if test "x$_libmodbus_dir" = "xno"; then - PKG_CHECK_EXISTS(libmodbus,[ - LIBMODBUS_LIBS=`$PKG_CONFIG --libs libmodbus` - ],[ - AC_MSG_ERROR([Not found libmodbus package]) - ]) + m4_ifdef([PKG_CHECK_EXISTS], [ + PKG_CHECK_EXISTS(libmodbus,[ + LIBMODBUS_LIBS=`$PKG_CONFIG --libs libmodbus` + ],[ + AC_MSG_ERROR([Not found libmodbus package]) + ]) + ], [:]) LIBMODBUS_CFLAGS=`$PKG_CONFIG --cflags libmodbus` LIBMODBUS_LDFLAGS="" _libmodbus_version=`$PKG_CONFIG --modversion libmodbus` diff --git a/m4/libopenssl.m4 b/m4/libopenssl.m4 index fedac99dc3c..d2ab7939d4c 100644 --- a/m4/libopenssl.m4 +++ b/m4/libopenssl.m4 @@ -108,8 +108,10 @@ AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[use OpenSSL package @<:@default=no@ if test "x$enable_static_libs" = "xyes"; then test "x$static_linking_support" = "xno" -a -z "$_libopenssl_dir_lib" && AC_MSG_ERROR(["OpenSSL: Compiler not support statically linked libs from default folders"]) AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - PKG_PROG_PKG_CONFIG() + m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:]) test -z "$PKG_CONFIG" -a -z "$_libopenssl_dir_lib" && AC_MSG_ERROR([Not found pkg-config library]) + _libopenssl_dir_lib_64="$_libopenssl_dir_lib/64" + test -d "$_libopenssl_dir_lib_64" && _libopenssl_dir_lib="$_libopenssl_dir_lib_64" m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) fi @@ -137,6 +139,8 @@ AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[use OpenSSL package @<:@default=no@ if test -d $_libopenssl_dir/lib64; then OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib64 + elif test -d $_libopenssl_dir/lib/64; then + OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib/64 else OPENSSL_LDFLAGS=-L$_libopenssl_dir/lib fi @@ -160,13 +164,16 @@ AC_HELP_STRING([--with-openssl@<:@=DIR@:>@],[use OpenSSL package @<:@default=no@ OPENSSL_LIBS="$_libopenssl_dir_lib/libssl.a $_libopenssl_dir_lib/libcrypto.a" elif test "x$enable_static_libs" = "xyes"; then if test -z "$_libopenssl_dir_lib"; then - PKG_CHECK_EXISTS(openssl,[ - OPENSSL_LIBS=`$PKG_CONFIG --static --libs openssl` - ],[ - AC_MSG_ERROR([Not found openssl package]) - ]) + m4_ifdef([PKG_CHECK_EXISTS], [ + PKG_CHECK_EXISTS(openssl,[ + OPENSSL_LIBS=`$PKG_CONFIG --static --libs openssl` + ],[ + AC_MSG_ERROR([Not found openssl package]) + ]) + ], [:]) else - AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libopenssl_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors openssl]) || AC_MSG_ERROR(["Not found openssl package in $_libopenssl_dir/lib/pkgconfig"]) + AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libopenssl_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors openssl]) || + AC_MSG_ERROR(["Not found openssl package in $_libopenssl_dir_lib/pkgconfig"]) OPENSSL_LIBS=`PKG_CONFIG_LIBDIR="$_libopenssl_dir_lib/pkgconfig" $PKG_CONFIG --static --libs openssl` test -z "$OPENSSL_LIBS" && OPENSSL_LIBS=`PKG_CONFIG_LIBDIR="$_libopenssl_dir_lib/pkgconfig" $PKG_CONFIG --libs openssl` fi diff --git a/m4/libxml2.m4 b/m4/libxml2.m4 index cd6f79c126d..6e3714a31a6 100644 --- a/m4/libxml2.m4 +++ b/m4/libxml2.m4 @@ -50,7 +50,7 @@ AC_HELP_STRING([--with-libxml2@<:@=ARG@:>@], if test "$want_libxml2" = "yes"; then AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - PKG_PROG_PKG_CONFIG() + m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:]) if test -x "$PKG_CONFIG"; then diff --git a/m4/pcre.m4 b/m4/pcre.m4 index 05469c2882f..f387a227b73 100644 --- a/m4/pcre.m4 +++ b/m4/pcre.m4 @@ -28,140 +28,243 @@ found_libpcre="yes") AC_DEFUN([LIBPCRE_CHECK_CONFIG], [ + want_libpcre=no + found_libpcre=no + libpcre_dir="" + libpcre_include_dir="" + libpcre_lib_dir="" + + # + # process --with-* flags + # + AC_ARG_WITH([libpcre],[ If you want to specify libpcre installation directories: AC_HELP_STRING([--with-libpcre@<:@=DIR@:>@], [use libpcre from given base install directory (DIR), default is to search through a number of common places for the libpcre files.])], - [ - if test "$withval" = "yes"; then - want_libpcre=yes - if test -f /usr/local/include/pcre.h; then - withval="/usr/local" - else - withval="/usr" - fi - else - want_libpcre=no - _libpcre_dir_lib="$withval/lib" + [ + if test "$withval" != "no"; then + want_libpcre=yes + if test "$withval" != "yes"; then + libpcre_dir="$withval" fi - _libpcre_dir="$withval" - test "x$withval" = "xyes" && withval=/usr - LIBPCRE_CFLAGS="-I$withval/include" - LIBPCRE_LDFLAGS="-L$withval/lib" - _libpcre_dir_set="yes" - ] - ) - - AC_ARG_WITH([libpcre-include], - AC_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@], - [use libpcre include headers from given path.] - ), - [ - LIBPCRE_CFLAGS="-I$withval" - _libpcre_dir_set="yes" - ] - ) - - AC_ARG_WITH([libpcre-lib], - AC_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@], - [use libpcre libraries from given path.] - ), - [ - _libpcre_dir="$withval" - _libpcre_dir_lib="$withval" - LIBPCRE_LDFLAGS="-L$withval" - _libpcre_dir_set="yes" - ] - ) - - if test "x$enable_static_libs" = "xyes"; then + fi + ]) + + AC_ARG_WITH([libpcre-include], AC_HELP_STRING([--with-libpcre-include@<:@=DIR@:>@], [use libpcre include headers from given path.]), [ + want_libpcre="yes" + libpcre_include_dir="$withval" + if ! test -d "$libpcre_include_dir"; then + AC_MSG_ERROR([cannot find $libpcre_include_dir directory]) + fi + if ! test -f "$libpcre_include_dir/pcre.h"; then + AC_MSG_ERROR([cannot find $libpcre_include_dir/pcre.h]) + fi + ]) + + AC_ARG_WITH([libpcre-lib], AC_HELP_STRING([--with-libpcre-lib@<:@=DIR@:>@], [use libpcre libraries from given path.]), [ + want_libpcre="yes" + libpcre_lib_dir="$withval" + if ! test -d "$libpcre_lib_dir"; then + AC_MSG_ERROR([cannot find $libpcre_lib_dir directory]) + fi + ]) + + + # + # find actual compiler flags and include paths + # + + if test "$1" != "flags-only"; then AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - PKG_PROG_PKG_CONFIG() - test -z "$PKG_CONFIG" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR([Not found pkg-config library]) - m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) - fi + m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:]) - AC_MSG_CHECKING(for libpcre support) + if test -n "$PKG_CONFIG"; then + # + # got pkg-config, use that + # - LIBPCRE_LIBS="-lpcre" + m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) - if test "x$enable_static" = "xyes"; then - LIBPCRE_LIBS=" $LIBPCRE_LIBS -lpthread" - elif test "x$enable_static_libs" = "xyes" -a -z "$PKG_CONFIG"; then - LIBPCRE_LIBS="$_libpcre_dir_lib/libpcre.a" - elif test "x$enable_static_libs" = "xyes"; then + if test -n "$libpcre_lib_dir"; then + export PKG_CONFIG_LIBDIR="$libpcre_lib_dir/pkgconfig" + elif test -n "$libpcre_dir"; then + export PKG_CONFIG_LIBDIR="$libpcre_dir/lib/pkgconfig" + fi - test "x$static_linking_support" = "xno" -a -z "$_libpcre_dir_lib" && AC_MSG_ERROR(["Compiler not support statically linked libs from default folders"]) + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors libpcre]) || { + AC_MSG_ERROR([cannot find pkg-config package for libpcre]) + } - if test -z "$_libpcre_dir_lib"; then - PKG_CHECK_EXISTS(libpcre,[ - LIBPCRE_LIBS=`$PKG_CONFIG --static --libs libpcre` - ],[ - AC_MSG_ERROR([Not found libpcre package]) - ]) - else - AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors libpcre]) || AC_MSG_ERROR(["Not found libpcre package in $_libpcre_dir/lib/pkgconfig"]) - LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --static --libs libpcre` - test -z "$LIBPCRE_LIBS" && LIBPCRE_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre_dir_lib/pkgconfig" $PKG_CONFIG --libs libpcre` - fi + if test -n "$libpcre_include_dir"; then + LIBPCRE_CFLAGS="-I$libpcre_include_dir" + else + LIBPCRE_CFLAGS=`$PKG_CONFIG --cflags libpcre` + fi + + LIBPCRE_LDFLAGS=`$PKG_CONFIG --libs-only-L libpcre` + LIBPCRE_LIBS=`$PKG_CONFIG --libs-only-l libpcre` + + unset PKG_CONFIG_LIBDIR - if test "x$static_linking_support" = "xno"; then - LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s|-lpcre|$_libpcre_dir_lib/libpcre.a|g"` + found_libpcre="yes" else - LIBPCRE_LIBS=`echo "$LIBPCRE_LIBS"|sed "s/-lpcre/${static_linking_support}static -lpcre ${static_linking_support}dynamic/g"` + # + # no pkg-config, trying to guess + # + + AC_MSG_WARN([proceeding without pkg-config]) + + LIBPCRE_LIBS="-lpcre" + + if test -n "$libpcre_dir"; then + # + # directories are given explicitly + # + + if test -n "$libpcre_include_dir"; then + LIBPCRE_CFLAGS="-I$libpcre_include_dir" + else + if test -f "$libpcre_dir/include/pcre.h"; then + LIBPCRE_CFLAGS="-I$libpcre_dir/include" + else + AC_MSG_ERROR([cannot find $libpcre_dir/include/pcre.h]) + fi + fi + + if test -n "$libpcre_lib_dir"; then + LIBPCRE_LDFLAGS="-L$libpcre_lib_dir" + else + if test -d "$libpcre_dir/lib"; then + LIBPCRE_LDFLAGS="-L$libpcre_dir/lib" + else + AC_MSG_ERROR([cannot find $libpcre_dir/lib]) + fi + fi + + found_libpcre="yes" + elif test -n "$libpcre_include_dir"; then + LIBPCRE_CFLAGS="-I$libpcre_include_dir" + + if test -n "$libpcre_lib_dir"; then + LIBPCRE_LDFLAGS="-L$libpcre_lib_dir" + fi + + found_libpcre="yes" + elif test -n "$libpcre_lib_dir"; then + LIBPCRE_LDFLAGS="-L$libpcre_lib_dir" + + found_libpcre="yes" + else + # + # search default directories + # + + if test -f /usr/include/pcre.h; then + found_libpcre="yes" + elif test -f /usr/local/include/pcre.h; then + LIBPCRE_CFLAGS="-I/usr/local/include" + LIBPCRE_LDFLAGS="-L/usr/local/lib" + + found_libpcre="yes" + elif test -f /usr/pkg/include/pcre.h; then + LIBPCRE_CFLAGS="-I/usr/pkg/include" + LIBPCRE_LDFLAGS="-L/usr/pkg/lib" + LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/usr/pkg/lib" + + found_libpcre="yes" + elif test -f /opt/csw/include/pcre.h; then + LIBPCRE_CFLAGS="-I/opt/csw/include" + LIBPCRE_LDFLAGS="-L/opt/csw/lib" + + if $(echo "$CFLAGS"|grep -q -- "-m64") ; then + LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS/64 -Wl,-R/opt/csw/lib/64" + else + LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/opt/csw/lib" + fi + + found_libpcre="yes" + else + found_libpcre="no" + fi + fi fi - fi - if test -n "$_libpcre_dir_set" -o -f /usr/include/pcre.h; then - found_libpcre="yes" - elif test -f /usr/local/include/pcre.h; then - LIBPCRE_CFLAGS="-I/usr/local/include" - LIBPCRE_LDFLAGS="-L/usr/local/lib" - found_libpcre="yes" - elif test -f /usr/pkg/include/pcre.h; then - LIBPCRE_CFLAGS="-I/usr/pkg/include" - LIBPCRE_LDFLAGS="-L/usr/pkg/lib" - LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/usr/pkg/lib" - found_libpcre="yes" - elif test -f /opt/csw/include/pcre.h; then - LIBPCRE_CFLAGS="-I/opt/csw/include" - LIBPCRE_LDFLAGS="-L/opt/csw/lib" - if $(echo "$CFLAGS"|grep -q -- "-m64") ; then - LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS/64 -Wl,-R/opt/csw/lib/64" - else - LIBPCRE_LDFLAGS="$LIBPCRE_LDFLAGS -Wl,-R/opt/csw/lib" + + # + # process --enable-static and --enable_static-libs flags + # + + if test "x$enable_static" = "xyes"; then + LIBPCRE_LIBS=" $LIBPCRE_LIBS -lpthread" + elif test "x$enable_static_libs" = "xyes"; then + if test "x$static_linking_support" == "xno"; then + AC_MSG_WARN([compiler has no direct suppor for static linkage]) + + if test -n "$libpcre_lib_dir"; then + if test -f "$libpcre_lib_dir/libpcre.a"; then + LIBPCRE_LIBS="$libpcre_lib_dir/libpcre.a" + else + AC_MSG_ERROR([cannot find $libpcre_lib_dir/libpcre.a]) + fi + elif test -n "$libpcre_dir"; then + if test -f "$libpcre_dir/lib/libpcre.a"; then + LIBPCRE_LIBS="$libpcre_dir/lib/libpcre.a" + else + AC_MSG_ERROR([cannot find $libpcre_dir/lib/libpcre.a]) + fi + else + AC_MSG_ERROR([libpcre directory must be given explicitly in this case]) + fi + else + LIBPCRE_LIBS="$LIBPCRE_LDFLAGS ${static_linking_support}static $LIBPCRE_LIBS ${static_linking_support}dynamic" + LIBPCRE_LDFLAGS="" + fi fi - found_libpcre="yes" - else - found_libpcre="no" - AC_MSG_RESULT(no) - fi - if test "x$found_libpcre" = "xyes"; then - am_save_CFLAGS="$CFLAGS" - am_save_LDFLAGS="$LDFLAGS" - am_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $LIBPCRE_CFLAGS" - LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS" - LIBS="$LIBS $LIBPCRE_LIBS" + # + # try building with pcre + # - found_libpcre="no" - LIBPCRE_TRY_LINK([no]) + AC_MSG_CHECKING([for libpcre support]) - CFLAGS="$am_save_CFLAGS" - LDFLAGS="$am_save_LDFLAGS" - LIBS="$am_save_LIBS" - fi + if test "x$found_libpcre" = "xyes"; then + am_save_CFLAGS="$CFLAGS" + am_save_LDFLAGS="$LDFLAGS" + am_save_LIBS="$LIBS" - if test "x$found_libpcre" = "xyes"; then - AC_MSG_RESULT(yes) - else - LIBPCRE_CFLAGS="" - LIBPCRE_LDFLAGS="" - LIBPCRE_LIBS="" - fi + CFLAGS="$CFLAGS $LIBPCRE_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPCRE_LDFLAGS" + LIBS="$LIBS $LIBPCRE_LIBS" + + found_libpcre="no" + LIBPCRE_TRY_LINK([no]) + + if test "x$found_libpcre" = "xyes"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + if test "$1" = "mandatory"; then + AC_MSG_NOTICE([CFLAGS: $CFLAGS]) + AC_MSG_NOTICE([LDFLAGS: $LDFLAGS]) + AC_MSG_NOTICE([LIBS: $LIBS]) + AC_MSG_ERROR([cannot build with libpcre]) + else + LIBPCRE_CFLAGS="" + LIBPCRE_LDFLAGS="" + LIBPCRE_LIBS="" + fi + fi - AC_SUBST(LIBPCRE_CFLAGS) - AC_SUBST(LIBPCRE_LDFLAGS) - AC_SUBST(LIBPCRE_LIBS) + CFLAGS="$am_save_CFLAGS" + LDFLAGS="$am_save_LDFLAGS" + LIBS="$am_save_LIBS" + else + AC_MSG_RESULT(no) + fi + + AC_SUBST(LIBPCRE_CFLAGS) + AC_SUBST(LIBPCRE_LDFLAGS) + AC_SUBST(LIBPCRE_LIBS) + fi ])dnl diff --git a/m4/pcre2.m4 b/m4/pcre2.m4 index 436b98de4ae..3b85f475eb5 100644 --- a/m4/pcre2.m4 +++ b/m4/pcre2.m4 @@ -29,140 +29,243 @@ found_libpcre2="yes") AC_DEFUN([LIBPCRE2_CHECK_CONFIG], [ + want_libpcre2=no + found_libpcre2=no + libpcre2_dir="" + libpcre2_include_dir="" + libpcre2_lib_dir="" + + # + # process --with-* flags + # + AC_ARG_WITH([libpcre2],[ If you want to specify libpcre2 installation directories: AC_HELP_STRING([--with-libpcre2@<:@=DIR@:>@], [use libpcre2 from given base install directory (DIR), default is to search through a number of common places for the libpcre2 files.])], - [ - if test "$withval" = "yes"; then - want_libpcre2=yes - if test -f /usr/local/include/pcre2.h; then - withval="/usr/local" - else - withval="/usr" - fi - else - want_libpcre2=no - _libpcre2_dir_lib="$withval/lib" + [ + if test "$withval" != "no"; then + want_libpcre2=yes + if test "$withval" != "yes"; then + libpcre2_dir="$withval" fi - _libpcre2_dir="$withval" - test "x$withval" = "xyes" && withval=/usr - LIBPCRE2_CFLAGS="-I$withval/include" - LIBPCRE2_LDFLAGS="-L$withval/lib" - _libpcre2_dir_set="yes" - ] - ) - - AC_ARG_WITH([libpcre2-include], - AC_HELP_STRING([--with-libpcre2-include@<:@=DIR@:>@], - [use libpcre2 include headers from given path.] - ), - [ - LIBPCRE2_CFLAGS="-I$withval" - _libpcre2_dir_set="yes" - ] - ) - - AC_ARG_WITH([libpcre2-lib], - AC_HELP_STRING([--with-libpcre2-lib@<:@=DIR@:>@], - [use libpcre2 libraries from given path.] - ), - [ - _libpcre2_dir="$withval" - _libpcre2_dir_lib="$withval" - LIBPCRE2_LDFLAGS="-L$withval" - _libpcre2_dir_set="yes" - ] - ) - - if test "x$enable_static_libs" = "xyes"; then + fi + ]) + + AC_ARG_WITH([libpcre2-include], AC_HELP_STRING([--with-libpcre2-include@<:@=DIR@:>@], [use libpcre2 include headers from given path.]), [ + want_libpcre2="yes" + libpcre2_include_dir="$withval" + if ! test -d "$libpcre2_include_dir"; then + AC_MSG_ERROR([cannot find $libpcre2_include_dir directory]) + fi + if ! test -f "$libpcre2_include_dir/pcre2.h"; then + AC_MSG_ERROR([cannot find $libpcre2_include_dir/pcre2.h]) + fi + ]) + + AC_ARG_WITH([libpcre2-lib], AC_HELP_STRING([--with-libpcre2-lib@<:@=DIR@:>@], [use libpcre2 libraries from given path.]), [ + want_libpcre2="yes" + libpcre2_lib_dir="$withval" + if ! test -d "$libpcre2_lib_dir"; then + AC_MSG_ERROR([cannot find $libpcre2_lib_dir directory]) + fi + ]) + + + # + # find actual compiler flags and include paths + # + + if test "$1" != "flags-only"; then AC_REQUIRE([PKG_PROG_PKG_CONFIG]) - PKG_PROG_PKG_CONFIG() - test -z "$PKG_CONFIG" -a -z "$_libpcre2_dir_lib" && AC_MSG_ERROR([Not found pkg-config library]) - m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) - fi + m4_ifdef([PKG_PROG_PKG_CONFIG], [PKG_PROG_PKG_CONFIG()], [:]) - AC_MSG_CHECKING(for libpcre2 support) + if test -n "$PKG_CONFIG"; then + # + # got pkg-config, use that + # - LIBPCRE2_LIBS="-lpcre2-8" + m4_pattern_allow([^PKG_CONFIG_LIBDIR$]) - if test "x$enable_static" = "xyes"; then - LIBPCRE2_LIBS=" $LIBPCRE2_LIBS -lpthread" - elif test "x$enable_static_libs" = "xyes" -a -z "$PKG_CONFIG"; then - LIBPCRE2_LIBS="$_libpcre2_dir_lib/libpcre2.a" - elif test "x$enable_static_libs" = "xyes"; then + if test -n "$libpcre2_lib_dir"; then + export PKG_CONFIG_LIBDIR="$libpcre2_lib_dir/pkgconfig" + elif test -n "$libpcre2_dir"; then + export PKG_CONFIG_LIBDIR="$libpcre2_dir/lib/pkgconfig" + fi - test "x$static_linking_support" = "xno" -a -z "$_libpcre2_dir_lib" && AC_MSG_ERROR(["Compiler not support statically linked libs from default folders"]) + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors libpcre2-8]) || { + AC_MSG_ERROR([cannot find pkg-config package for libpcre2]) + } - if test -z "$_libpcre2_dir_lib"; then - PKG_CHECK_EXISTS(libpcre2,[ - LIBPCRE2_LIBS=`$PKG_CONFIG --static --libs libpcre2` - ],[ - AC_MSG_ERROR([Not found libpcre2 package]) - ]) - else - AC_RUN_LOG([PKG_CONFIG_LIBDIR="$_libpcre2_dir_lib/pkgconfig" $PKG_CONFIG --exists --print-errors libpcre2]) || AC_MSG_ERROR(["Not found libpcre2 package in $_libpcre2_dir/lib/pkgconfig"]) - LIBPCRE2_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre2_dir_lib/pkgconfig" $PKG_CONFIG --static --libs libpcre2` - test -z "$LIBPCRE2_LIBS" && LIBPCRE2_LIBS=`PKG_CONFIG_LIBDIR="$_libpcre2_dir_lib/pkgconfig" $PKG_CONFIG --libs libpcre2` - fi + if test -n "$libpcre2_include_dir"; then + LIBPCRE2_CFLAGS="-I$libpcre2_include_dir" + else + LIBPCRE2_CFLAGS=`$PKG_CONFIG --cflags libpcre2-8` + fi + + LIBPCRE2_LDFLAGS=`$PKG_CONFIG --libs-only-L libpcre2-8` + LIBPCRE2_LIBS=`$PKG_CONFIG --libs-only-l libpcre2-8` + + unset PKG_CONFIG_LIBDIR - if test "x$static_linking_support" = "xno"; then - LIBPCRE2_LIBS=`echo "$LIBPCRE2_LIBS"|sed "s|-lpcre2-8|$_libpcre2_dir_lib/libpcre2.a|g"` + found_libpcre2="yes" else - LIBPCRE2_LIBS=`echo "$LIBPCRE2_LIBS"|sed "s/-lpcre2-8/${static_linking_support}static -lpcre2-8 ${static_linking_support}dynamic/g"` + # + # no pkg-config, trying to guess + # + + AC_MSG_WARN([proceeding without pkg-config]) + + LIBPCRE2_LIBS="-lpcre2-8" + + if test -n "$libpcre2_dir"; then + # + # directories are given explicitly + # + + if test -n "$libpcre2_include_dir"; then + LIBPCRE2_CFLAGS="-I$libpcre2_include_dir" + else + if test -f "$libpcre2_dir/include/pcre2.h"; then + LIBPCRE2_CFLAGS="-I$libpcre2_dir/include" + else + AC_MSG_ERROR([cannot find $libpcre2_dir/include/pcre2.h]) + fi + fi + + if test -n "$libpcre2_lib_dir"; then + LIBPCRE2_LDFLAGS="-L$libpcre2_lib_dir" + else + if test -d "$libpcre2_dir/lib"; then + LIBPCRE2_LDFLAGS="-L$libpcre2_dir/lib" + else + AC_MSG_ERROR([cannot find $libpcre2_dir/lib]) + fi + fi + + found_libpcre2="yes" + elif test -n "$libpcre2_include_dir"; then + LIBPCRE2_CFLAGS="-I$libpcre2_include_dir" + + if test -n "$libpcre2_lib_dir"; then + LIBPCRE2_LDFLAGS="-L$libpcre2_lib_dir" + fi + + found_libpcre2="yes" + elif test -n "$libpcre2_lib_dir"; then + LIBPCRE2_LDFLAGS="-L$libpcre2_lib_dir" + + found_libpcre2="yes" + else + # + # search default directories + # + + if test -f /usr/include/pcre2.h; then + found_libpcre2="yes" + elif test -f /usr/local/include/pcre2.h; then + LIBPCRE2_CFLAGS="-I/usr/local/include" + LIBPCRE2_LDFLAGS="-L/usr/local/lib" + + found_libpcre2="yes" + elif test -f /usr/pkg/include/pcre2.h; then + LIBPCRE2_CFLAGS="-I/usr/pkg/include" + LIBPCRE2_LDFLAGS="-L/usr/pkg/lib" + LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS -Wl,-R/usr/pkg/lib" + + found_libpcre2="yes" + elif test -f /opt/csw/include/pcre2.h; then + LIBPCRE2_CFLAGS="-I/opt/csw/include" + LIBPCRE2_LDFLAGS="-L/opt/csw/lib" + + if $(echo "$CFLAGS"|grep -q -- "-m64") ; then + LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS/64 -Wl,-R/opt/csw/lib/64" + else + LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS -Wl,-R/opt/csw/lib" + fi + + found_libpcre2="yes" + else + found_libpcre2="no" + fi + fi fi - fi - if test -n "$_libpcre2_dir_set" -o -f /usr/include/pcre2.h; then - found_libpcre2="yes" - elif test -f /usr/local/include/pcre2.h; then - LIBPCRE2_CFLAGS="-I/usr/local/include" - LIBPCRE2_LDFLAGS="-L/usr/local/lib" - found_libpcre2="yes" - elif test -f /usr/pkg/include/pcre2.h; then - LIBPCRE2_CFLAGS="-I/usr/pkg/include" - LIBPCRE2_LDFLAGS="-L/usr/pkg/lib" - LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS -Wl,-R/usr/pkg/lib" - found_libpcre2="yes" - elif test -f /opt/csw/include/pcre2.h; then - LIBPCRE2_CFLAGS="-I/opt/csw/include" - LIBPCRE2_LDFLAGS="-L/opt/csw/lib" - if $(echo "$CFLAGS"|grep -q -- "-m64") ; then - LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS/64 -Wl,-R/opt/csw/lib/64" - else - LIBPCRE2_LDFLAGS="$LIBPCRE2_LDFLAGS -Wl,-R/opt/csw/lib" + + # + # process --enable-static and --enable_static-libs flags + # + + if test "x$enable_static" = "xyes"; then + LIBPCRE2_LIBS=" $LIBPCRE2_LIBS -lpthread" + elif test "x$enable_static_libs" = "xyes"; then + if test "x$static_linking_support" == "xno"; then + AC_MSG_WARN([compiler has no direct suppor for static linkage]) + + if test -n "$libpcre2_lib_dir"; then + if test -f "$libpcre2_lib_dir/libpcre2-8.a"; then + LIBPCRE2_LIBS="$libpcre2_lib_dir/libpcre2-8.a" + else + AC_MSG_ERROR([cannot find $libpcre2_lib_dir/libpcre2-8.a]) + fi + elif test -n "$libpcre2_dir"; then + if test -f "$libpcre2_dir/lib/libpcre2-8.a"; then + LIBPCRE2_LIBS="$libpcre2_dir/lib/libpcre2-8.a" + else + AC_MSG_ERROR([cannot find $libpcre2_dir/lib/libpcre2-8.a]) + fi + else + AC_MSG_ERROR([libpcre2 directory must be given explicitly in this case]) + fi + else + LIBPCRE2_LIBS="$LIBPCRE2_LDFLAGS ${static_linking_support}static $LIBPCRE2_LIBS ${static_linking_support}dynamic" + LIBPCRE2_LDFLAGS="" + fi fi - found_libpcre2="yes" - else - found_libpcre2="no" - AC_MSG_RESULT(no) - fi - if test "x$found_libpcre2" = "xyes"; then - am_save_CFLAGS="$CFLAGS" - am_save_LDFLAGS="$LDFLAGS" - am_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $LIBPCRE2_CFLAGS" - LDFLAGS="$LDFLAGS $LIBPCRE2_LDFLAGS" - LIBS="$LIBS $LIBPCRE2_LIBS" + # + # try building with pcre2 + # - found_libpcre2="no" - LIBPCRE2_TRY_LINK([no]) + AC_MSG_CHECKING([for libpcre2 support]) - CFLAGS="$am_save_CFLAGS" - LDFLAGS="$am_save_LDFLAGS" - LIBS="$am_save_LIBS" - fi + if test "x$found_libpcre2" = "xyes"; then + am_save_CFLAGS="$CFLAGS" + am_save_LDFLAGS="$LDFLAGS" + am_save_LIBS="$LIBS" - if test "x$found_libpcre2" = "xyes"; then - AC_MSG_RESULT(yes) - else - LIBPCRE2_CFLAGS="" - LIBPCRE2_LDFLAGS="" - LIBPCRE2_LIBS="" - fi + CFLAGS="$CFLAGS $LIBPCRE2_CFLAGS" + LDFLAGS="$LDFLAGS $LIBPCRE2_LDFLAGS" + LIBS="$LIBS $LIBPCRE2_LIBS" + + found_libpcre2="no" + LIBPCRE2_TRY_LINK([no]) + + if test "x$found_libpcre2" = "xyes"; then + AC_MSG_RESULT(yes) + else + AC_MSG_RESULT(no) + if test "$1" = "mandatory"; then + AC_MSG_NOTICE([CFLAGS: $CFLAGS]) + AC_MSG_NOTICE([LDFLAGS: $LDFLAGS]) + AC_MSG_NOTICE([LIBS: $LIBS]) + AC_MSG_ERROR([cannot build with libpcre2]) + else + LIBPCRE2_CFLAGS="" + LIBPCRE2_LDFLAGS="" + LIBPCRE2_LIBS="" + fi + fi - AC_SUBST(LIBPCRE2_CFLAGS) - AC_SUBST(LIBPCRE2_LDFLAGS) - AC_SUBST(LIBPCRE2_LIBS) + CFLAGS="$am_save_CFLAGS" + LDFLAGS="$am_save_LDFLAGS" + LIBS="$am_save_LIBS" + else + AC_MSG_RESULT(no) + fi + + AC_SUBST(LIBPCRE2_CFLAGS) + AC_SUBST(LIBPCRE2_LDFLAGS) + AC_SUBST(LIBPCRE2_LIBS) + fi ])dnl diff --git a/src/libs/zbxcommon/comms.c b/src/libs/zbxcommon/comms.c index ba3277885a4..d72125e31bf 100644 --- a/src/libs/zbxcommon/comms.c +++ b/src/libs/zbxcommon/comms.c @@ -18,98 +18,6 @@ **/ #include "common.h" -#include "base64.h" - -int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size_t key_len, - char *data, size_t data_len, char *lastlogsize, size_t lastlogsize_len, - char *timestamp, size_t timestamp_len, char *source, size_t source_len, - char *severity, size_t severity_len) -{ - int i, ret = SUCCEED; - char *data_b64 = NULL; - - assert(NULL != host && 0 != host_len); - assert(NULL != key && 0 != key_len); - assert(NULL != data && 0 != data_len); - assert(NULL != lastlogsize && 0 != lastlogsize_len); - assert(NULL != timestamp && 0 != timestamp_len); - assert(NULL != source && 0 != source_len); - assert(NULL != severity && 0 != severity_len); - - if (SUCCEED == xml_get_data_dyn(xml, "host", &data_b64)) - { - str_base64_decode(data_b64, host, (int)host_len - 1, &i); - host[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - { - *host = '\0'; - ret = FAIL; - } - - if (SUCCEED == xml_get_data_dyn(xml, "key", &data_b64)) - { - str_base64_decode(data_b64, key, (int)key_len - 1, &i); - key[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - { - *key = '\0'; - ret = FAIL; - } - - if (SUCCEED == xml_get_data_dyn(xml, "data", &data_b64)) - { - str_base64_decode(data_b64, data, (int)data_len - 1, &i); - data[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - { - *data = '\0'; - ret = FAIL; - } - - if (SUCCEED == xml_get_data_dyn(xml, "lastlogsize", &data_b64)) - { - str_base64_decode(data_b64, lastlogsize, (int)lastlogsize_len - 1, &i); - lastlogsize[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - *lastlogsize = '\0'; - - if (SUCCEED == xml_get_data_dyn(xml, "timestamp", &data_b64)) - { - str_base64_decode(data_b64, timestamp, (int)timestamp_len - 1, &i); - timestamp[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - *timestamp = '\0'; - - if (SUCCEED == xml_get_data_dyn(xml, "source", &data_b64)) - { - str_base64_decode(data_b64, source, (int)source_len - 1, &i); - source[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - *source = '\0'; - - if (SUCCEED == xml_get_data_dyn(xml, "severity", &data_b64)) - { - str_base64_decode(data_b64, severity, (int)severity_len - 1, &i); - severity[i] = '\0'; - xml_free_data_dyn(&data_b64); - } - else - *severity = '\0'; - - return ret; -} /****************************************************************************** * * diff --git a/src/zabbix_js/Makefile.am b/src/zabbix_js/Makefile.am index c8b360e5619..ec8465fc1b8 100644 --- a/src/zabbix_js/Makefile.am +++ b/src/zabbix_js/Makefile.am @@ -20,7 +20,7 @@ zabbix_js_LDADD = \ $(top_srcdir)/src/libs/zbxcompress/libzbxcompress.a \ $(top_srcdir)/src/libs/zbxhttp/libzbxhttp.a \ $(top_srcdir)/src/libs/zbxxml/libzbxxml.a - -zabbix_js_LDADD += @ZBXJS_LIBS@ -zabbix_js_LDFLAGS = @ZBXJS_LDFLAGS@ +zabbix_js_LDADD += @ZBXJS_LIBS@ $(LIBXML2_LIBS) + +zabbix_js_LDFLAGS = @ZBXJS_LDFLAGS@ $(LIBXML2_LDFLAGS) diff --git a/src/zabbix_proxy/Makefile.am b/src/zabbix_proxy/Makefile.am index 5a6c77d98b9..cdcda13c83b 100644 --- a/src/zabbix_proxy/Makefile.am +++ b/src/zabbix_proxy/Makefile.am @@ -67,6 +67,7 @@ zabbix_proxy_LDADD = \ $(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \ $(top_builddir)/src/libs/zbxcrypto/libzbxcrypto.a \ $(top_builddir)/src/libs/zbxcomms/libzbxcomms.a \ + $(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \ $(top_builddir)/src/libs/zbxcommshigh/libzbxcommshigh.a \ $(top_builddir)/src/libs/zbxjson/libzbxjson.a \ $(top_builddir)/src/libs/zbxhttp/libzbxhttp.a \ diff --git a/src/zabbix_server/Makefile.am b/src/zabbix_server/Makefile.am index 96e778f8b44..23d1430c2db 100644 --- a/src/zabbix_server/Makefile.am +++ b/src/zabbix_server/Makefile.am @@ -101,6 +101,7 @@ zabbix_server_LDADD = \ $(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \ $(top_builddir)/src/libs/zbxcrypto/libzbxcrypto.a \ $(top_builddir)/src/libs/zbxcomms/libzbxcomms.a \ + $(top_builddir)/src/libs/zbxcommon/libzbxcommon.a \ $(top_builddir)/src/libs/zbxcommshigh/libzbxcommshigh.a \ $(top_builddir)/src/libs/zbxjson/libzbxjson.a \ $(top_builddir)/src/libs/zbxhttp/libzbxhttp.a \ diff --git a/src/zabbix_server/trapper/Makefile.am b/src/zabbix_server/trapper/Makefile.am index adece376064..05947d08f9e 100644 --- a/src/zabbix_server/trapper/Makefile.am +++ b/src/zabbix_server/trapper/Makefile.am @@ -30,3 +30,6 @@ libzbxtrapper_server_a_SOURCES = \ libzbxtrapper_proxy_a_SOURCES = \ trapper_proxy.c \ trapper_request.h + +libzbxtrapper_a_CFLAGS = \ + $(LIBXML2_CFLAGS) diff --git a/src/zabbix_server/trapper/trapper.c b/src/zabbix_server/trapper/trapper.c index 669365ba018..e52f7e22340 100644 --- a/src/zabbix_server/trapper/trapper.c +++ b/src/zabbix_server/trapper/trapper.c @@ -35,6 +35,7 @@ #include "trapper_expressions_evaluate.h" #include "trapper_item_test.h" #include "trapper_request.h" +#include "base64.h" #ifdef HAVE_NETSNMP # include "zbxrtc.h" @@ -949,6 +950,97 @@ static void active_passive_misconfig(zbx_socket_t *sock) zbx_free(msg); } +static int comms_parse_response(char *xml, char *host, size_t host_len, char *key, size_t key_len, + char *data, size_t data_len, char *lastlogsize, size_t lastlogsize_len, + char *timestamp, size_t timestamp_len, char *source, size_t source_len, + char *severity, size_t severity_len) +{ + int i, ret = SUCCEED; + char *data_b64 = NULL; + + assert(NULL != host && 0 != host_len); + assert(NULL != key && 0 != key_len); + assert(NULL != data && 0 != data_len); + assert(NULL != lastlogsize && 0 != lastlogsize_len); + assert(NULL != timestamp && 0 != timestamp_len); + assert(NULL != source && 0 != source_len); + assert(NULL != severity && 0 != severity_len); + + if (SUCCEED == xml_get_data_dyn(xml, "host", &data_b64)) + { + str_base64_decode(data_b64, host, (int)host_len - 1, &i); + host[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + { + *host = '\0'; + ret = FAIL; + } + + if (SUCCEED == xml_get_data_dyn(xml, "key", &data_b64)) + { + str_base64_decode(data_b64, key, (int)key_len - 1, &i); + key[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + { + *key = '\0'; + ret = FAIL; + } + + if (SUCCEED == xml_get_data_dyn(xml, "data", &data_b64)) + { + str_base64_decode(data_b64, data, (int)data_len - 1, &i); + data[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + { + *data = '\0'; + ret = FAIL; + } + + if (SUCCEED == xml_get_data_dyn(xml, "lastlogsize", &data_b64)) + { + str_base64_decode(data_b64, lastlogsize, (int)lastlogsize_len - 1, &i); + lastlogsize[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + *lastlogsize = '\0'; + + if (SUCCEED == xml_get_data_dyn(xml, "timestamp", &data_b64)) + { + str_base64_decode(data_b64, timestamp, (int)timestamp_len - 1, &i); + timestamp[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + *timestamp = '\0'; + + if (SUCCEED == xml_get_data_dyn(xml, "source", &data_b64)) + { + str_base64_decode(data_b64, source, (int)source_len - 1, &i); + source[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + *source = '\0'; + + if (SUCCEED == xml_get_data_dyn(xml, "severity", &data_b64)) + { + str_base64_decode(data_b64, severity, (int)severity_len - 1, &i); + severity[i] = '\0'; + xml_free_data_dyn(&data_b64); + } + else + *severity = '\0'; + + return ret; +} + static int process_trap(zbx_socket_t *sock, char *s, ssize_t bytes_received, zbx_timespec_t *ts) { int ret = SUCCEED; |