From 5c559a8109c93cea393d4ed3e19727b54ebc88f6 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Fri, 17 Jan 2025 11:32:33 +0100 Subject: [PATCH] Protect against exceptions when getting properties from udev We've seen online UnicodeDecodeErrors from pyudev, but let's just catch all exceptions here and try to process the device anyway. Fixes: #490 --- blivet/udev.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/blivet/udev.py b/blivet/udev.py index 7c453df88..b7c906433 100644 --- a/blivet/udev.py +++ b/blivet/udev.py @@ -74,7 +74,12 @@ def device_to_dict(device): # Sice blivet uses Device.properties only (with couple of exceptions) # this is a functional workaround. (japokorn May 2017) - result = dict(device.properties) + result = dict() + for key in device.properties.keys(): + try: + result[key] = device.properties.get(key) + except Exception as e: # pylint: disable=broad-except + log.error("Failed to get %s property of %s: %s", key, device.sys_name, str(e)) result["SYS_NAME"] = device.sys_name result["SYS_PATH"] = device.sys_path return result