File 0001-Update-external-ec2-to-support-IMDSv2.patch of Package cluster-glue.28029

From c65bac71c356d8631987d22368f6176e92413915 Mon Sep 17 00:00:00 2001
From: adam kaminski <thimslugga@users.noreply.github.com>
Date: Thu, 25 Nov 2021 00:22:29 -0500
Subject: [PATCH 1/1] Update external/ec2 to support IMDSv2

Retrieve session token to support IMDSv2
---
 lib/plugins/stonith/external/ec2 | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/plugins/stonith/external/ec2 b/lib/plugins/stonith/external/ec2
index aceda846..19d54d01 100755
--- a/lib/plugins/stonith/external/ec2
+++ b/lib/plugins/stonith/external/ec2
@@ -181,11 +181,15 @@ EOF
 
 function is_instance_running()
 {
+	local token
 	local myinstance
 	local mystatus
+	
+	# get session token, required for IMDSv2
+	token="$(curl -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" -X PUT http://169.254.169.254/latest/api/token)"
 
 	# get my instance id
-	myinstance="$(curl http://169.254.169.254/latest/meta-data/instance-id)"
+	myinstance="$(curl -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/instance-id)"
 
 	# check my status.
 	# When the EC2 instance be stopped by the "aws ec2 stop-instances" , the stop processing of the OS is executed.
-- 
2.34.1

openSUSE Build Service is sponsored by