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

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