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

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