From a05e9738f8849bd179400aae833f28e07f998b46 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Feb 16 2021 18:10:51 +0000 Subject: import python-blivet-3.2.2-8.el8 --- diff --git a/SOURCES/0017-Let-parted-fix-fixable-issues-with-partition-table.patch b/SOURCES/0017-Let-parted-fix-fixable-issues-with-partition-table.patch new file mode 100644 index 0000000..af2c4d8 --- /dev/null +++ b/SOURCES/0017-Let-parted-fix-fixable-issues-with-partition-table.patch @@ -0,0 +1,30 @@ +From d477f8d076789cbe1c0a85545ea8b5133fdc4bdf Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 18 Sep 2020 13:58:48 +0200 +Subject: [PATCH] Let parted fix fixable issues with partition table + +This will automatically fix issues like GPT partition table not +covering whole device after disk size change. + +Resolves: rhbz#1846869 +--- + blivet/populator/populator.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/blivet/populator/populator.py b/blivet/populator/populator.py +index 465c272d..fe566816 100644 +--- a/blivet/populator/populator.py ++++ b/blivet/populator/populator.py +@@ -64,6 +64,9 @@ def parted_exn_handler(exn_type, exn_options, exn_msg): + if exn_type == parted.EXCEPTION_TYPE_ERROR and \ + exn_options == parted.EXCEPTION_OPT_YES_NO: + ret = parted.EXCEPTION_RESOLVE_YES ++ elif exn_type == parted.EXCEPTION_TYPE_WARNING and \ ++ exn_options & parted.EXCEPTION_RESOLVE_FIX: ++ ret = parted.EXCEPTION_RESOLVE_FIX + return ret + + +-- +2.29.2 + diff --git a/SOURCES/0018-Fix-possible-UnicodeDecodeError-when-reading-sysfs-a.patch b/SOURCES/0018-Fix-possible-UnicodeDecodeError-when-reading-sysfs-a.patch new file mode 100644 index 0000000..11b6a40 --- /dev/null +++ b/SOURCES/0018-Fix-possible-UnicodeDecodeError-when-reading-sysfs-a.patch @@ -0,0 +1,112 @@ +From 430cd2cdba8fba434b5bed2d2a7ed97803c62f6d Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 5 Jan 2021 16:56:52 +0100 +Subject: [PATCH 1/3] Fix possible UnicodeDecodeError when reading sysfs + attributes + +This is a follow-up for https://github.com/storaged-project/blivet/pull/861 +where we fixed reading device model in "__is_blacklisted_blockdev" +but we read the device model from other places too so it makes +more sense to "fix" all sysfs attribute reads. +--- + blivet/util.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/blivet/util.py b/blivet/util.py +index 2fa9c8fc..48b7818f 100644 +--- a/blivet/util.py ++++ b/blivet/util.py +@@ -379,7 +379,7 @@ def get_sysfs_attr(path, attr, root=None): + log.warning("%s is not a valid attribute", attr) + return None + +- f = open(fullattr, "r") ++ f = open(fullattr, "r", encoding="utf-8", errors="replace") + data = f.read() + f.close() + sdata = "".join(["%02x" % (ord(x),) for x in data]) +-- +2.29.2 + + +From 15350b52f30910d4fadad92da0195710adcb69a0 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Tue, 5 Jan 2021 16:59:14 +0100 +Subject: [PATCH 2/3] Use util.get_sysfs_attr in __is_ignored_blockdev to read + device mode + +--- + blivet/udev.py | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/blivet/udev.py b/blivet/udev.py +index 2c795225..25375459 100644 +--- a/blivet/udev.py ++++ b/blivet/udev.py +@@ -185,9 +185,8 @@ def __is_blacklisted_blockdev(dev_name): + if any(re.search(expr, dev_name) for expr in device_name_blacklist): + return True + +- model_path = "/sys/class/block/%s/device/model" % dev_name +- if os.path.exists(model_path): +- model = open(model_path, encoding="utf-8", errors="replace").read() ++ model = util.get_sysfs_attr("/sys/class/block/%s" % dev_name, "device/model") ++ if model: + for bad in ("IBM *STMF KERNEL", "SCEI Flash-5", "DGC LUNZ"): + if model.find(bad) != -1: + log.info("ignoring %s with model %s", dev_name, model) +-- +2.29.2 + + +From 64ece8c0dafb550bbde4798a766515fb04f44568 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Wed, 6 Jan 2021 12:34:49 +0100 +Subject: [PATCH 3/3] Add test for util.get_sysfs_attr + +--- + tests/util_test.py | 23 +++++++++++++++++++++++ + 1 file changed, 23 insertions(+) + +diff --git a/tests/util_test.py b/tests/util_test.py +index 9a2ff492..853b6166 100644 +--- a/tests/util_test.py ++++ b/tests/util_test.py +@@ -2,7 +2,9 @@ + import test_compat + + from six.moves import mock ++import os + import six ++import tempfile + import unittest + from decimal import Decimal + +@@ -157,3 +159,24 @@ class DependencyGuardTestCase(unittest.TestCase): + with mock.patch.object(_requires_something, '_check_avail', return_value=True): + self.assertEqual(self._test_dependency_guard_non_critical(), True) + self.assertEqual(self._test_dependency_guard_critical(), True) ++ ++ ++class GetSysfsAttrTestCase(unittest.TestCase): ++ ++ def test_get_sysfs_attr(self): ++ ++ with tempfile.TemporaryDirectory() as sysfs: ++ model_file = os.path.join(sysfs, "model") ++ with open(model_file, "w") as f: ++ f.write("test model\n") ++ ++ model = util.get_sysfs_attr(sysfs, "model") ++ self.assertEqual(model, "test model") ++ ++ # now with some invalid byte in the model ++ with open(model_file, "wb") as f: ++ f.write(b"test model\xef\n") ++ ++ # the unicode replacement character (U+FFFD) should be used instead ++ model = util.get_sysfs_attr(sysfs, "model") ++ self.assertEqual(model, "test model\ufffd") +-- +2.29.2 + diff --git a/SPECS/python-blivet.spec b/SPECS/python-blivet.spec index 44bca8a..dd28979 100644 --- a/SPECS/python-blivet.spec +++ b/SPECS/python-blivet.spec @@ -23,7 +23,7 @@ Version: 3.2.2 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 7%{?prerelease}%{?dist} +Release: 8%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ Group: System Environment/Libraries @@ -47,6 +47,8 @@ Patch12: 0013-Do-not-limit-swap-to-128-GiB.patch Patch13: 0014-Use-UnusableConfigurationError-for-patially-hidden-multipath-devices.patch Patch14: 0015-Fix-possible-UnicodeDecodeError-when-reading-model-f.patch Patch15: 0016-Basic-LVM-VDO-support.patch +Patch16: 0017-Let-parted-fix-fixable-issues-with-partition-table.patch +Patch17: 0018-Fix-possible-UnicodeDecodeError-when-reading-sysfs-a.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -208,6 +210,12 @@ configuration. %endif %changelog +* Mon Jan 11 2021 Vojtech Trefny - 3.2.2-8 +- Let parted fix fixable issues with partition table + Resolves: rhbz#1846869 +- Fix possible UnicodeDecodeError when reading sysfs attributes + Resolves: rhbz#1849326 + * Wed Nov 18 2020 Vojtech Trefny - 3.2.2-7 - Add support for XFS format grow Resolves: rhbz#1862349