From 4e4cdb43ad204a6fa53801fec03a464c8888624f Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Mon, 26 Aug 2013 10:44:18 -0700 Subject: [PATCH] ovs-save: Do not depend on hardcoded set of $PATH for utilities. Reported-by: Jian Qiu Signed-off-by: Gurucharan Shetty Acked-by: Ben Pfaff --- AUTHORS | 1 + utilities/ovs-save | 27 ++++++--------------------- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/AUTHORS b/AUTHORS index 890ed3aa1..af34bfedd 100644 --- a/AUTHORS +++ b/AUTHORS @@ -164,6 +164,7 @@ Jari Sundell sundell.software@gmail.com Jed Daniels openvswitch@jeddaniels.com Jeff Merrick jmerrick@vmware.com Jeongkeun Lee jklee@hp.com +Jian Qiu swordqiu@gmail.com Joan Cirer joan@ev0.net John Galgay john@galgay.net Kevin Mancuso kevin.mancuso@rackspace.com diff --git a/utilities/ovs-save b/utilities/ovs-save index b46f98d3b..73895f337 100755 --- a/utilities/ovs-save +++ b/utilities/ovs-save @@ -33,23 +33,8 @@ This script is meant as a helper for the Open vSwitch init script commands. EOF } -PATH=/sbin:/bin:/usr/sbin:/usr/bin - -missing_program () { - save_IFS=$IFS - IFS=: - for dir in $PATH; do - IFS=$save_IFS - if test -x $dir/$1; then - return 1 - fi - done - IFS=$save_IFS - return 0 -} - save_interfaces () { - if missing_program ip; then + if (ip -V) > /dev/null 2>&1; then :; else echo "$0: ip not found in $PATH" >&2 exit 1 fi @@ -152,18 +137,18 @@ save_interfaces () { echo done - if missing_program iptables-save; then - echo "# iptables-save not found in $PATH, not saving iptables state" - else + if (iptables-save) > /dev/null 2>&1; then echo "# global" echo "iptables-restore <<'EOF'" iptables-save echo "EOF" + else + echo "# iptables-save not found in $PATH, not saving iptables state" fi } save_flows () { - if missing_program ovs-ofctl; then + if (ovs-ofctl --version) > /dev/null 2>&1; then :; else echo "$0: ovs-ofctl not found in $PATH" >&2 exit 1 fi @@ -182,7 +167,7 @@ ovs_vsctl () { save_ofports () { - if missing_program ovs-vsctl; then + if (ovs-vsctl --version) > /dev/null 2>&1; then :; else echo "$0: ovs-vsctl not found in $PATH" >&2 exit 1 fi -- 2.20.1