From 57abd97c766532ccdfffea07fce6b9fa8b5293e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christofer=20Gilje=20Skj=C3=A6veland?= Date: Wed, 26 Nov 2025 17:18:06 +0100 Subject: [PATCH 1/4] fix: Add extra check for etc path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christofer Gilje Skjæveland Signed-off-by: Kai-Uwe Hermann --- lib/runtime.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/runtime.cpp b/lib/runtime.cpp index 2a4d2013..b7e6bc06 100644 --- a/lib/runtime.cpp +++ b/lib/runtime.cpp @@ -116,11 +116,13 @@ void ManagerSettings::init_settings(const everest::config::Settings& settings) { fs::path etc_dir; { // etc directory - const auto default_etc_dir = fs::path(defaults::SYSCONF_DIR) / defaults::NAMESPACE; - if (prefix.string() != "/usr") { - etc_dir = prefix / default_etc_dir; - } else { + const auto default_etc_dir = (fs::path(defaults::SYSCONF_DIR) / defaults::NAMESPACE).relative_path(); + if (prefix.string() == "/usr") { etc_dir = fs::path("/") / default_etc_dir; + } else if (etc_root.filename() == "usr") { + etc_dir = prefix.parent_path() / default_etc_dir; + } else { + etc_dir = prefix / default_etc_dir; } etc_dir = assert_dir(etc_dir.string(), "Default etc directory"); } @@ -662,8 +664,7 @@ bool ModuleLoader::parse_command_line(int argc, char* argv[]) { if (vm.count("config") != 0) { std::cout - << "--config is not used anymore, modules request their config automatically via MQTT" - << "\n" + << "--config is not used anymore, modules request their config automatically via MQTT" << "\n" << "If you want to influence this config loading behavior you can specify the appropriate --mqtt_* flags" << "\n"; } From 2f82a7bc9a031665a7df606de47ac8b8b38d964e Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann Date: Tue, 2 Dec 2025 11:40:56 +0100 Subject: [PATCH 2/4] Fix typo, "etc_root" should be "prefix" Signed-off-by: Kai-Uwe Hermann --- lib/runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime.cpp b/lib/runtime.cpp index b7e6bc06..a58bea27 100644 --- a/lib/runtime.cpp +++ b/lib/runtime.cpp @@ -119,7 +119,7 @@ void ManagerSettings::init_settings(const everest::config::Settings& settings) { const auto default_etc_dir = (fs::path(defaults::SYSCONF_DIR) / defaults::NAMESPACE).relative_path(); if (prefix.string() == "/usr") { etc_dir = fs::path("/") / default_etc_dir; - } else if (etc_root.filename() == "usr") { + } else if (prefix.filename() == "usr") { etc_dir = prefix.parent_path() / default_etc_dir; } else { etc_dir = prefix / default_etc_dir; From ea909cb53091a95f090f29fab2793712db4d3f83 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann Date: Fri, 28 Nov 2025 16:59:46 +0100 Subject: [PATCH 3/4] Add testcase to check if etc dir is correctly set Signed-off-by: Kai-Uwe Hermann --- tests/CMakeLists.txt | 5 +++++ tests/test_config.cpp | 7 +++++++ .../test_configs/valid_config_custom_prefix_config.yaml | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 tests/test_configs/valid_config_custom_prefix_config.yaml diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e7e65610..6881067c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,6 +36,11 @@ include(test_utilities.cmake) setup_test_directory(empty_config) setup_test_directory(valid_config) +setup_test_directory(valid_config_custom_prefix) +file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix_tmp) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix) +file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix_tmp ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix/usr) +file(RENAME ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix/usr/etc ${CMAKE_CURRENT_BINARY_DIR}/valid_config_custom_prefix/etc) setup_test_directory(valid_module_config TESTValidManifest test_interface) setup_test_directory(valid_module_config_userconfig TESTValidManifest test_interface CONFIG valid_module_config_config.yaml diff --git a/tests/test_config.cpp b/tests/test_config.cpp index 9ebc23ac..5c1d7c0f 100644 --- a/tests/test_config.cpp +++ b/tests/test_config.cpp @@ -28,6 +28,13 @@ SCENARIO("Check ManagerSettings Constructor", "[!throws]") { CHECK_NOTHROW(Everest::ManagerSettings(bin_dir + "valid_config/", bin_dir + "valid_config/config.yaml")); } } + GIVEN("A valid prefix and a valid config file with a custom prefix") { + THEN("It should not throw") { + auto ms = Everest::ManagerSettings(bin_dir + "valid_config_custom_prefix/usr", + bin_dir + "valid_config_custom_prefix/usr/config.yaml"); + CHECK(ms.runtime_settings.etc_dir == bin_dir + "valid_config_custom_prefix/etc/everest"); + } + } GIVEN("A broken yaml file") { // FIXME (aw): this also throws, if the folder doesn't even exists or some other things fail THEN("It should throw") { diff --git a/tests/test_configs/valid_config_custom_prefix_config.yaml b/tests/test_configs/valid_config_custom_prefix_config.yaml new file mode 100644 index 00000000..97a28291 --- /dev/null +++ b/tests/test_configs/valid_config_custom_prefix_config.yaml @@ -0,0 +1,9 @@ +active_modules: {} +settings: + interfaces_dir: "interfaces" + modules_dir: "modules" + types_dir: "types" + errors_dir: "errors" + schemas_dir: "schemas" + www_dir: "www" + logging_config_file: "logging.ini" From 7fbb64a1f7831d58d6a02fde8b31964b68e92d11 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann Date: Tue, 2 Dec 2025 11:57:31 +0100 Subject: [PATCH 4/4] clang-format Signed-off-by: Kai-Uwe Hermann --- lib/runtime.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/runtime.cpp b/lib/runtime.cpp index a58bea27..75794299 100644 --- a/lib/runtime.cpp +++ b/lib/runtime.cpp @@ -664,7 +664,8 @@ bool ModuleLoader::parse_command_line(int argc, char* argv[]) { if (vm.count("config") != 0) { std::cout - << "--config is not used anymore, modules request their config automatically via MQTT" << "\n" + << "--config is not used anymore, modules request their config automatically via MQTT" + << "\n" << "If you want to influence this config loading behavior you can specify the appropriate --mqtt_* flags" << "\n"; }