#!/bin/sh
# $Id: t-smar-1.sh,v 1.19 2007/04/26 04:08:59 ca Exp $
# Copyright (c) 2003, 2004 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.
#
# ------------------------------------------------------------
# Description:
# Script to test MX/A expansion for RFC2821 addresses.
# Uses smar, t-smar.sh, DNS
# Note: this program relies on the meta1.org DNS server and some "quirks",
# unroutable addresses as name servers to create timeouts.
# ------------------------------------------------------------
#
test -s stop && exit 1
#
if test X"${MTA_NO_DNS_TEST}" != "X"
then
echo "SKIPPED: $0"
exit 0
fi
if test X"${MTA_NO_DNS_HACK_TEST}" != "X"
then
echo "SKIPPED: $0"
exit 0
fi
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../smar
fi
. ${SD}/common.sh
OK=smar.ok
rm -f ${SOCK} ${PIDS}
SKIP=""
VERBOSE=false
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
# ; test records
# ; pointing to existing host
# mxok.meta1.org. IN MX 10 server.meta1.org.
# ; pointing to non-existing host
# mxnonexistent.meta1.org. IN MX 10 nonexistent.meta1.org.
# ; pointing to two hosts: one exists the other doesn't
# mxhalfok0.meta1.org. IN MX 10 server.meta1.org.
# mxhalfok0.meta1.org. IN MX 20 nonexistent.meta1.org.
# ; pointing to two hosts: one exists the other doesn't
# mxhalfok1.meta1.org. IN MX 10 nonexistent.meta1.org.
# mxhalfok1.meta1.org. IN MX 20 server.meta1.org.
# ; pointing to two hosts: one exists the other doesn't
# mxhalfok2.meta1.org. IN MX 10 nonexistent.meta1.org.
# mxhalfok2.meta1.org. IN MX 10 server.meta1.org.
# ; how to create tempory errors?
# bogus.meta1.org has been delegated to 127.0.0.2 which shouldn't answer
# DNS requests -> timeout...
# mx.bogus.meta1.org. should time out
# mxbogus.meta1.org. IN MX 10 server.bogus.meta1.org.
# ; pointing to IP address
# mxip.meta1.org. 21600 IN MX 10 127.1.2.3.
# ; pointing to two IP addresses
# mxip2.meta1.org. 21600 IN MX 10 127.1.2.4.
# mxip2.meta1.org. 21600 IN MX 10 127.1.2.5.
# add records where one entry times out?
TEST=1
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a1@mxok.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=2
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a2@mxnonexistent.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'WARN: lookup=(perm|notfound)' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=3
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a3@mxhalfok0.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=4
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a4@mxhalfok1.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=5
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a5@mxhalfok2.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
# ; a bogus name server
# bogus.meta1.org. IN NS bogusns.meta1.org.
# bogusns.meta1.org. IN A 127.0.0.2
#
# ; test records
# ; pointing to host whose name server doesn't answer
# mx2at.meta1.org. 21600 IN MX 10 server.bogus.meta1.org.
# ; pointing to two hosts: first exists second doesn't
# mx2ahalft0.meta1.org. 21600 IN MX 10 server.meta1.org.
# mx2ahalft0.meta1.org. 21600 IN MX 20 server.bogus.meta1.org.
# ; pointing to two hosts: first doesn't exists the other does
# mx2ahalft1.meta1.org. 21600 IN MX 10 server.bogus.meta1.org.
# mx2ahalft1.meta1.org. 21600 IN MX 20 server.meta1.org.
# ; pointing to two hosts: one exists the other doesn't
# mx2ahalft2.meta1.org. 21600 IN MX 10 server.bogus.meta1.org.
# mx2ahalft2.meta1.org. 21600 IN MX 10 server.meta1.org.
# ; MX pointing to invalid host: not accepted by nameserver, can't use it!
# mxinvalidhost.meta1.org. IN MX 10 invalid@host.meta1.org.
# ; pointing to IP address
# mxip.meta1.org. 21600 IN MX 10 127.1.2.3.
TEST=6
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a6@mx.bogus.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'WARN: lookup=(timeout|temp_fail)' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=7
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a7@mx2at.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'WARN: lookup=(timeout|temp_fail)' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=8
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a8@mx2ahalft0.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=9
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
if test X"${MTA_FULL_DNS_TEST}" != "X"
then
A='<a9@mx2ahalft1.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'WARN: lookup=timeout' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
fi
TEST=10
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a10@mx2ahalft2.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'IP\[0\]=127.0.0.1 \[7f000001\]' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
TEST=11
# ----------------------------------------
if echo "${SKIP} X" | grep -v " ${TEST} " > /dev/null
then
A='<a11@mxip.meta1.org>'
${SHELL} ${SD}/t-smar.sh -e 'WARN: lookup=(perm|notfound)' ${A}
ok=$?
if test ${ok} != 0
then
ERRS=`expr ${ERRS} + 1 `
echo "$0: test ${TEST} failed: ${A}"
test X"${MTA_STOPONERROR}" != X && exit ${ERRS}
else
${VERBOSE} && echo "$0: test ${TEST} OK"
fi
fi
exit ${ERRS}
syntax highlighted by Code2HTML, v. 0.9.1