From 4aefb7fd7dda479714868829488ba5e097d911c0 Mon Sep 17 00:00:00 2001 From: Jason Dellaluce Date: Thu, 12 Jan 2023 13:15:06 +0000 Subject: [PATCH] fix(userspace/falco): require config file only when needed Signed-off-by: Jason Dellaluce --- userspace/falco/app_actions/load_config.cpp | 15 ++++++++++----- userspace/falco/application.cpp | 1 + userspace/falco/application.h | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/userspace/falco/app_actions/load_config.cpp b/userspace/falco/app_actions/load_config.cpp index 0982e8cb..cc8bf975 100644 --- a/userspace/falco/app_actions/load_config.cpp +++ b/userspace/falco/app_actions/load_config.cpp @@ -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(); -} +} \ No newline at end of file diff --git a/userspace/falco/application.cpp b/userspace/falco/application.cpp index 9db02d27..f1c4cec0 100644 --- a/userspace/falco/application.cpp +++ b/userspace/falco/application.cpp @@ -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), diff --git a/userspace/falco/application.h b/userspace/falco/application.h index bfbe9b45..32938594 100644 --- a/userspace/falco/application.h +++ b/userspace/falco/application.h @@ -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();