Blame SOURCES/bz1455383-fence_scsi-FIPS-support.patch

4822a5
From 81b8370844f5aecaee5e7178d82670c70399d824 Mon Sep 17 00:00:00 2001
4822a5
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
4822a5
Date: Mon, 24 Jul 2017 16:12:15 +0200
4822a5
Subject: [PATCH] fence_scsi: add FIPS support
4822a5
4822a5
---
4822a5
 fence/agents/scsi/fence_scsi.py | 11 ++++++++++-
4822a5
 1 file changed, 10 insertions(+), 1 deletion(-)
4822a5
4822a5
diff --git a/fence/agents/scsi/fence_scsi.py b/fence/agents/scsi/fence_scsi.py
4822a5
index 37ff1d38..3ebe6513 100644
4822a5
--- a/fence/agents/scsi/fence_scsi.py
4822a5
+++ b/fence/agents/scsi/fence_scsi.py
4822a5
@@ -182,7 +182,16 @@ def get_cluster_id(options):
4822a5
 	cmd = options["--corosync-cmap-path"] + " totem.cluster_name"
4822a5
 
4822a5
 	match = re.search(r"\(str\) = (\S+)\n", run_cmd(options, cmd)["out"])
4822a5
-	return hashlib.md5(match.group(1)).hexdigest() if match else fail_usage("Failed: cannot get cluster name")
4822a5
+
4822a5
+	if not match:
4822a5
+		fail_usage("Failed: cannot get cluster name")
4822a5
+
4822a5
+	try:
4822a5
+		return hashlib.md5(match.group(1)).hexdigest()
4822a5
+	except ValueError:
4822a5
+		# FIPS requires usedforsecurity=False and might not be
4822a5
+		# available on all distros: https://bugs.python.org/issue9216
4822a5
+		return hashlib.md5(match.group(1), usedforsecurity=False).hexdigest()
4822a5
 
4822a5
 
4822a5
 def get_node_id(options):