From 8ae560e7c65f2c4739acf7583fc4b660071a08de Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Fri, 12 Jan 2024 14:04:47 -0800 Subject: [PATCH] Add feature tests for AF_PACKET, GeoIP, and JavaScript to zeek-config --- CMakeLists.txt | 2 ++ cmake_templates/zeek-config.in | 39 ++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eeffce462e..cbb840f6d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1101,6 +1101,7 @@ endif () # Tell the plugin code that we're building as part of the main tree. set(ZEEK_PLUGIN_INTERNAL_BUILD true CACHE INTERNAL "" FORCE) +set(ZEEK_HAVE_AF_PACKET no) if (${CMAKE_SYSTEM_NAME} MATCHES Linux) if (NOT DISABLE_AF_PACKET) if (NOT AF_PACKET_PLUGIN_PATH) @@ -1108,6 +1109,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux) endif () list(APPEND ZEEK_INCLUDE_PLUGINS ${AF_PACKET_PLUGIN_PATH}) + set(ZEEK_HAVE_AF_PACKET yes) endif () endif () diff --git a/cmake_templates/zeek-config.in b/cmake_templates/zeek-config.in index c78ea5e855..29943e84e1 100755 --- a/cmake_templates/zeek-config.in +++ b/cmake_templates/zeek-config.in @@ -6,6 +6,9 @@ btest_tools_dir="@ZEEK_CONFIG_BTEST_TOOLS_DIR@" build_type="@CMAKE_BUILD_TYPE_LOWER@" cmake_dir="@ZEEK_CMAKE_CONFIG_DIR@" config_dir="@ZEEK_ETC_INSTALL_DIR@" +have_af_packet="@ZEEK_HAVE_AF_PACKET@" +have_geoip="@USE_GEOIP@" +have_javascript="@ZEEK_HAVE_JAVASCRIPT@" have_spicy="@USE_SPICY_ANALYZERS@" include_dir="@CMAKE_INSTALL_PREFIX@/include" lib_dir="@CMAKE_INSTALL_FULL_LIBDIR@" @@ -18,6 +21,18 @@ version="@ZEEK_VERSION_FULL@" zeek_dist="@ZEEK_DIST@" zeekpath="@DEFAULT_ZEEKPATH@" +report_feature() { + # $1: cmake feature flag value + input=$(echo "$1" | tr '[:lower:]' '[:upper:]') + if [ "$input" = "1" ] || [ "$input" = "ON" ] || [ "$input" = "YES" ] || [ "$input" = "TRUE" ] || [ "$input" = "Y" ]; then + echo "yes" + exit 0 + fi + + echo "no" + exit 1 +} + add_path() { # $1: existing path # $2: path to add @@ -67,9 +82,12 @@ Toplevel installation directories for third-party components: --binpac_root BinPAC compiler --broker_root Broker communication framework -Feature tests: +Feature tests (prints 'yes' if supported; exit code reflects result): - --have-spicy-analyzers Prints 'yes' if built-in Spicy analyzers are available; exit code reflects result + --have-af-packet Native AF_PACKET support + --have-geoip IP address geolocation & AS lookups + --have-javascript JavaScript support + --have-spicy-analyzers built-in Spicy analyzers " } @@ -109,14 +127,17 @@ while [ $# -ne 0 ]; do --config_dir) echo $config_dir ;; + --have-af-packet) + report_feature "$have_af_packet" + ;; + --have-geoip) + report_feature "$have_geoip" + ;; + --have-javascript) + report_feature "$have_javascript" + ;; --have-spicy-analyzers) - if [ "$have_spicy" = "yes" ]; then - echo "yes" - exit 0 - else - echo "no" - exit 1 - fi + report_feature "$have_spicy" ;; --include_dir) echo $include_dir