mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/seth/plugin-dir-fixes'
* origin/topic/seth/plugin-dir-fixes: Fixes for the builtin plugin functionality
This commit is contained in:
commit
6c747a0fca
7 changed files with 21 additions and 19 deletions
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
||||||
|
4.1.0-dev.725 | 2021-06-11 11:54:30 -0700
|
||||||
|
|
||||||
|
* Fixes for the builtin plugin functionality (Seth Hall, Corelight)
|
||||||
|
|
||||||
4.1.0-dev.722 | 2021-06-10 10:42:57 -0700
|
4.1.0-dev.722 | 2021-06-10 10:42:57 -0700
|
||||||
|
|
||||||
* Added --include-plugins configure argument (Seth Hall, Corelight)
|
* Added --include-plugins configure argument (Seth Hall, Corelight)
|
||||||
|
|
|
@ -490,7 +490,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(DEFAULT_ZEEKPATH .:${ZEEK_SCRIPT_INSTALL_PATH}:${ZEEK_SCRIPT_INSTALL_PATH}/policy:${ZEEK_SCRIPT_INSTALL_PATH}/site)
|
set(DEFAULT_ZEEKPATH .:${ZEEK_SCRIPT_INSTALL_PATH}:${ZEEK_SCRIPT_INSTALL_PATH}/policy:${ZEEK_SCRIPT_INSTALL_PATH}/site:${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins)
|
||||||
|
|
||||||
if ( NOT BINARY_PACKAGING_MODE )
|
if ( NOT BINARY_PACKAGING_MODE )
|
||||||
set(ZEEK_DIST ${CMAKE_SOURCE_DIR})
|
set(ZEEK_DIST ${CMAKE_SOURCE_DIR})
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.1.0-dev.722
|
4.1.0-dev.725
|
||||||
|
|
2
cmake
2
cmake
|
@ -1 +1 @@
|
||||||
Subproject commit 74259745dea5ee4889d1ac1f4ebde4e2c59c329a
|
Subproject commit d8d09afec01055f8258501909f6b48482a5663ed
|
|
@ -194,21 +194,11 @@ foreach (plugin_dir ${BUILTIN_PLUGIN_LIST})
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/builtin-plugins/${plugin_name})
|
${CMAKE_CURRENT_BINARY_DIR}/builtin-plugins/${plugin_name})
|
||||||
|
|
||||||
add_subdirectory(${plugin_dir} ${CMAKE_CURRENT_BINARY_DIR}/builtin-plugins/${plugin_name})
|
add_subdirectory(${plugin_dir} ${CMAKE_CURRENT_BINARY_DIR}/builtin-plugins/${plugin_name})
|
||||||
|
|
||||||
set(preload_script ${plugin_dir}/scripts/__preload__.zeek)
|
|
||||||
if (EXISTS ${plugin_dir}/scripts/__preload__.zeek)
|
|
||||||
file(APPEND ${CMAKE_BINARY_DIR}/scripts/builtin-plugins/__preload__.zeek "\n@load ${preload_script}")
|
|
||||||
endif()
|
|
||||||
set(load_script ${plugin_dir}/scripts/__load__.zeek)
|
|
||||||
if (EXISTS ${plugin_dir}/scripts/__load__.zeek)
|
|
||||||
file(APPEND ${CMAKE_BINARY_DIR}/scripts/builtin-plugins/__load__.zeek "\n@load ${load_script}")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
install(FILES ${PRELOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
install(FILES ${PRELOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
||||||
install(FILES ${LOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
install(FILES ${LOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
||||||
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
## bro target
|
## bro target
|
||||||
|
|
||||||
|
|
|
@ -415,21 +415,28 @@ void Manager::RegisterBifFile(const char* plugin, bif_init_func c)
|
||||||
|
|
||||||
void Manager::ExtendZeekPathForPlugins()
|
void Manager::ExtendZeekPathForPlugins()
|
||||||
{
|
{
|
||||||
|
// Extend the path outside of the loop to avoid looking through a longer path for each plugin
|
||||||
|
vector<string> path_additions;
|
||||||
|
|
||||||
for ( const auto& p : Manager::ActivePlugins() )
|
for ( const auto& p : Manager::ActivePlugins() )
|
||||||
{
|
{
|
||||||
if ( p->DynamicPlugin() || p->Name().empty() )
|
if ( p->DynamicPlugin() || p->Name().empty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string canon = std::regex_replace(p->Name(), std::regex("::"), "_");
|
string canon = std::regex_replace(p->Name(), std::regex("::"), "_");
|
||||||
string dir = "plugins/" + canon + "/";
|
string dir = "builtin-plugins/" + canon;
|
||||||
|
|
||||||
// Use find_file to find the directory in the path.
|
// Use find_file to find the directory in the path.
|
||||||
string script_dir = util::find_file(dir, util::zeek_path());
|
string script_dir = util::find_file(dir, util::zeek_path());
|
||||||
if ( ! util::is_dir(script_dir) )
|
if ( script_dir.empty() || ! util::is_dir(script_dir) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
DBG_LOG(DBG_PLUGINS, " Adding %s to ZEEKPATH", script_dir.c_str());
|
DBG_LOG(DBG_PLUGINS, " Adding %s to ZEEKPATH", script_dir.c_str());
|
||||||
util::detail::add_to_zeek_path(script_dir);
|
path_additions.push_back(script_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( const auto& plugin_path : path_additions )
|
||||||
|
util::detail::add_to_zeek_path(plugin_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::InitPreScript()
|
void Manager::InitPreScript()
|
||||||
|
|
|
@ -601,14 +601,15 @@ SetupResult setup(int argc, char** argv, Options* zopts)
|
||||||
// manager will be missing the plugins we want to try to add to the path.
|
// manager will be missing the plugins we want to try to add to the path.
|
||||||
plugin_mgr->ExtendZeekPathForPlugins();
|
plugin_mgr->ExtendZeekPathForPlugins();
|
||||||
|
|
||||||
if ( options.print_usage )
|
|
||||||
usage(argv[0], 0);
|
|
||||||
|
|
||||||
for ( const auto& x : requested_plugins )
|
for ( const auto& x : requested_plugins )
|
||||||
plugin_mgr->ActivateDynamicPlugin(std::move(x));
|
plugin_mgr->ActivateDynamicPlugin(std::move(x));
|
||||||
|
|
||||||
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
plugin_mgr->ActivateDynamicPlugins(! options.bare_mode);
|
||||||
|
|
||||||
|
// Print usage after plugins load so that any path extensions are properly shown.
|
||||||
|
if ( options.print_usage )
|
||||||
|
usage(argv[0], 0);
|
||||||
|
|
||||||
init_event_handlers();
|
init_event_handlers();
|
||||||
|
|
||||||
md5_type = make_intrusive<OpaqueType>("md5");
|
md5_type = make_intrusive<OpaqueType>("md5");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue