summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérôme Schneider <jschneider@entrouvert.com>2011-06-23 14:53:25 (GMT)
committerJérôme Schneider <jschneider@entrouvert.com>2011-06-23 14:53:25 (GMT)
commit584c4b8aa64e86a8ea2ef11667fe83c8d661e37d (patch)
tree05cd691564afbb0043e1bac43c3161afe3c9dd92
parent0749affec526488654685c16383f6ae9079a9d36 (diff)
downloadeofirewall-584c4b8aa64e86a8ea2ef11667fe83c8d661e37d.zip
eofirewall-584c4b8aa64e86a8ea2ef11667fe83c8d661e37d.tar.gz
eofirewall-584c4b8aa64e86a8ea2ef11667fe83c8d661e37d.tar.bz2
Use local variable instead of global
-rwxr-xr-xfirewall42
1 files 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