eclipse-bluechi / bluechi

Eclipse BlueChi is a systemd service controller intended for multi-node environments with a predefined number of nodes and with a focus on highly regulated ecosystems such as those requiring functional safety.
https://bluechi.readthedocs.io/en/latest/
GNU Lesser General Public License v2.1
130 stars 37 forks source link

Parse config does not check for .conf suffix #892

Closed engelmi closed 4 months ago

engelmi commented 4 months ago

Describe the bug

Based on our documentation:

Each configuration file should end with .conf suffix, otherwise it's ignored.

However, we only check if .conf is in the file name, not that it ends with it: https://github.com/eclipse-bluechi/bluechi/blob/main/src/libbluechi/common/cfg.c#L234-L239

To Reproduce

Creating two configuration files in /etc/bluechi/controller.conf.d/:

With different settings, e.g. having port 8420 in the first and 8421 in the second.

Starting bluechi-controller.

The same approach can be used with the bluechi-agent - it results in the same behavior.

The option from the second configuration (ctrl.conf.backup) is used even though its name doesn't end with .conf.

Expected behavior

ctrl.conf.backup is ignored and the option from ctrl.conf is used.