check correct sourcing of configuration file, and exit if it fails

This commit is contained in:
Thomas Martin 2010-06-09 19:27:19 +02:00 committed by Gregory Colpart
parent 1cdb7af52c
commit ac9400aa8c
1 changed files with 15 additions and 1 deletions

View File

@ -91,7 +91,21 @@ $IPT -A LOG_ACCEPT -j LOG --log-prefix '[IPTABLES ACCEPT] : '
$IPT -A LOG_ACCEPT -j ACCEPT
# Configuration
test -f /etc/firewall.rc && . /etc/firewall.rc
configfile="/etc/firewall.rc"
if ! test -f $configfile; then
echo "$configfile does not exist" >&2
exit 1
fi
tmpfile=`mktemp`
. $configfile 2>$tmpfile >&2
if [ -s $tmpfile ]; then
echo "$configfile returns standard or error output (see below). Stopping."
cat $tmpfile
exit 1
fi
rm $tmpfile
# trusted ip addresses
$IPT -N ONLYTRUSTED