fix(userspace/falco): require config file only when needed

Signed-off-by: Jason Dellaluce <jasondellaluce@gmail.com>
This commit is contained in:
Jason Dellaluce 2023-01-12 13:15:06 +00:00 committed by poiana
parent 149c95c3fb
commit 4aefb7fd7d
3 changed files with 12 additions and 5 deletions

View File

@ -33,7 +33,15 @@ application::run_result application::load_config()
}
falco_logger::log(LOG_INFO, "Falco initialized with configuration file: " + m_options.conf_filename + "\n");
}
else
m_state->config->m_buffered_outputs = !m_options.unbuffered_outputs;
return run_result::ok();
}
application::run_result application::require_config_file()
{
if (m_options.conf_filename.empty())
{
#ifndef BUILD_TYPE_RELEASE
return run_result::fatal(std::string("You must create a config file at ") + FALCO_SOURCE_CONF_FILE + ", " + FALCO_INSTALL_CONF_FILE + " or by passing -c");
@ -41,8 +49,5 @@ application::run_result application::load_config()
return run_result::fatal(std::string("You must create a config file at ") + FALCO_INSTALL_CONF_FILE + " or by passing -c");
#endif
}
m_state->config->m_buffered_outputs = !m_options.unbuffered_outputs;
return run_result::ok();
}
}

View File

@ -181,6 +181,7 @@ bool application::run(std::string &errstr, bool &restart)
std::bind(&application::print_generated_gvisor_config, this),
std::bind(&application::print_ignored_events, this),
std::bind(&application::print_syscall_events, this),
std::bind(&application::require_config_file, this),
std::bind(&application::print_plugin_info, this),
std::bind(&application::list_plugins, this),
std::bind(&application::load_plugins, this),

View File

@ -315,6 +315,7 @@ private:
run_result list_fields();
run_result list_plugins();
run_result load_config();
run_result require_config_file();
run_result load_plugins();
run_result load_rules_files();
run_result create_requested_paths();