From 3d53f901d23c9cc44b1dee0ca68f4763e31f9a2d Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Wed, 28 Apr 2021 01:27:57 +0200 Subject: [PATCH] PluginManager: Do not load built-in plugins via dlopen/dlsym fixes #351 --- fairmq/PluginManager.cxx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fairmq/PluginManager.cxx b/fairmq/PluginManager.cxx index 39c817c1..77268bed 100644 --- a/fairmq/PluginManager.cxx +++ b/fairmq/PluginManager.cxx @@ -200,7 +200,19 @@ auto fair::mq::PluginManager::LoadPluginStatic(const string& pluginName) -> void // Load symbol if (fPluginFactories.find(pluginName) == fPluginFactories.end()) { try { - LoadSymbols(pluginName, dll::program_location()); + if ("control" == pluginName) { + try { + fPluginProgOptions.insert({pluginName, plugins::ControlPluginProgramOptions().value()}); + } + catch (const boost::bad_optional_access& e) { /* just ignore, if no prog options are declared */ } + } else if ("config" == pluginName) { + try { + fPluginProgOptions.insert({pluginName, plugins::ConfigPluginProgramOptions().value()}); + } + catch (const boost::bad_optional_access& e) { /* just ignore, if no prog options are declared */ } + } else { + LoadSymbols(pluginName, dll::program_location()); + } fPluginOrder.push_back(pluginName); } catch (boost::system::system_error& e) { throw PluginLoadError(ToString("An error occurred while loading static plugin ", pluginName, ": ", e.what())); @@ -211,7 +223,13 @@ auto fair::mq::PluginManager::LoadPluginStatic(const string& pluginName) -> void auto fair::mq::PluginManager::InstantiatePlugin(const string& pluginName) -> void { if (fPlugins.find(pluginName) == fPlugins.end()) { - fPlugins[pluginName] = fPluginFactories[pluginName](*fPluginServices); + if ("control" == pluginName) { + fPlugins[pluginName] = plugins::Make_control_Plugin(fPluginServices.get()); + } else if ("config" == pluginName) { + fPlugins[pluginName] = plugins::Make_config_Plugin(fPluginServices.get()); + } else { + fPlugins[pluginName] = fPluginFactories[pluginName](*fPluginServices); + } } }