mirror of
https://github.com/unraid/webgui.git
synced 2025-12-30 14:09:53 -06:00
Merge pull request #2281 from unraid/fix-parse-plugin-cfg
fix: parse_plugin_cfg(): better handling of corrupt ini files
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 = "") {
|
||||
|
||||
Reference in New Issue
Block a user