Add feature tests for AF_PACKET, GeoIP, and JavaScript to zeek-config

This commit is contained in:
Christian Kreibich 2024-01-12 14:04:47 -08:00
parent 3b7749b8de
commit 8ae560e7c6
2 changed files with 32 additions and 9 deletions

View file

@ -1101,6 +1101,7 @@ endif ()
# Tell the plugin code that we're building as part of the main tree. # 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_PLUGIN_INTERNAL_BUILD true CACHE INTERNAL "" FORCE)
set(ZEEK_HAVE_AF_PACKET no)
if (${CMAKE_SYSTEM_NAME} MATCHES Linux) if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
if (NOT DISABLE_AF_PACKET) if (NOT DISABLE_AF_PACKET)
if (NOT AF_PACKET_PLUGIN_PATH) if (NOT AF_PACKET_PLUGIN_PATH)
@ -1108,6 +1109,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES Linux)
endif () endif ()
list(APPEND ZEEK_INCLUDE_PLUGINS ${AF_PACKET_PLUGIN_PATH}) list(APPEND ZEEK_INCLUDE_PLUGINS ${AF_PACKET_PLUGIN_PATH})
set(ZEEK_HAVE_AF_PACKET yes)
endif () endif ()
endif () endif ()

View file

@ -6,6 +6,9 @@ btest_tools_dir="@ZEEK_CONFIG_BTEST_TOOLS_DIR@"
build_type="@CMAKE_BUILD_TYPE_LOWER@" build_type="@CMAKE_BUILD_TYPE_LOWER@"
cmake_dir="@ZEEK_CMAKE_CONFIG_DIR@" cmake_dir="@ZEEK_CMAKE_CONFIG_DIR@"
config_dir="@ZEEK_ETC_INSTALL_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@" have_spicy="@USE_SPICY_ANALYZERS@"
include_dir="@CMAKE_INSTALL_PREFIX@/include" include_dir="@CMAKE_INSTALL_PREFIX@/include"
lib_dir="@CMAKE_INSTALL_FULL_LIBDIR@" lib_dir="@CMAKE_INSTALL_FULL_LIBDIR@"
@ -18,6 +21,18 @@ version="@ZEEK_VERSION_FULL@"
zeek_dist="@ZEEK_DIST@" zeek_dist="@ZEEK_DIST@"
zeekpath="@DEFAULT_ZEEKPATH@" 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() { add_path() {
# $1: existing path # $1: existing path
# $2: path to add # $2: path to add
@ -67,9 +82,12 @@ Toplevel installation directories for third-party components:
--binpac_root BinPAC compiler --binpac_root BinPAC compiler
--broker_root Broker communication framework --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) --config_dir)
echo $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) --have-spicy-analyzers)
if [ "$have_spicy" = "yes" ]; then report_feature "$have_spicy"
echo "yes"
exit 0
else
echo "no"
exit 1
fi
;; ;;
--include_dir) --include_dir)
echo $include_dir echo $include_dir