- fence_scsi: fix Python 3 encoding issue

This commit is contained in:
Oyvind Albrigtsen 2018-05-25 10:10:20 +02:00
parent dc9fe5dfe9
commit 40d0720d08
2 changed files with 38 additions and 1 deletions

View File

@ -16,11 +16,12 @@
Name: fence-agents
Summary: Fence Agents for Red Hat Cluster
Version: 4.2.0
Release: 1%{?alphatag:.%{alphatag}}%{?dist}
Release: 2%{?alphatag:.%{alphatag}}%{?dist}
License: GPLv2+ and LGPLv2+
Group: System Environment/Base
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.xz
Patch0: fence_scsi-fix-python3-encoding-error.patch
%if 0%{?fedora} || 0%{?rhel} > 7
%global testagents zvm virsh raritan rcd_serial
@ -882,6 +883,9 @@ The fence-agents-zvm package contains a fence agent for IBM z/VM over IP.
%{_mandir}/man8/fence_zvmip.8*
%changelog
* Fri May 25 2018 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.2.0-2
- fence_scsi: fix Python 3 encoding issue
* Thu May 17 2018 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.2.0-1
- new upstream release

View File

@ -0,0 +1,33 @@
From 335aca4e54e4ec46b9b5d86ef30a7d9348e6a216 Mon Sep 17 00:00:00 2001
From: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Date: Wed, 23 May 2018 14:51:23 +0200
Subject: [PATCH] fence_scsi: fix python3 encoding error #206
File "/usr/sbin/fence_scsi", line 184, in get_cluster_id
return hashlib.md5(match.group(1)).hexdigest()
TypeError: Unicode-objects must be encoded before hashing
---
agents/scsi/fence_scsi.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/agents/scsi/fence_scsi.py b/agents/scsi/fence_scsi.py
index 119dbb85..2180d0c9 100644
--- a/agents/scsi/fence_scsi.py
+++ b/agents/scsi/fence_scsi.py
@@ -181,11 +181,11 @@ def get_cluster_id(options):
fail_usage("Failed: cannot get cluster name")
try:
- return hashlib.md5(match.group(1)).hexdigest()
+ return hashlib.md5(match.group(1).encode('ascii')).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()
+ return hashlib.md5(match.group(1).encode('ascii'), usedforsecurity=False).hexdigest()
def get_node_id(options):
--
2.17.0