fix(userspace/falco): applies FALCO_INSTALL_CONF_FILE as the default config.

Signed-off-by: Andrea Bonanno <andrea@bonanno.cloud>
This commit is contained in:
Andrea Bonanno 2022-02-14 16:53:58 +01:00 committed by poiana
parent 83c527dd91
commit eedb794fd5
3 changed files with 14 additions and 3 deletions

View File

@ -58,6 +58,7 @@ if(CMAKE_BUILD_TYPE STREQUAL "debug")
else()
set(CMAKE_BUILD_TYPE "release")
set(KBUILD_FLAGS "${DRAIOS_FEATURE_FLAGS}")
add_definitions(-DBUILD_TYPE_RELEASE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

View File

@ -92,7 +92,11 @@ static void usage()
"Usage: falco [options]\n\n"
"Options:\n"
" -h, --help Print this page\n"
" -c Configuration file (default " FALCO_SOURCE_CONF_FILE ", " FALCO_INSTALL_CONF_FILE ")\n"
#ifdef BUILD_TYPE_RELEASE
" -c Configuration file (default " FALCO_INSTALL_CONF_FILE ")\n"
#else
" -c Configuration file (default " FALCO_SOURCE_CONF_FILE ", " FALCO_INSTALL_CONF_FILE ")\n"
#endif
" -A Monitor all events, including those with EF_DROP_SIMPLE_CONS flag.\n"
" -b, --print-base64 Print data buffers in base64.\n"
" This is useful for encoding binary data that needs to be used over media designed to.\n"
@ -873,12 +877,14 @@ int falco_init(int argc, char **argv)
}
else
{
#ifndef BULD_TYPE_RELEASE
conf_stream.open(FALCO_SOURCE_CONF_FILE);
if (conf_stream.is_open())
{
conf_filename = FALCO_SOURCE_CONF_FILE;
}
else
#endif
{
conf_stream.open(FALCO_INSTALL_CONF_FILE);
if (conf_stream.is_open())
@ -887,7 +893,11 @@ int falco_init(int argc, char **argv)
}
else
{
throw std::invalid_argument("You must create a config file at " FALCO_SOURCE_CONF_FILE ", " FALCO_INSTALL_CONF_FILE " or by passing -c\n");
#ifndef BUILD_TYPE_RELEASE
throw std::invalid_argument("You must create a config file at " FALCO_SOURCE_CONF_FILE ", " FALCO_INSTALL_CONF_FILE "or by passing -c\n");
#else
throw std::invalid_argument("You must create a config file at " FALCO_INSTALL_CONF_FILE " or by passing -c\n");
#endif
}
}
}

View File

@ -4,7 +4,7 @@ set -euo pipefail
SOURCE_DIR=$1
NEW_CHECKSUM=$(./falco --list -N | sha256sum | awk '{print $1}')
NEW_CHECKSUM=$(./falco -c ${SOURCE_DIR}/falco.yaml --list -N | sha256sum | awk '{print $1}')
CUR_CHECKSUM=$(grep FALCO_FIELDS_CHECKSUM "${SOURCE_DIR}/userspace/engine/falco_engine_version.h" | awk '{print $3}' | sed -e 's/"//g')
if [ "$NEW_CHECKSUM" != "$CUR_CHECKSUM" ]; then