diff --git a/CHANGES b/CHANGES index 8e90360bcc..e34189f34d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,11 @@ +5.0.0-dev.470 | 2022-05-24 11:55:37 -0700 + + * Ensure presence of Zeek-related directories in toplevel CMakeLists.txt (Christian Kreibich, Corelight) + + * Add base/misc/installation.zeek, with Zeek installation directories (Christian Kreibich, Corelight) + + * Add scripts.base.misc.installation btest (Christian Kreibich, Corelight) + 5.0.0-dev.466 | 2022-05-23 17:47:08 -0700 * Add DOCKERFILE_VERSION variable to all CI dockerfiles (Tim Wojtulewicz, Corelight) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5303341b0d..fb5eb39561 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,6 +65,27 @@ else () CACHE STRING "Installation path for plugins" FORCE) endif () +if ( NOT ZEEK_ETC_INSTALL_DIR ) + set(ZEEK_ETC_INSTALL_DIR ${ZEEK_ROOT_DIR}/etc) +endif () + +if ( NOT ZEEK_STATE_DIR ) + set(ZEEK_STATE_DIR ${ZEEK_ROOT_DIR}/var/lib) +endif () + +if ( NOT ZEEK_SPOOL_DIR ) + set(ZEEK_SPOOL_DIR ${ZEEK_ROOT_DIR}/spool) +endif () + +if ( NOT ZEEK_LOG_DIR ) + set(ZEEK_LOG_DIR ${ZEEK_ROOT_DIR}/logs) +endif () + +install(DIRECTORY DESTINATION ${ZEEK_ETC_INSTALL_DIR}) +install(DIRECTORY DESTINATION ${ZEEK_STATE_DIR}) +install(DIRECTORY DESTINATION ${ZEEK_SPOOL_DIR}) +install(DIRECTORY DESTINATION ${ZEEK_LOG_DIR}) + configure_file(zeek-path-dev.in ${CMAKE_CURRENT_BINARY_DIR}/zeek-path-dev) execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/zeek-wrapper.in" @@ -612,7 +633,7 @@ if ( INSTALL_ZKG ) # An etc/zkg directory for zkg's config file simplifies zkg's # config file code. set(ZEEK_ZKG_CONFIG_DIR "${ZEEK_ETC_INSTALL_DIR}/zkg") - set(ZEEK_ZKG_STATE_DIR "${ZEEK_ROOT_DIR}/var/lib/zkg") + set(ZEEK_ZKG_STATE_DIR "${ZEEK_STATE_DIR}/zkg") configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zkg-config.in @@ -768,10 +789,16 @@ message( "\n" "\nBuild type: ${CMAKE_BUILD_TYPE}" "\nBuild dir: ${PROJECT_BINARY_DIR}" + "\n" "\nInstall prefix: ${CMAKE_INSTALL_PREFIX}" + "\nConfig file dir: ${ZEEK_ETC_INSTALL_DIR}" + "\nLog dir: ${ZEEK_LOG_DIR}" "\nPlugin dir: ${BRO_PLUGIN_INSTALL_PATH}" "\nPython module dir: ${PY_MOD_INSTALL_DIR}" - "\nZeek Script Path: ${ZEEK_SCRIPT_INSTALL_PATH}" + "\nScript dir: ${ZEEK_SCRIPT_INSTALL_PATH}" + "\nSpool dir: ${ZEEK_SPOOL_DIR}" + "\nState dir: ${ZEEK_STATE_DIR}" + "\n" "\nDebug mode: ${ENABLE_DEBUG}" "\nUnit tests: ${ENABLE_ZEEK_UNIT_TESTS}" "\nBuiltin Plugins: ${ZEEK_BUILTIN_PLUGINS}" diff --git a/NEWS b/NEWS index f6ee1a2692..dabdd259fd 100644 --- a/NEWS +++ b/NEWS @@ -66,6 +66,13 @@ New Functionality directly or indirectly. The number is not meant to be precise, but rather comparable: larger footprint correlates with more memory consumption. +- The new ``configure --statedir`` option lets you adjust the installation's + persistent state directory. It defaults to ``var/lib`` under your Zeek + installation's root directory. + +- The ``base/misc/installation.zeek`` script provides your Zeek installation's + key directories. + Changed Functionality --------------------- diff --git a/VERSION b/VERSION index d0f176d988..6a8c306e4b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.0.0-dev.466 +5.0.0-dev.470 diff --git a/configure b/configure index 56adde85cb..8d0ee612b3 100755 --- a/configure +++ b/configure @@ -38,13 +38,12 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --localstatedir=PATH when using ZeekControl, path to store log files and run-time data (within log/ and spool/ subdirs) [PREFIX] - --spooldir=PATH when using ZeekControl, path to store run-time data - [PREFIX/spool] - --logdir=PATH when using ZeekControl, path to store log file - [PREFIX/logs] + --spooldir=PATH directory for in-progress logs [PREFIX/spool] + --statedir=PATH directory for variable state [PREFIX/var/lib] + --logdir=PATH directory for finalized logs [PREFIX/logs] --libdir=PATH installation directory for library files [PREFIX/lib] --plugindir=PATH installation directory for plugins [LIBDIR/zeek/plugin] - --conf-files-dir=PATH config files installation directory [PREFIX/etc] + --conf-files-dir=PATH installation directory for config files [PREFIX/etc] --mandir=PATH installation path for man pages [PREFIX/share/man] --python-dir=PATH explicit installation directory for Python modules --python-prefix=PATH versioned installation directory for Python modules, @@ -256,6 +255,9 @@ while [ $# -ne 0 ]; do --spooldir=*) append_cache_entry ZEEK_SPOOL_DIR PATH $optarg ;; + --statedir=*) + append_cache_entry ZEEK_STATE_DIR PATH $optarg + ;; --logdir=*) append_cache_entry ZEEK_LOG_DIR PATH $optarg ;; diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 96b2c897c1..168eba704b 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -12,3 +12,11 @@ InstallPackageConfigFile( ${CMAKE_CURRENT_SOURCE_DIR}/site/local.zeek ${ZEEK_SCRIPT_INSTALL_PATH}/site local.zeek) + +# Substitute values in templated script files, and install them. +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/base/misc/installation.zeek.in + ${CMAKE_CURRENT_BINARY_DIR}/base/misc/installation.zeek @ONLY) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/base/misc/installation.zeek + DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/base/misc) diff --git a/scripts/base/init-default.zeek b/scripts/base/init-default.zeek index b7d1b01b99..32274faca6 100644 --- a/scripts/base/init-default.zeek +++ b/scripts/base/init-default.zeek @@ -81,4 +81,5 @@ @load base/misc/find-checksum-offloading @load base/misc/find-filtered-trace +@load base/misc/installation @load base/misc/version diff --git a/scripts/base/misc/installation.zeek.in b/scripts/base/misc/installation.zeek.in new file mode 100644 index 0000000000..84536deb95 --- /dev/null +++ b/scripts/base/misc/installation.zeek.in @@ -0,0 +1,25 @@ +##! This module collects properties of the Zeek installation. +##! +##! Directories are absolute and guaranteed to exist. Not all are necessarily in +##! operational use -- this depends on how you're running Zeek (as a standalone +##! process or clusterized, via zeekctl or the Management framework, etc). +##! +##! For details about Zeek's version, see the :zeek:see:`Version` module. +module Installation; + +export { + ## Zeek installation root directory. + const root_dir = "@ZEEK_ROOT_DIR@"; + + ## The installation's configuration directory. + const etc_dir = "@ZEEK_ETC_INSTALL_DIR@"; + + ## The installation's log directory. + const log_dir = "@ZEEK_LOG_DIR@"; + + ## The installation's spool directory. + const spool_dir = "@ZEEK_SPOOL_DIR@"; + + ## The installation's variable-state directory. + const state_dir = "@ZEEK_STATE_DIR@"; +} diff --git a/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log b/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log index 1a5ff60c6b..ecf792fbc6 100644 --- a/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log +++ b/testing/btest/Baseline/coverage.default-load-baseline/canonified_loaded_scripts.log @@ -444,6 +444,7 @@ scripts/base/init-default.zeek scripts/base/files/extract/main.zeek scripts/base/misc/find-checksum-offloading.zeek scripts/base/misc/find-filtered-trace.zeek + build/scripts/base/misc/installation.zeek scripts/base/misc/version.zeek build/scripts/builtin-plugins/__preload__.zeek build/scripts/builtin-plugins/Zeek_Spicy/__preload__.zeek diff --git a/testing/btest/Baseline/plugins.hooks/output b/testing/btest/Baseline/plugins.hooks/output index 7e8ed9f6ea..ba2ea70ddb 100644 --- a/testing/btest/Baseline/plugins.hooks/output +++ b/testing/btest/Baseline/plugins.hooks/output @@ -995,6 +995,7 @@ 0.000000 MetaHookPost LoadFile(0, base<...>/imap, <...>/imap) -> -1 0.000000 MetaHookPost LoadFile(0, base<...>/input, <...>/input) -> -1 0.000000 MetaHookPost LoadFile(0, base<...>/input.bif, <...>/input.bif.zeek) -> -1 +0.000000 MetaHookPost LoadFile(0, base<...>/installation, <...>/installation.zeek) -> -1 0.000000 MetaHookPost LoadFile(0, base<...>/intel, <...>/intel) -> -1 0.000000 MetaHookPost LoadFile(0, base<...>/ip, <...>/ip) -> -1 0.000000 MetaHookPost LoadFile(0, base<...>/iptunnel, <...>/iptunnel) -> -1 @@ -1379,6 +1380,7 @@ 0.000000 MetaHookPost LoadFileExtended(0, base<...>/imap, <...>/imap) -> (-1, ) 0.000000 MetaHookPost LoadFileExtended(0, base<...>/input, <...>/input) -> (-1, ) 0.000000 MetaHookPost LoadFileExtended(0, base<...>/input.bif, <...>/input.bif.zeek) -> (-1, ) +0.000000 MetaHookPost LoadFileExtended(0, base<...>/installation, <...>/installation.zeek) -> (-1, ) 0.000000 MetaHookPost LoadFileExtended(0, base<...>/intel, <...>/intel) -> (-1, ) 0.000000 MetaHookPost LoadFileExtended(0, base<...>/ip, <...>/ip) -> (-1, ) 0.000000 MetaHookPost LoadFileExtended(0, base<...>/iptunnel, <...>/iptunnel) -> (-1, ) @@ -2473,6 +2475,7 @@ 0.000000 MetaHookPre LoadFile(0, base<...>/imap, <...>/imap) 0.000000 MetaHookPre LoadFile(0, base<...>/input, <...>/input) 0.000000 MetaHookPre LoadFile(0, base<...>/input.bif, <...>/input.bif.zeek) +0.000000 MetaHookPre LoadFile(0, base<...>/installation, <...>/installation.zeek) 0.000000 MetaHookPre LoadFile(0, base<...>/intel, <...>/intel) 0.000000 MetaHookPre LoadFile(0, base<...>/ip, <...>/ip) 0.000000 MetaHookPre LoadFile(0, base<...>/iptunnel, <...>/iptunnel) @@ -2857,6 +2860,7 @@ 0.000000 MetaHookPre LoadFileExtended(0, base<...>/imap, <...>/imap) 0.000000 MetaHookPre LoadFileExtended(0, base<...>/input, <...>/input) 0.000000 MetaHookPre LoadFileExtended(0, base<...>/input.bif, <...>/input.bif.zeek) +0.000000 MetaHookPre LoadFileExtended(0, base<...>/installation, <...>/installation.zeek) 0.000000 MetaHookPre LoadFileExtended(0, base<...>/intel, <...>/intel) 0.000000 MetaHookPre LoadFileExtended(0, base<...>/ip, <...>/ip) 0.000000 MetaHookPre LoadFileExtended(0, base<...>/iptunnel, <...>/iptunnel) @@ -3962,6 +3966,7 @@ 0.000000 | HookLoadFile base<...>/imap <...>/imap 0.000000 | HookLoadFile base<...>/input <...>/input 0.000000 | HookLoadFile base<...>/input.bif <...>/input.bif.zeek +0.000000 | HookLoadFile base<...>/installation <...>/installation.zeek 0.000000 | HookLoadFile base<...>/intel <...>/intel 0.000000 | HookLoadFile base<...>/ip <...>/ip 0.000000 | HookLoadFile base<...>/iptunnel <...>/iptunnel @@ -4346,6 +4351,7 @@ 0.000000 | HookLoadFileExtended base<...>/imap <...>/imap 0.000000 | HookLoadFileExtended base<...>/input <...>/input 0.000000 | HookLoadFileExtended base<...>/input.bif <...>/input.bif.zeek +0.000000 | HookLoadFileExtended base<...>/installation <...>/installation.zeek 0.000000 | HookLoadFileExtended base<...>/intel <...>/intel 0.000000 | HookLoadFileExtended base<...>/ip <...>/ip 0.000000 | HookLoadFileExtended base<...>/iptunnel <...>/iptunnel diff --git a/testing/btest/Baseline/scripts.base.misc.installation/.stdout b/testing/btest/Baseline/scripts.base.misc.installation/.stdout new file mode 100644 index 0000000000..49d861c74c --- /dev/null +++ b/testing/btest/Baseline/scripts.base.misc.installation/.stdout @@ -0,0 +1 @@ +### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. diff --git a/testing/btest/scripts/base/misc/installation.zeek b/testing/btest/scripts/base/misc/installation.zeek new file mode 100644 index 0000000000..98a650bacf --- /dev/null +++ b/testing/btest/scripts/base/misc/installation.zeek @@ -0,0 +1,18 @@ +# This test verifies that the directories in base/misc/installation.zeek do get +# substituted to absolute paths. It does not verify the path strings themselves +# since they may change from build to build. + +# @TEST-EXEC: zeek -b %INPUT +# @TEST-EXEC: btest-diff .stdout + +@load base/utils/paths +@load base/misc/installation + +global dirs = vector(Installation::root_dir, Installation::etc_dir, + Installation::log_dir, Installation::spool_dir, Installation::state_dir); + +for ( i in dirs ) + { + if ( dirs[i] != absolute_path_pat ) + print dirs[i]; + }