intel / ledmon

Enclosure LED Utilities
GNU General Public License v2.0
72 stars 44 forks source link

Regex should be compiled during conf file parsing #172

Closed mtkaczyk closed 6 months ago

mtkaczyk commented 10 months ago

The regcomp implemented in match_string should be moved to conffile_parse It is bug prone to resolve regex so late, it produce a lot of error messages and doesn't break application from working (which should be expected). see: https://github.com/intel/ledmon/pull/170#discussion_r1313084267

ktanska commented 7 months ago

Regexes are being used only to parse controller lists (ALLOWLIST, EXCLUDELIST) from config. When user puts precise path to controller there, regex is not compiled, but controller path from list is simply compared to controller path found by Ledmon with strcmp and then controller is added or removed from list (if it is allowed or excluded). Regex enables to have more than precise path. When path to drive was given, also controller was found and action was performed. This may lead to have unexpected behaviors and user may not be aware of it. Regex is not needed here, the new PR related to this issue will remove it and keep only strncmp to compare path given by user with the path from controller list found by ledmon. Strcmp will be extended to strncmp, which will enable to exclude or allow all controllers by once. Also manual will be updated.