#!/bin/sh
# $Id: t-dnsbl-3.sh,v 1.1 2007/06/20 05:26:48 ca Exp $
#
# ------------------------------------------------------------
# Description:
# Script to test DNS BL and access map restrictions (only IP addresses)
# dnsbl returns multiple A records.
# Uses smar, t-smar-3, access map, t-mm, startsmar.sh
# ------------------------------------------------------------
#
test -s stop && exit 1
#
if test X"${MTA_NO_DNS_TEST}" != "X"
then
echo "SKIPPED: $0"
exit 0
fi
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../smar
fi
. ${SD}/common.sh
OUT=dnsbl-3.out
IP=dnsbl-3.ip
OK=dnsbl-3.ok
VERBOSE=false
CONF=smar.conf
TPRG=./t-smar-3
RMTMP=true
if test X"`uname`" != "XOSF1"
then
while getopts kV FLAG
do
case "${FLAG}" in
k) RMTMP=false;;
V) VERBOSE=true;;
esac
done
shift `expr ${OPTIND} - 1`
fi
rm -f ${ACCMAP} ${SOCK} ${PIDS}
# create access map for tests
${MM} -t' ' -F ${ACCMAP} <<EOF
#meta1dnsbl:127.0.0.100 error:550 5.7.100 found 127.0.0.100 in meta1dnsbl
meta1dnsbl:127.0.0.101 error:550 5.7.101 found 127.0.0.101 in meta1dnsbl
#meta1dnsbl:127.0.0.102 error:550 5.7.102 found 127.0.0.102 in meta1dnsbl
EOF
cat > ${CONF} <<EOF
smar {
Log_Level = 12;
DNS_timeout = 5;
# should tag include ":"?
dnsbl { domain = dnsbl.meta1.org.; tag = "meta1dnsbl"; }
}
EOF
# start SMAR
${SHELL} ${SD}/startsmar.sh -d 9 -f ${CONF} || exit 1
rm -f ${OUT} ${IP} ${OK}
TEST=1
# ----------------------------------------
# test: dnsbl: rejection
${VALGRIND} ${TPRG} -d '127.0.0.100' > ${OUT} 2>&1
grep '^react=' ${OUT} > ${IP}
cat > ${OK} <<EOF
react=statt, ret=0, statt='550 5.7.101 found 127.0.0.101 in meta1dnsbl
EOF
if diff ${OK} ${IP}
then
:
else
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed."
${VERBOSE} && echo ${TEST} failed
fi
# stop SMAR
for i in `cat ${PIDS}`
do
kill ${i}
done
# ----------------
# thanks kids for not following the POSIX standard...
if test X"`uname`" = "XLinux"
then
killall smar
fi
sleep 3
if test ${ERRS} -eq 0
then
${RMTMP} && rm -f ${OUT} ${IP} ${OK}
fi
exit ${ERRS}
syntax highlighted by Code2HTML, v. 0.9.1