cluster: STABLE3 - cman init: add check for executable
Fabio M. Di Nitto
fabbione at fedoraproject.org
Mon Jan 11 15:51:11 UTC 2010
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=f28ffc584d21fdf0c72e97ccc13a16c85e253655
Commit: f28ffc584d21fdf0c72e97ccc13a16c85e253655
Parent: 2d63f693d780f9b3ac667c3445346f5798c42537
Author: Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate: Mon Jan 11 16:49:25 2010 +0100
Committer: Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Mon Jan 11 16:49:25 2010 +0100
cman init: add check for executable
based on debian idea to check if a binary is available and executable,
implement a generic check and use it around.
we do only check for our own binaries. System binaries are supposed to be
there and in a sane state (otherwise the init script would fail anyway).
Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
cman/init.d/cman.in | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/cman/init.d/cman.in b/cman/init.d/cman.in
index 9caff61..1cf3366 100644
--- a/cman/init.d/cman.in
+++ b/cman/init.d/cman.in
@@ -19,8 +19,6 @@
# set secure PATH
PATH="/bin:/usr/bin:/sbin:/usr/sbin:@SBINDIR@"
-[ -x @SBINDIR@/cman_tool ] || exit 0
-
local_chkconfig()
{
case "$1" in
@@ -222,12 +220,29 @@ runwrap()
fi
}
+check_exec()
+{
+ exec=$1
+
+ realexec="$(type -p $exec)"
+ if [ -z "$realexec" ]; then
+ errmsg="Unable to find $exec in PATH"
+ return 1
+ fi
+ if [ ! -x "$realexec" ]; then
+ errmsg="$realexec not executable"
+ return 1
+ fi
+ return 0
+}
+
start_daemon()
{
daemon=$1
shift
args="$@"
+ check_exec $daemon || return $?
status $daemon > /dev/null 2>&1 && return 0
errmsg=$( $daemon $args 2>&1 )
}
@@ -505,6 +520,7 @@ stop_configfs()
start_cman()
{
+ check_exec cman_tool || return $?
cman_running && return 0
cman_checkconfig || return 1
More information about the cluster-commits
mailing list