From 797b861fbc765d81233390b5f3bdac378dec004d Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Wed, 6 Oct 2021 09:42:27 -0700 Subject: [PATCH] Change config handling for load_plugins If the value is not specified at all, then all plugins are loaded. Otherwise, check against the list. This allows disabling all plugins via: --- load_plugins: [] --- Signed-off-by: Mark Stemm --- userspace/falco/configuration.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/userspace/falco/configuration.cpp b/userspace/falco/configuration.cpp index 454d296a..82fe0c3d 100644 --- a/userspace/falco/configuration.cpp +++ b/userspace/falco/configuration.cpp @@ -257,6 +257,10 @@ void falco_configuration::init(string conf_filename, list &cmdline_optio } std::set load_plugins; + + YAML::Node load_plugins_node; + m_config->get_node(load_plugins_node, "load_plugins"); + m_config->get_sequence>(load_plugins, "load_plugins"); std::list plugins; @@ -270,10 +274,13 @@ void falco_configuration::init(string conf_filename, list &cmdline_optio throw logic_error("Error reading config file(" + m_config_file + "): could not load plugins config: " + e.what()); } - // If load_plugins has values, only save plugins matching those in values + // If load_plugins was specified, only save plugins matching those in values for (auto &p : plugins) { - if(load_plugins.empty() || load_plugins.find(p.m_name) != load_plugins.end()) + // If load_plugins was not specified at all, every + // plugin is added. Otherwise, the plugin must be in + // the load_plugins list. + if(!load_plugins_node.IsDefined() || load_plugins.find(p.m_name) != load_plugins.end()) { m_plugins.push_back(p); }