Skip to content

Commit

Permalink
fix(config): Error out when no config file supplied
Browse files Browse the repository at this point in the history
Fixes: #1406

Signed-off-by: Spencer Krum <[email protected]>
  • Loading branch information
nibalizer committed Nov 30, 2020
1 parent 3b78cda commit 8ba7377
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
12 changes: 1 addition & 11 deletions userspace/falco/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ falco_configuration::~falco_configuration()
}
}

// If we don't have a configuration file, we just use stdout output and all other defaults
void falco_configuration::init(list<string> &cmdline_options)
{
init_cmdline_options(cmdline_options);

falco::outputs::config stdout_output;
stdout_output.name = "stdout";
m_outputs.push_back(stdout_output);
}

void falco_configuration::init(string conf_filename, list<string> &cmdline_options)
{
string m_config_file = conf_filename;
Expand Down Expand Up @@ -346,4 +336,4 @@ void falco_configuration::set_cmdline_option(const string &opt)
{
m_config->set_scalar(keyval.first, keyval.second);
}
}
}
9 changes: 2 additions & 7 deletions userspace/falco/falco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ int falco_init(int argc, char **argv)
}
else
{
conf_filename = "";
throw std::invalid_argument("You must create a config file at " FALCO_SOURCE_CONF_FILE ", " FALCO_INSTALL_CONF_FILE " or by passing -c\n");
}
}
}
Expand Down Expand Up @@ -836,12 +836,7 @@ int falco_init(int argc, char **argv)
}
else
{
config.init(cmdline_options);
falco_logger::set_time_format_iso_8601(config.m_time_format_iso_8601);

// log after config init because config determines where logs go
falco_logger::log(LOG_INFO, "Falco version " + std::string(FALCO_VERSION) + " (driver version " + std::string(DRIVER_VERSION) + ")\n");
falco_logger::log(LOG_INFO, "Falco initialized. No configuration file found, proceeding with defaults\n");
throw std::runtime_error("Could not find configuration file at " + conf_filename);
}

if (rules_filenames.size())
Expand Down

0 comments on commit 8ba7377

Please sign in to comment.