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

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