From 7ea337e8cdaa328ceed6774e2e690e953f20f6e5 Mon Sep 17 00:00:00 2001 From: ljm42 Date: Fri, 27 Jun 2025 15:37:59 -0700 Subject: [PATCH 1/2] fix: parse_plugin_cfg(): better handling of corrupt ini files --- emhttp/plugins/dynamix/include/Wrappers.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Wrappers.php b/emhttp/plugins/dynamix/include/Wrappers.php index b430ee17f..8d446563b 100644 --- a/emhttp/plugins/dynamix/include/Wrappers.php +++ b/emhttp/plugins/dynamix/include/Wrappers.php @@ -52,8 +52,24 @@ function parse_plugin_cfg($plugin, $sections=false, $scanner=INI_SCANNER_NORMAL) global $docroot; $ram = "$docroot/plugins/$plugin/default.cfg"; $rom = "/boot/config/plugins/$plugin/$plugin.cfg"; - $cfg = file_exists($ram) ? my_parse_ini_file($ram, $sections, $scanner) : []; - return file_exists($rom) ? array_replace_recursive($cfg, my_parse_ini_file($rom, $sections, $scanner)) : $cfg; + + $cfg_ram = []; + if (file_exists($ram)) { + $cfg_ram = my_parse_ini_file($ram, $sections, $scanner); + if ($cfg_ram === false) { + my_logger("Failed to parse config file: $ram", 'webgui'); + $cfg_ram = []; + } + } + $cfg_rom = []; + if (file_exists($rom)) { + $cfg_rom = my_parse_ini_file($rom, $sections, $scanner); + if ($cfg_rom === false) { + my_logger("Failed to parse config file: $rom", 'webgui'); + $cfg_rom = []; + } + } + return !empty($cfg_rom) ? array_replace_recursive($cfg_ram, $cfg_rom) : $cfg_ram; } function parse_cron_cfg($plugin, $job, $text = "") { From f1c5cbe70337d481f5fdc05c2c74a580eeaffe3b Mon Sep 17 00:00:00 2001 From: ljm42 Date: Fri, 27 Jun 2025 17:01:37 -0700 Subject: [PATCH 2/2] feat: show banner if dynamix.cfg is corrupt --- emhttp/plugins/dynamix/include/Report.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Report.php b/emhttp/plugins/dynamix/include/Report.php index a294f59ac..867a547ea 100644 --- a/emhttp/plugins/dynamix/include/Report.php +++ b/emhttp/plugins/dynamix/include/Report.php @@ -18,11 +18,12 @@ require_once "$docroot/webGui/include/Wrappers.php"; switch ($_POST['cmd']??'') { case 'config': $config = "/boot/config"; - $files = ['disk:0','docker:1','domain:1','flash:0','ident:1','share:0']; // config files to check + $files = ['disk:0:0','docker:1:0','domain:1:0','flash:0:0','ident:1:0','share:0:0','dynamix:0:1']; // config files to check foreach ($files as $file) { - [$name,$need] = explode(':',$file); + [$name,$need,$plugin] = explode(':',$file); + $filename = $plugin ? "$config/plugins/$name/$name.cfg" : "$config/$name.cfg"; for ( $i=0;$i<2;$i++) { - if (($need && !file_exists("$config/$name.cfg")) || (file_exists("$config/$name.cfg") && !@parse_ini_file("$config/$name.cfg"))) { + if (($need && !file_exists($filename)) || (file_exists($filename) && !@parse_ini_file($filename))) { $flag = 1; sleep(1); } else {