Blame SOURCES/0058-devices-file-fix-pvcreate-uuid-matching-pvid-entry-w.patch

f358f0
From 87904fbbb84c10e6f733db1c5ba447537d1cf08c Mon Sep 17 00:00:00 2001
f358f0
From: David Teigland <teigland@redhat.com>
f358f0
Date: Fri, 19 Aug 2022 13:31:22 -0500
f358f0
Subject: [PATCH 1/6] devices file: fix pvcreate --uuid matching pvid entry
f358f0
 with no device id
f358f0
f358f0
pvcreate with --uuid would segfault if a devices file entry matched
f358f0
the specified pvid, but the devices file entry had no device_id, which
f358f0
could happen if the entry has a devname idtype.
f358f0
---
f358f0
 lib/device/device_id.c            |  7 ++++---
f358f0
 test/shell/devicesfile-devname.sh | 13 +++++++++++++
f358f0
 2 files changed, 17 insertions(+), 3 deletions(-)
f358f0
f358f0
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
f358f0
index 4d8fa5c9c..c3816a66c 100644
f358f0
--- a/lib/device/device_id.c
f358f0
+++ b/lib/device/device_id.c
f358f0
@@ -1142,8 +1142,9 @@ id_done:
f358f0
 			  du_devname->devname);
f358f0
 
f358f0
 	if (du_pvid && (du_pvid->dev != dev))
f358f0
-		log_warn("WARNING: adding device %s with PVID %s which is already used for %s.",
f358f0
-			 dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device");
f358f0
+		log_warn("WARNING: adding device %s with PVID %s which is already used for %s device_id %s.",
f358f0
+			 dev_name(dev), pvid, du_pvid->dev ? dev_name(du_pvid->dev) : "missing device",
f358f0
+			 du_pvid->idname ?: "none");
f358f0
 
f358f0
 	if (du_devid && (du_devid->dev != dev)) {
f358f0
 		if (!du_devid->dev) {
f358f0
@@ -1189,7 +1190,7 @@ id_done:
f358f0
 		else
f358f0
 			check_idname = device_id_system_read(cmd, dev, du_pvid->idtype);
f358f0
 
f358f0
-		if (check_idname && !strcmp(check_idname, du_pvid->idname)) {
f358f0
+		if (!du_pvid->idname || (check_idname && !strcmp(check_idname, du_pvid->idname))) {
f358f0
 			update_du = du_pvid;
f358f0
 			dm_list_del(&update_du->list);
f358f0
 			update_matching_kind = "PVID";
f358f0
diff --git a/test/shell/devicesfile-devname.sh b/test/shell/devicesfile-devname.sh
f358f0
index 338637275..211f4dbed 100644
f358f0
--- a/test/shell/devicesfile-devname.sh
f358f0
+++ b/test/shell/devicesfile-devname.sh
f358f0
@@ -550,6 +550,19 @@ vgchange -an $vg2
f358f0
 vgremove -ff $vg1
f358f0
 vgremove -ff $vg2
f358f0
 
f358f0
+# bz 2119473
f358f0
+
f358f0
+aux lvmconf "devices/search_for_devnames = \"none\""
f358f0
+sed -e "s|DEVNAME=$dev1|DEVNAME=.|" "$ORIG" > tmp1.devices
f358f0
+sed -e "s|IDNAME=$dev1|IDNAME=.|" tmp1.devices > "$DF"
f358f0
+pvs
f358f0
+lvmdevices
f358f0
+pvcreate -ff --yes --uuid "$PVID1" --norestorefile $dev1
f358f0
+grep "$PVID1" "$DF" |tee out
f358f0
+grep "DEVNAME=$dev1" out
f358f0
+grep "IDNAME=$dev1" out
f358f0
+aux lvmconf "devices/search_for_devnames = \"auto\""
f358f0
+
f358f0
 # devnames change so the new devname now refers to a filtered device,
f358f0
 # e.g. an mpath or md component, which is not scanned
f358f0
 
f358f0
-- 
f358f0
2.38.1
f358f0