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