Blame SOURCES/0015-Fix-possible-UnicodeDecodeError-when-reading-model-f.patch

f01d01
From 866a48e6c3d8246d2897bb402a191df5f2848aa4 Mon Sep 17 00:00:00 2001
f01d01
From: Vojtech Trefny <vtrefny@redhat.com>
f01d01
Date: Tue, 23 Jun 2020 10:33:33 +0200
f01d01
Subject: [PATCH] Fix possible UnicodeDecodeError when reading model from sysfs
f01d01
f01d01
Some Innovation IT NVMe devices have an (invalid) unicode in their
f01d01
model name.
f01d01
f01d01
Resolves: rhbz#1849326
f01d01
---
f01d01
 blivet/udev.py | 5 +++--
f01d01
 1 file changed, 3 insertions(+), 2 deletions(-)
f01d01
f01d01
diff --git a/blivet/udev.py b/blivet/udev.py
f01d01
index 41c99496..2c795225 100644
f01d01
--- a/blivet/udev.py
f01d01
+++ b/blivet/udev.py
f01d01
@@ -185,8 +185,9 @@ def __is_blacklisted_blockdev(dev_name):
f01d01
         if any(re.search(expr, dev_name) for expr in device_name_blacklist):
f01d01
             return True
f01d01
 
f01d01
-    if os.path.exists("/sys/class/block/%s/device/model" % (dev_name,)):
f01d01
-        model = open("/sys/class/block/%s/device/model" % (dev_name,)).read()
f01d01
+    model_path = "/sys/class/block/%s/device/model" % dev_name
f01d01
+    if os.path.exists(model_path):
f01d01
+        model = open(model_path, encoding="utf-8", errors="replace").read()
f01d01
         for bad in ("IBM *STMF KERNEL", "SCEI Flash-5", "DGC LUNZ"):
f01d01
             if model.find(bad) != -1:
f01d01
                 log.info("ignoring %s with model %s", dev_name, model)
f01d01
-- 
f01d01
2.26.2
f01d01