File 0012-CTDB-fix-OCF_RESKEY_ctdb_recovery_lock-validation-bs.patch of Package resource-agents.11488

From 25fc6177a0d3b9b49c09efb6893f21128ba4f093 Mon Sep 17 00:00:00 2001
From: David Disseldorp <ddiss@suse.de>
Date: Wed, 25 Jul 2018 22:48:40 +0200
Subject: [PATCH] CTDB: fix OCF_RESKEY_ctdb_recovery_lock validation
 (bsc#1088692)

ctdb supports '!' prefix syntax to use a helper binary for recovery
lock functionality. This currently fails the reclock path existence
check.
Add helper binary support by stripping the '!' prefix and trailing
helper binary parameters before checking for existence.

Signed-off-by: David Disseldorp <ddiss@suse.de>

Cherry-picked from 2a7f004c.
---
 heartbeat/CTDB | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/heartbeat/CTDB b/heartbeat/CTDB
index 28e58cea..dc24ae0f 100755
--- a/heartbeat/CTDB
+++ b/heartbeat/CTDB
@@ -134,8 +134,8 @@ For more information see http://linux-ha.org/wiki/CTDB_(resource_agent)
 
 <parameter name="ctdb_recovery_lock" unique="1" required="1">
 <longdesc lang="en">
-The location of a shared lock file, common across all nodes.
-This must be on shared storage, e.g.: /shared-fs/samba/ctdb.lock
+The location of a shared lock file or helper binary, common across all nodes.
+See CTDB documentation for details.
 </longdesc>
 <shortdesc lang="en">CTDB shared lock file</shortdesc>
 <content type="string" default="" />
@@ -757,13 +757,24 @@ ctdb_validate() {
 		return $OCF_ERR_CONFIGURED
 	fi
 
-	lock_dir=$(dirname "$OCF_RESKEY_ctdb_recovery_lock")
-	touch "$lock_dir/$$" 2>/dev/null
-	if [ $? != 0 ]; then
-		ocf_exit_reason "Directory for lock file '$OCF_RESKEY_ctdb_recovery_lock' does not exist, or is not writable."
-		return $OCF_ERR_ARGS
+	if [ "${OCF_RESKEY_ctdb_recovery_lock:0:1}" == '!' ]; then
+		# '!' prefix means recovery lock is handled via a helper binary
+		binary="${OCF_RESKEY_ctdb_recovery_lock:1}"
+		binary="${binary%% *}"	# trim any parameters
+		if [ -z "$binary" ]; then
+			ocf_exit_reason "ctdb_recovery_lock invalid helper"
+			return $OCF_ERR_CONFIGURED
+		fi
+		check_binary "${binary}"
+	else
+		lock_dir=$(dirname "$OCF_RESKEY_ctdb_recovery_lock")
+		touch "$lock_dir/$$" 2>/dev/null
+		if [ $? != 0 ]; then
+			ocf_exit_reason "Directory for lock file '$OCF_RESKEY_ctdb_recovery_lock' does not exist, or is not writable."
+			return $OCF_ERR_ARGS
+		fi
+		rm "$lock_dir/$$"
 	fi
-	rm "$lock_dir/$$"
 
 	return $OCF_SUCCESS
 }
-- 
2.13.7

openSUSE Build Service is sponsored by