- fence_ibm_vpc: refresh bearer-token if token data is corrupt, and

avoid edge-case of writing empty token file
  Resolves: RHEL-83255
This commit is contained in:
Oyvind Albrigtsen 2025-03-14 09:27:46 +01:00
parent f2befcfc92
commit d53dbdb147
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 293b3961149f680ead9028e6719c405957abc6b7 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Thu, 13 Mar 2025 16:40:30 +0100
Subject: [PATCH] fence_ibm_vpc: refresh bearer-token in connect() if token
data is corrupt, and avoid edge-case of writing empty token file
---
agents/ibm_vpc/fence_ibm_vpc.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/agents/ibm_vpc/fence_ibm_vpc.py b/agents/ibm_vpc/fence_ibm_vpc.py
index 035a3235a..efda5eed7 100755
--- a/agents/ibm_vpc/fence_ibm_vpc.py
+++ b/agents/ibm_vpc/fence_ibm_vpc.py
@@ -105,6 +105,8 @@ def get_bearer_token(conn, options):
except Exception as e:
logging.error("Failed: Unable to authenticate: {}".format(e))
fail(EC_LOGIN_DENIED)
+ if len(token) < 1:
+ fail(EC_LOGIN_DENIED)
file_obj.write(token)
finally:
os.umask(oldumask)
@@ -152,6 +154,14 @@ def connect(opt):
# set auth token for later requests
conn = set_bearer_token(conn, bearer_token)
+ try:
+ command = "instances?version=2021-05-25&generation=2&limit=1"
+ res = send_command(conn, opt, command)
+ except Exception as e:
+ logging.warning("Failed to login/connect. Updating bearer-token.")
+ bearer_token = get_bearer_token(conn, opt)
+ conn = set_bearer_token(conn, bearer_token)
+
return conn
def disconnect(conn):

View File

@ -57,7 +57,7 @@
Name: fence-agents
Summary: Set of unified programs capable of host isolation ("fencing")
Version: 4.10.0
Release: 86%{?alphatag:.%{alphatag}}%{?dist}
Release: 87%{?alphatag:.%{alphatag}}%{?dist}
License: GPLv2+ and LGPLv2+
URL: https://github.com/ClusterLabs/fence-agents
Source0: https://fedorahosted.org/releases/f/e/fence-agents/%{name}-%{version}.tar.gz
@ -245,6 +245,7 @@ Patch59: RHEL-56138-fence_mpath-1-support-hex-key-format.patch
Patch60: RHEL-56138-fence_mpath-2-fix-unfencing-issue-use-MULTILINE-avoid-duplicates.patch
Patch61: RHEL-62206-fence_ibm_powervs-add-private-endpoint-and-token-file-support.patch
Patch62: RHEL-76493-fence_azure_arm-use-azure-identity.patch
Patch63: RHEL-83255-fence_ibm_vpc-refresh-bearer-token.patch
### HA support libs/utils ###
# all archs
@ -428,6 +429,7 @@ BuildRequires: %{systemd_units}
%patch -p1 -P 60
%patch -p1 -P 61
%patch -p1 -P 62
%patch -p1 -P 63
# prevent compilation of something that won't get used anyway
sed -i.orig 's|FENCE_ZVM=1|FENCE_ZVM=0|' configure.ac
@ -1534,6 +1536,11 @@ are located on corosync cluster nodes.
%endif
%changelog
* Fri Mar 14 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-87
- fence_ibm_vpc: refresh bearer-token if token data is corrupt, and
avoid edge-case of writing empty token file
Resolves: RHEL-83255
* Tue Mar 11 2025 Oyvind Albrigtsen <oalbrigt@redhat.com> - 4.10.0-86
- bundled jinja2: fix CVE-2025-27516
Resolves: RHEL-82713