#!/bin/sh
# $Id: t-pm-rsad-4.sh,v 1.2 2007/03/23 03:21:22 ca Exp $
#
# ----------------------------------------
# test pmilter RSAD, including recipient addition/deletion by pmilter
# uses smtpcnf.sh.
# ----------------------------------------
#
test -s stop && exit 1
#
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../chkmts
fi
. ${SD}/common.sh
SCRIPTS=`cd ${SD} && pwd`
if ../smtps/smtps -VVV | ${GREP} MTA_USE_PMILTER >/dev/null
then
:
else
echo "SKIPPED: $0: smtps not compiled with MTA_USE_PMILTER (--enable-pmilter)"
exit 0
fi
if ../smtps/smtps -VVV | ${GREP} MTA_USE_RSAD >/dev/null
then
:
else
echo "SKIPPED: $0: smtps not compiled with MTA_USE_RSAD"
exit 0
fi
PMPRG="-p ../libpmilter/t-pmilter-1"
PMOPT=""
if test X"`uname`" != "XOSF1"
then
while getopts O:p:s:V FLAG
do
case "${FLAG}" in
O) PMOPT="${PMOPT} ${OPTARG}";;
p) PMPRG="-p ${OPTARG}";;
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}
${CAT} > ${SMXCNF} <<EOF
qmgr { Log_Level = 12; wait_for_server=4; wait_for_client=4; }
smar { Log_Level = 12; nameserver = ${NS}; }
smtpc { Log_Level = 12; remote_port=${SNKPORT}; wait_for_server=4; }
smtps {
Log_Level = 19;
flags={prdr};
daemon_address = localhost:${SRVPORT};
wait_for_server=4;
policy_milter { socket {type=unix; path="pmilter.sock";} timeout=2; }
}
EOF
# create aliases
${CAT} > ${ALI} <<EOF
abuse: local:
postmaster: local:
user: local:
del: local:
i-spy: local:
EOF
# create map
rm -f ${ALIMAP}
${MM} < ${ALI}
# ----------------------------------------
# reject rcpt command in milter (deferred): perm/temp/ok
TEST=1
if echo "${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
# XREF: SMTP_R_D_EOM=353
if ${SHELL} ${SCRIPTS}/smtpcnf.sh ${PMPRG} ${PMOPT} -P "-r b=353" -Z 'smtpc2' -c '-E -9' -E 1 -A 1 -X 1 $@ -S"a@b.c" -n 4 -R"d250@y.z -Rd451@y.z -Rd552@y.z -Rdel@local.dom" -3 lmtpsock ${PMPRG} ${PMOPT} -P '-T <i-spy@local.dom>' -P '-X 3=<del@local.dom>'
then
ERR=false
else
echo "$0: test ${TEST} failed"
ERR=true
test X"${MTA_STOPONERROR}" != X && exit 1
fi
# need more/better checks...
if ${GREP} 'RCPT=error, text=550 5.7.0 Rejected' ${CLTL} >/dev/null
then
:
else
echo "$0: ${TEST}: missing 550 5.7.0 Rejected"
ERR=true
fi
if ${GREP} 'RCPT=error, text=451 4.5.0 Temporary error' ${CLTL} >/dev/null
then
:
else
echo "$0: ${TEST}: missing 451 4.5.0 Temporary error"
ERR=true
fi
if ${GREP} 'DOT=error' ${CLTL} >/dev/null
then
echo "$0: ${TEST}: found DOT=error"
ERR=true
fi
if ${GREP} 'rcpt=<i-spy@local\.dom>' ${SCL} >/dev/null
then
:
else
echo "$0: ${TEST}: missing rcpt i-spy@local.dom"
ERR=true
fi
if ${ERR}
then
echo "$0: test ${TEST} check failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
else
${VERBOSE} && echo "test ${TEST} succeeded"
fi
fi
# ----------------------------------------
# end
if test "${ERRS}" = "0"
then
exit 0
else
echo "${ERRS} error(s)"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1