[Cluster-devel] [PATCH] resource-agents: nfsclient: fix wildcard status checks [RHEL5]

Lon Hohberger lhh at redhat.com
Fri Oct 28 02:26:20 UTC 2011


Several permutations of nfsclients with options were
not checked correctly due to bad pattern matching.

Resolves: rhbz#700103

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/src/resources/nfsclient.sh |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/rgmanager/src/resources/nfsclient.sh b/rgmanager/src/resources/nfsclient.sh
index 138370d..42ed2ce 100755
--- a/rgmanager/src/resources/nfsclient.sh
+++ b/rgmanager/src/resources/nfsclient.sh
@@ -391,8 +391,8 @@ status|monitor)
 		exportfs -v > $tmpfn
 	fi
 
-        cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -iq \
-		"^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_regexp}" 
+        cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -Piq \
+		"^${OCF_RESKEY_path}[\t ]+${OCF_RESKEY_target_regexp}" 
 	rv=$? 
 
 	if [ $rv -eq 0 ]; then
@@ -400,15 +400,19 @@ status|monitor)
 		exit 0
 	fi
 
-	declare OCF_RESKEY_target_tmp=$(clufindhostname -i "$OCF_RESKEY_target")
+	declare OCF_RESKEY_target_tmp
+	OCF_RESKEY_target_tmp=$(clufindhostname -i "$OCF_RESKEY_target")
 	if [ $? -ne 0 ]; then
-		[ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
-		ocf_log err "nfsclient:$OCF_RESKEY_name is missing!"
-		exit 1
+		OCF_RESKEY_target_tmp=$(clufindhostname -n "$OCF_RESKEY_target")
+		if [ $? -ne 0 ]; then
+			[ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
+			ocf_log err "nfsclient:$OCF_RESKEY_name is missing!"
+			exit 1
+		fi
 	fi
 
-        cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -q \
-		"^${OCF_RESKEY_path}[\t ]*.*${OCF_RESKEY_target_tmp}" 
+        cat $tmpfn | tr -d "\n" | sed -e 's/([^)]*)/\n/g' | grep -Pq \
+		"^${OCF_RESKEY_path}[\t ]+${OCF_RESKEY_target_tmp}" 
 	rv=$? 
 
 	[ "$OCF_RESKEY_use_cache" = "1" ] || rm -f $tmpfn
-- 
1.7.3.4




More information about the Cluster-devel mailing list