mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fixes for the builtin plugin functionality
This commit is contained in:
parent
623f2b4e71
commit
8222193525
5 changed files with 16 additions and 18 deletions
|
@ -490,7 +490,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(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 )
|
||||
set(ZEEK_DIST ${CMAKE_SOURCE_DIR})
|
||||
|
|
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})
|
||||
|
||||
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()
|
||||
|
||||
install(FILES ${PRELOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
||||
install(FILES ${LOAD_SCRIPT} DESTINATION ${ZEEK_SCRIPT_INSTALL_PATH}/builtin-plugins/)
|
||||
|
||||
|
||||
########################################################################
|
||||
## bro target
|
||||
|
||||
|
|
|
@ -415,21 +415,28 @@ void Manager::RegisterBifFile(const char* plugin, bif_init_func c)
|
|||
|
||||
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() )
|
||||
{
|
||||
if ( p->DynamicPlugin() || p->Name().empty() )
|
||||
continue;
|
||||
|
||||
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.
|
||||
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;
|
||||
|
||||
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()
|
||||
|
|
|
@ -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.
|
||||
plugin_mgr->ExtendZeekPathForPlugins();
|
||||
|
||||
if ( options.print_usage )
|
||||
usage(argv[0], 0);
|
||||
|
||||
for ( const auto& x : requested_plugins )
|
||||
plugin_mgr->ActivateDynamicPlugin(std::move(x));
|
||||
|
||||
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();
|
||||
|
||||
md5_type = make_intrusive<OpaqueType>("md5");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue