From 584c4b8aa64e86a8ea2ef11667fe83c8d661e37d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 23 Jun 2011 16:53:25 +0200 Subject: [PATCH] Use local variable instead of global --- firewall | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/firewall b/firewall index c625b6a..33d5ad0 100755 --- a/firewall +++ b/firewall @@ -75,10 +75,10 @@ forward_port() return fi - source=$1 - port=$2 - destination=$3 - proto=$4 + local source=$1 + local port=$2 + local destination=$3 + local proto=$4 if echo "$destination" | grep -q ":"; then dest_ip=$(echo $destination | cut -d ":" -f1) @@ -97,13 +97,13 @@ forward_port() open_port() { if [ $# == 4 ]; then - destination=$2 - proto=$3 - ports=$4 + local destination=$2 + local proto=$3 + local ports=$4 elif [ $# == 3 ]; then - destination=$IP - proto=$2 - ports=$3 + local destination=$IP + local proto=$2 + local ports=$3 else echo "!!! CRITICAL Open port bad syntax : $*" stop && exit 1 @@ -123,10 +123,10 @@ port_redirection() return fi - if=$1 - proto=$2 - srcport=$3 - destport=$4 + local if=$1 + local proto=$2 + local srcport=$3 + local destport=$4 echo "+ Redirect $if port $srcport to $destport for portocol $proto" iptables -t nat -A PREROUTING -i $if -p $proto --dport $srcport -j REDIRECT --to-port $destport @@ -139,11 +139,11 @@ port_knocking() return fi - port=$1 - knock_ports=$2 - knock_number=$3 + local port=$1 + local knock_ports=$2 + local knock_number=$3 + local i=0 - i=0 for kport in $(echo $knock_ports | sed 's/,/ /g'); do ((i++)) tock_number=$knock_number$i @@ -253,10 +253,10 @@ start() done ## Port knocking - j=1 + local i=1 for args in "${PORT_KNOCK[@]}"; do - port_knocking $args $j - ((j++)) + port_knocking $args $i + ((i++)) done ## Port forwading