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