mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
When attempting to activate a plugin, load dynamic libraries first.
Just moving code. This is so that we can abort if dlopen() fails without having changed any other state yet.
This commit is contained in:
parent
3ebfcdf0ae
commit
df40e82fd6
1 changed files with 52 additions and 52 deletions
|
@ -175,58 +175,6 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
||||||
|
|
||||||
DBG_LOG(DBG_PLUGINS, "Activating plugin %s", name.c_str());
|
DBG_LOG(DBG_PLUGINS, "Activating plugin %s", name.c_str());
|
||||||
|
|
||||||
// Add the "scripts" and "bif" directories to ZEEKPATH.
|
|
||||||
std::string scripts = dir + "scripts";
|
|
||||||
|
|
||||||
if ( util::is_dir(scripts) )
|
|
||||||
{
|
|
||||||
DBG_LOG(DBG_PLUGINS, " Adding %s to ZEEKPATH", scripts.c_str());
|
|
||||||
util::detail::add_to_zeek_path(scripts);
|
|
||||||
}
|
|
||||||
|
|
||||||
string init;
|
|
||||||
|
|
||||||
// First load {scripts}/__preload__.zeek automatically.
|
|
||||||
for (const string& ext : util::detail::script_extensions)
|
|
||||||
{
|
|
||||||
init = dir + "scripts/__preload__" + ext;
|
|
||||||
|
|
||||||
if ( util::is_file(init) )
|
|
||||||
{
|
|
||||||
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
|
||||||
util::detail::warn_if_legacy_script(init);
|
|
||||||
scripts_to_load.push_back(init);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load {bif,scripts}/__load__.zeek automatically.
|
|
||||||
for (const string& ext : util::detail::script_extensions)
|
|
||||||
{
|
|
||||||
init = dir + "lib/bif/__load__" + ext;
|
|
||||||
|
|
||||||
if ( util::is_file(init) )
|
|
||||||
{
|
|
||||||
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
|
||||||
util::detail::warn_if_legacy_script(init);
|
|
||||||
scripts_to_load.push_back(init);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const string& ext : util::detail::script_extensions)
|
|
||||||
{
|
|
||||||
init = dir + "scripts/__load__" + ext;
|
|
||||||
|
|
||||||
if ( util::is_file(init) )
|
|
||||||
{
|
|
||||||
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
|
||||||
util::detail::warn_if_legacy_script(init);
|
|
||||||
scripts_to_load.push_back(init);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load shared libraries.
|
// Load shared libraries.
|
||||||
|
|
||||||
string dypattern = dir + "/lib/*." + HOST_ARCHITECTURE + DYNAMIC_PLUGIN_SUFFIX;
|
string dypattern = dir + "/lib/*." + HOST_ARCHITECTURE + DYNAMIC_PLUGIN_SUFFIX;
|
||||||
|
@ -288,6 +236,58 @@ bool Manager::ActivateDynamicPluginInternal(const std::string& name, bool ok_if_
|
||||||
DBG_LOG(DBG_PLUGINS, " No shared library found");
|
DBG_LOG(DBG_PLUGINS, " No shared library found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the "scripts" and "bif" directories to ZEEKPATH.
|
||||||
|
std::string scripts = dir + "scripts";
|
||||||
|
|
||||||
|
if ( util::is_dir(scripts) )
|
||||||
|
{
|
||||||
|
DBG_LOG(DBG_PLUGINS, " Adding %s to ZEEKPATH", scripts.c_str());
|
||||||
|
util::detail::add_to_zeek_path(scripts);
|
||||||
|
}
|
||||||
|
|
||||||
|
string init;
|
||||||
|
|
||||||
|
// First load {scripts}/__preload__.zeek automatically.
|
||||||
|
for (const string& ext : util::detail::script_extensions)
|
||||||
|
{
|
||||||
|
init = dir + "scripts/__preload__" + ext;
|
||||||
|
|
||||||
|
if ( util::is_file(init) )
|
||||||
|
{
|
||||||
|
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
||||||
|
util::detail::warn_if_legacy_script(init);
|
||||||
|
scripts_to_load.push_back(init);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load {bif,scripts}/__load__.zeek automatically.
|
||||||
|
for (const string& ext : util::detail::script_extensions)
|
||||||
|
{
|
||||||
|
init = dir + "lib/bif/__load__" + ext;
|
||||||
|
|
||||||
|
if ( util::is_file(init) )
|
||||||
|
{
|
||||||
|
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
||||||
|
util::detail::warn_if_legacy_script(init);
|
||||||
|
scripts_to_load.push_back(init);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const string& ext : util::detail::script_extensions)
|
||||||
|
{
|
||||||
|
init = dir + "scripts/__load__" + ext;
|
||||||
|
|
||||||
|
if ( util::is_file(init) )
|
||||||
|
{
|
||||||
|
DBG_LOG(DBG_PLUGINS, " Loading %s", init.c_str());
|
||||||
|
util::detail::warn_if_legacy_script(init);
|
||||||
|
scripts_to_load.push_back(init);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Mark this plugin as activated by clearing the path.
|
// Mark this plugin as activated by clearing the path.
|
||||||
m->second.clear();
|
m->second.clear();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue