#!/bin/sh
# $Id: t-mts-dnsbl-grey-0.sh,v 1.9 2007/01/10 23:29:20 ca Exp $
# Copyright (c) 2004, 2005 Sendmail, Inc. and its suppliers.
# All rights reserved.
#
# By using this file, you agree to the terms and conditions set
# forth in the LICENSE file which can be found at the top level of
# the sendmail distribution.
#
# ----------------------------------------
# test DNSBL + greylisting
# uses smtpcnf.sh.
# ----------------------------------------
#
test -s stop && exit 1
#
# this is a "slow" test?
if test X"${MTA_NO_SLOW_TEST}" != "X"
then
echo "SKIPPED: $0: MTA_NO_SLOW_TEST is set"
exit 0
fi
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../chkmts
fi
. ${SD}/common.sh
SCRIPTS=`cd ${SD} && pwd`
if test X"`uname`" != "XOSF1"
then
while getopts s:V FLAG
do
case "${FLAG}" in
s) SKIP="${SKIP} ${OPTARG}";;
V) VERBOSE=true;;
esac
done
shift `expr ${OPTIND} - 1`
fi
# cd to right directory (where the programs will be executed).
cd ../qmgr || exit 1
rm -f ${MTMAP} ${ACCMAP}
# create access map for tests
${MM} -t' ' -F ${ACCMAP} <<EOF
meta1all:127.0.0.2 error:550 5.7.2 found 127.0.0.2 in meta1all
EOF
${CAT} > ${SMXCNF} <<EOF
qmgr { Log_Level = 12; wait_for_server=4; wait_for_client=4; }
smar {
Log_Level = 12;
nameserver = ${NS};
DNS_timeout = 5;
greylisting { grey_wait=10s; grey_expire=30s; }
dnsbl { domain = all.meta1.org.; tag = "meta1all"; }
}
smtpc { Log_Level = 12; remote_port=${SNKPORT}; wait_for_server=4; }
smtps {
Log_Level = 14;
daemon_address = localhost:${SRVPORT};
flags = {access,greylisting};
wait_for_server=4;
}
EOF
# ----------------------------------------
# reject by dnsbl
TEST=1
if echo "${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
rm -f grey_grey_m.db grey_grey_s.db
ERR=false
SENDER=sender${TEST}@b.c
RCPT=r${TEST}@y.z
if ${SHELL} ${SD}/smtpcnf.sh -Z 'smtpc2' -c '-E' -S${SENDER} -R${RCPT} -E 0 -X 0 -A 0
then
${VERBOSE} && echo "test ${TEST} succeeded"
else
echo "$0: test ${TEST} failed"
ERR=true
test X"${MTA_STOPONERROR}" != X && exit 1
fi
if ${GREP} 'MAIL=error, text=550' ${CLTL} >/dev/null
then
:
else
${VERBOSE} && echo "$0: test ${TEST}: missing MAIL=error in log"
ERR=true
fi
if ${ERR}
then
echo "$0: test ${TEST} check failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
fi
# clean up
rm -f ${MTMAP} ${ACCMAP}
# ----------------------------------------
# end
if test "${ERRS}" = "0"
then
exit 0
else
echo "${ERRS} error(s)"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1