dlandon / unassigned.devices

Unassigned Devices plugin for unRAID
Other
81 stars 39 forks source link

ini_parse failure causes php error on main page #58

Closed verrier closed 4 years ago

verrier commented 4 years ago

Root cause: Seems like a failure in ini_parse with certain values is causing the PHP error displayed below to appear on the main screen and no details for the drive to display.

Details image

Warning: syntax error, unexpected '=' in Unknown on line 30 in /usr/local/emhttp/plugins/unassigned.devices/include/lib.php on line 1455

Root Cause

Line 1455 of the affected file is: $state[$device] = parse_ini_string(timed_exec(5,"/sbin/udevadm info --query=property --path $(/sbin/udevadm info -q path -n $device 2>/dev/null) 2>/dev/null"));

If we break down each component, the affected device in my example is /dev/sdd... /sbin/udevadm info -q path -n /dev/sdd returns:

/devices/pci0000:00/0000:00:11.4/ata3/host3/target3:0:0/3:0:0:0/block/sdd

Taking the syspath, and putting it in the first half of the commands, results in: /sbin/udevadm info --query=property --path /devices/pci0000:00/0000:00:11.4/ata3/host3/target3:0:0/3:0:0:0/block/sdd

DEVLINKS=/dev/disk/by-id/ata-C300-CTFDDAC128MAG_00000000104502FF1C51 /dev/disk/by-id/wwn-0x500a075102ff1c51 DEVNAME=/dev/sdd DEVPATH=/devices/pci0000:00/0000:00:11.4/ata3/host3/target3:0:0/3:0:0:0/block/sdd DEVTYPE=disk ID_ATA=1 ID_ATA_DOWNLOAD_MICROCODE=1 ID_ATA_FEATURE_SET_APM=1 ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=254 ID_ATA_FEATURE_SET_APM_ENABLED=1 ID_ATA_FEATURE_SET_HPA=1 ID_ATA_FEATURE_SET_HPA_ENABLED=1 ID_ATA_FEATURE_SET_PM=1 ID_ATA_FEATURE_SET_PM_ENABLED=1 ID_ATA_FEATURE_SET_SECURITY=1 ID_ATA_FEATURE_SET_SECURITY_ENABLED=0 ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=2 ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=2 ID_ATA_FEATURE_SET_SECURITY_FROZEN=1 ID_ATA_FEATURE_SET_SMART=1 ID_ATA_FEATURE_SET_SMART_ENABLED=1 ID_ATA_ROTATION_RATE_RPM=0 ID_ATA_SATA=1 ID_ATA_SATA_SIGNAL_RATE_GEN1=1 ID_ATA_SATA_SIGNAL_RATE_GEN2=1 ID_ATA_WRITE_CACHE=1 ID_ATA_WRITE_CACHE_ENABLED=1 ID_BUS=ata ID_FS_TYPE=ddf_raid_member ID_FS_USAGE=raid ID_FS_UUID=MARVELL##_f$f$ ID_FS_UUID_ENC=MARVELL\x20\xab\x11#\x91\xab\x11#\x91\xd4\x05f\x24\xab\x05f\x24 ID_FS_VERSION=01.02.00 ID_MODEL=C300-CTFDDAC128MAG ID_MODEL_ENC=C300-CTFDDAC128MAG\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20 ID_REVISION=0002 ID_SERIAL=C300-CTFDDAC128MAG_00000000104502FF1C51 ID_SERIAL_SHORT=00000000104502FF1C51 ID_TYPE=disk ID_WWN=0x500a075102ff1c51 ID_WWN_WITH_EXTENSION=0x500a075102ff1c51 MAJOR=8 MINOR=48 SUBSYSTEM=block USEC_INITIALIZED=45465856

Line 30 of the parsed ini file is: ID_FS_UUID=MARVELL___#___#___f$__f$ ... which I assume at this point the $ in the result is throwing parse_ini for a loop since it's not escaped.

Related Issues: This appears to be the root cause of #36

dlandon commented 4 years ago

I've just issued an update to UD that should solve this issue. Update and let me know if it solves the problem,

verrier commented 4 years ago

Awesome, yes, confirmed fixed :) Thank you for the fast turn around on this!

image

dlandon commented 4 years ago

Glad it's solved for you. Php string handling can be a real challenge at times.