File nfsnotify.patch of Package resource-agents.21656

--- a/heartbeat/nfsnotify.in	2019-10-07 11:06:33.000000000 +0200
+++ b/heartbeat/nfsnotify.in	2021-10-20 14:11:26.595109302 +0200
@@ -33,10 +33,12 @@
 # Parameter defaults
 
 OCF_RESKEY_source_host_default=""
-OCF_RESKEY_notify_args_default="false"
+OCF_RESKEY_notify_args_default=""
+OCF_RESKEY_statd_path_default="/var/lib/nfs/statd"
 
 : ${OCF_RESKEY_source_host=${OCF_RESKEY_source_host_default}}
 : ${OCF_RESKEY_notify_args=${OCF_RESKEY_notify_args_default}}
+: ${OCF_RESKEY_statd_path=${OCF_RESKEY_statd_path_default}}
 
 #######################################################################
 
@@ -50,7 +52,6 @@
 NFSNOTIFY_TMP_DIR="${HA_RSCTMP}/nfsnotify_${OCF_RESOURCE_INSTANCE}/"
 HA_STATD_PIDFILE="$NFSNOTIFY_TMP_DIR/rpc.statd_${OCF_RESOURCE_INSTANCE}.pid"
 HA_STATD_PIDFILE_PREV="$NFSNOTIFY_TMP_DIR/rpc.statd_${OCF_RESOURCE_INSTANCE}.pid.prev"
-STATD_PATH="/var/lib/nfs/statd"
 SM_NOTIFY_BINARY="${sbindir}/sm-notify"
 IS_RENOTIFY=0
 
@@ -91,6 +92,15 @@
 <content type="string" default="${OCF_RESKEY_notify_args_default}" />
 </parameter>
 
+<parameter name="statd_path" unique="0" required="0">
+<longdesc lang="en">
+Path to the directory in which the statd state lives. This needs
+to be on shared storage.
+</longdesc>
+<shortdesc lang="en">statd state directory path</shortdesc>
+<content type="string" default="${OCF_RESKEY_statd_path_default}" />
+</parameter>
+
 </parameters>
 
 <actions>
@@ -203,8 +213,19 @@
 
 	cp -rpfn $src/sm $src/sm.bak $src/state $dest > /dev/null 2>&1
 
+	local rpcuser="root"
+	local rpcgrp="root"
+	if [ -n "$(id -u rpcuser >/dev/null 2>&1)" ]; then
+		rpcuser="rpcuser"
+	elif [ -n "$(id -u rpc >/dev/null 2>&1)" ]; then
+		rpcuser="rpc"
+	fi
+	if [ -n "$(id -g rpcuser >/dev/null 2>&1)" ]; then
+		rpcgrp="rpcuser"
+	fi
+
 	# make sure folder ownership and selinux lables stay consistent
-	[ -n "`id -u rpcuser`" -a "`id -g rpcuser`" ] && chown rpcuser.rpcuser "$dest"
+	chown $rpcuser:$rpcgrp "$dest"
 	[ $SELINUX_ENABLED -eq 0 ] && chcon -R "$SELINUX_LABEL" "$dest"
 }
 
@@ -239,12 +260,12 @@
 		is_renotify=1
 	fi
 
-	statd_backup="$STATD_PATH/nfsnotify.bu"
-	copy_statd "$STATD_PATH" "$statd_backup"
+	statd_backup="$OCF_RESKEY_statd_path/nfsnotify.bu"
+	copy_statd "$OCF_RESKEY_statd_path" "$statd_backup"
 
 	if [ -z "$OCF_RESKEY_source_host" ]; then
 		if [ "$is_renotify" -eq 0 ]; then
-			cur_statd="$STATD_PATH"
+			cur_statd="$OCF_RESKEY_statd_path"
 		else 
 			cur_statd="$statd_backup"
 		fi
@@ -264,13 +285,13 @@
 		# have the first sm-notify use the actual statd directory so the
 		# notify list can be managed properly.
 		if [ "$is_renotify" -eq 0 ]; then
-			cur_statd="$STATD_PATH"
+			cur_statd="$OCF_RESKEY_statd_path"
 			# everything after the first notify we are considering a renotification
 			# which means we don't use the real statd directory. 
 			is_renotify=1
 		else 
 			# use our copied statd directory for the remaining ip addresses
-			cur_statd="$STATD_PATH/nfsnotify_${OCF_RESOURCE_INSTANCE}_${ip}"
+			cur_statd="$OCF_RESKEY_statd_path/nfsnotify_${OCF_RESOURCE_INSTANCE}_${ip}"
 			copy_statd "$statd_backup" "$cur_statd"
 		fi
 
@@ -305,7 +326,7 @@
 which restorecon > /dev/null 2>&1 && selinuxenabled
 SELINUX_ENABLED=$?
 if [ $SELINUX_ENABLED -eq 0 ]; then
-	export SELINUX_LABEL="$(ls -dZ $STATD_PATH | grep -o '\S\+:\S\+:\S\+')"
+	export SELINUX_LABEL="$(ls -dZ $OCF_RESKEY_statd_path | grep -o '\S\+:\S\+:\S\+')"
 fi
 
 case $__OCF_ACTION in
openSUSE Build Service is sponsored by