Blame SOURCES/bz1820523-exportfs-1-add-symlink-support.patch

42b704
From 091a6d1f26140651b7314cfb618c80f9258fd1d4 Mon Sep 17 00:00:00 2001
42b704
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
42b704
Date: Tue, 5 May 2020 14:20:43 +0200
42b704
Subject: [PATCH] exportfs: add symlink support
42b704
42b704
based on implementation in Filesystem agent
42b704
---
42b704
 heartbeat/exportfs | 30 ++++++++++++++++++++++--------
42b704
 1 file changed, 22 insertions(+), 8 deletions(-)
42b704
42b704
diff --git a/heartbeat/exportfs b/heartbeat/exportfs
42b704
index 1cabdee70..294d7eec9 100755
42b704
--- a/heartbeat/exportfs
42b704
+++ b/heartbeat/exportfs
42b704
@@ -450,14 +450,28 @@ exportfs_validate_all ()
42b704
 	fi
42b704
 }
42b704
 
42b704
-# If someone puts a trailing slash at the end of the export directory,
42b704
-# this agent is going to fail in some unexpected ways due to how
42b704
-# export strings are matched.  The simplest solution here is to strip off
42b704
-# a trailing '/' in the directory before processing anything.
42b704
-newdir=$(echo "$OCF_RESKEY_directory" | sed -n -e 's/^\(.*\)\/$/\1/p')
42b704
-if [ -n "$newdir" ]; then
42b704
-	OCF_RESKEY_directory=$newdir
42b704
-fi
42b704
+for dir in $OCF_RESKEY_directory; do
42b704
+	# strip off trailing '/' from directory
42b704
+	dir=$(echo $dir | sed 's/\/*$//')
42b704
+	: ${dir:=/}
42b704
+	if [ -e "$dir" ] ; then
42b704
+		canonicalized_dir=$(readlink -f "$dir")
42b704
+		if [ $? -ne 0 ]; then
42b704
+			if [ "$__OCF_ACTION" != "stop" ]; then
42b704
+				ocf_exit_reason "Could not canonicalize $dir because readlink failed"
42b704
+				exit $OCF_ERR_GENERIC
42b704
+			fi
42b704
+		fi
42b704
+	else
42b704
+		if [ "$__OCF_ACTION" != "stop" ]; then
42b704
+			ocf_exit_reason "$dir does not exist"
42b704
+			exit $OCF_ERR_CONFIGURED
42b704
+		fi
42b704
+	fi
42b704
+	directories+="$canonicalized_dir "
42b704
+done
42b704
+
42b704
+OCF_RESKEY_directory="${directories%% }"
42b704
 
42b704
 NUMDIRS=`echo "$OCF_RESKEY_directory" | wc -w`
42b704
 OCF_REQUIRED_PARAMS="directory fsid clientspec"