#!/bin/sh
# $Id: t-pm-regex-2.sh,v 1.4 2007/01/11 02:00:26 ca Exp $
# Copyright (c) 2006 Claus Assmann
#
# By using this file, you agree to the terms and conditions set
# forth in the license/LICENSE.3C file which can be found at the
# top level of this source code distribution.
#
# ----------------------------------------
# test milter-regex, delay_checks, quick rejection
# uses smtpcnf.sh.
# ----------------------------------------
#
test -s stop && exit 1
#
if test "X"${MTA_PMILTER_REGEX_TEST} = "X"
then
echo "SKIPPED: $0: MTA_PMILTER_REGEX_TEST is not set"
exit 0
fi
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
PMPRG="../contrib/milter-regex"
if test -x ${PMPRG}
then
:
else
echo "SKIPPED: $0: ${PMPRG} missing"
exit 0
fi
PMCONF="regex.conf"
PMOPT="-d -c ${PMCONF} -p pmilter.sock"
MSG="t-pm-regex-2.msg"
if test X"`uname`" != "XOSF1"
then
while getopts O:s:V FLAG
do
case "${FLAG}" in
O) PMOPT="${PMOPT} ${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 = 12;
daemon_address = localhost:${SRVPORT};
wait_for_server=4;
policy_milter { socket {type=unix; path="pmilter.sock";} timeout=2; }
flags = { delay_checks }
}
EOF
# ----------------------------------------
# reject Subject in milter
TEST=1
if echo "${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
${CAT} > ${PMCONF} <<EOF
reject_quick "stocknews"
envfrom /<[0-9]*stocknews@/
EOF
${CAT} > ${MSG} <<EOF
From: sender@local.domain
To: rcpt@local.domain
Message-Id: <t-${TEST}-123456789@local.dom>
Subject: stock news
t-${TEST}-123456789@local.dom
EOF
if ${SHELL} ${SCRIPTS}/smtpcnf.sh -S21stocknews@example.com -p ${PMPRG} -P "${PMOPT}" -Z 'smtpc2' -c "-E -D ${MSG}" -E 0 -A 0 -X 0 $@ -R"x@y.z"
then
ERR=false
else
echo "$0: test ${TEST} failed."
ERR=true
test X"${MTA_STOPONERROR}" != X && exit 1
fi
if ${GREP} 'MAIL=error' ${CLTL} >/dev/null
then
:
else
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