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

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