Skip to content

Commit

Permalink
Medium: IPsrcaddr: exit with the right code when not properly configured
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuhamedagic committed Dec 13, 2010
1 parent aa2b080 commit 2db67fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions heartbeat/IPsrcaddr
Expand Up @@ -247,7 +247,7 @@ CheckIP() {
then
if [ $1 -eq 127 ]; then
ocf_log err "IP address [$ip] is a loopback address, thus can not be preferred source address"
exit $OCF_ERR_ARGS
exit $OCF_ERR_CONFIGURED
fi
else
true
Expand Down Expand Up @@ -385,7 +385,7 @@ ip_status() {
case $IF in
lo*)
ocf_log err "IP address [$BASEIP] is served by loopback, thus can not be preferred source address"
exit $OCF_ERR_ARGS
exit $OCF_ERR_CONFIGURED
;;
*)return $OCF_SUCCESS;;
esac
Expand All @@ -412,15 +412,15 @@ srca_validate_all() {
:
else
ocf_log err "Invalid IP address [$ipaddress]"
exit $OCF_ERR_ARGS
exit $OCF_ERR_CONFIGURED
fi

# We should serve this IP address of course
if ip_status "$ipaddress"; then
:
else
ocf_log err "We are not serving [$ipaddress], hence can not make it a preferred source address"
exit $OCF_ERR_ARGS
exit $OCF_ERR_INSTALLED

This comment has been minimized.

Copy link
@beekhof

beekhof Mar 24, 2015

Member

@dmuhamedagic Oops, wrong spot previously.
This is the change that looks wrong (both the old and the new).
Combined with srca_validate_all(), this will result in fencing when stopping an inactive instance (as would happen for a misconfigured resource)

This comment has been minimized.

Copy link
@dmuhamedagic

dmuhamedagic Mar 24, 2015

Author Contributor

Could be. Will take a look. Feel free to make a pull request.

This comment has been minimized.

Copy link
@dmuhamedagic

dmuhamedagic Mar 24, 2015

Author Contributor

Yes, the check seems to be misplaced. Wonder how did it get there.

This comment has been minimized.

Copy link
@dmuhamedagic

dmuhamedagic Mar 24, 2015

Author Contributor

It's a bit of a mess, I'll see to convert it to ocf_rarun.

fi
}

Expand Down Expand Up @@ -448,12 +448,15 @@ if
then
# usage
ocf_log err "Please set OCF_RESKEY_ipaddress to the preferred source IP address!"
exit $OCF_ERR_ARGS
exit $OCF_ERR_CONFIGURED
fi

ipaddress="$OCF_RESKEY_ipaddress"

INTERFACE=`$FINDIF -C |grep -o "^[^[:space:]]*"`
findif_out=`$FINDIF -C`
rc=$?
[ $rc -ne 0 ] && exit $rc
INTERFACE=`echo $findif_out | awk '{print $1}'`
NETWORK=`ip route list dev $INTERFACE scope link|grep -o '^[^ ]*'`

case $1 in
Expand Down
6 changes: 3 additions & 3 deletions tools/ocft/IPsrcaddr
Expand Up @@ -22,12 +22,12 @@ CASE "check base env"
CASE "check base env: unset 'OCF_RESKEY_ipaddress'"
Include prepare
Unvar OCF_RESKEY_ipaddress
AgentRun start OCF_ERR_ARGS
AgentRun start OCF_ERR_CONFIGURED

CASE "check base env: set worng 'OCF_RESKEY_ipaddress'"
CASE "check base env: set invalid 'OCF_RESKEY_ipaddress'"
Include prepare
Var OCF_RESKEY_ipaddress=not_ip_address
AgentRun start OCF_ERR_ARGS
AgentRun start OCF_ERR_CONFIGURED

CASE "normal start"
Include prepare
Expand Down

0 comments on commit 2db67fa

Please sign in to comment.