#!/bin/sh
# $Id: t-qmgrctl-0.sh,v 1.6 2006/10/05 01:41:52 ca Exp $
# Copyright (c) 2005, 2006 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 qmgrctl -s
# uses smtpcnf.sh
# ----------------------------------------
#
test -s stop && exit 1
#
SD=`dirname $0`
if test "${SD}" = "."
then
SD=../chkmts
fi
. ${SD}/common.sh
I=""
EDBROK="t-qmgrctl-0.ok"
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 working directory
cd ../qmgr || exit 1
# remove map
rm -f ${ACCMAP}
# create aliases
${CAT} > ${ALI} <<EOF
abuse: local:
postmaster: local:
user: local:
EOF
# create map
rm -f ${ALIMAP}
${MM} < ${ALI}
# create mailertable (save old version?)
${CAT} > ${MT} <<EOF
local.dom lmtp:
some.dom [127.0.0.1]
EOF
QMCTLSOCKET=qmctl
# ----------------------------------------
${CAT} > ${SMXCNF} <<EOF
qmgr { Log_Level = 12; wait_for_server=4; wait_for_client=4;
retry_min_delay=1h; retry_max_delay=2h;
control_socket=${QMCTLSOCKET};
}
smar {
Log_Level = 12;
nameserver = ${NS};
DNS_timeout = 5;
}
smtpc { Log_Level = 12; remote_port=${SNKPORT}; wait_for_server=4; }
smtps {
Log_Level = 14;
daemon_address = localhost:${SRVPORT};
wait_for_server=4;
}
EOF
# ----------------------------------------
# test: send mail which is temporarily rejected by sink,
# then reschedule via qmgrctl
TEST=1
if echo " ${SKIP} X" | ${GREP} -v " ${TEST} " > /dev/null
then
ERR=false
${CAT} > ${EDBROK} <<EOF
got transaction
mail=<sender1@some.dom>
rcpts_tot=1
rcpts_left=1
rcpts_temp=1
rcpts_perm=0
state=451
aqt_rcpts_ar=0
got recipient
rcpt=<user@local.dom>
aqr_rcpt_idx=0
aqr_da_idx=1
aqr_status=451
EOF
LMTPSOCK=lmtpsock
if ${SHELL} ${SD}/smtpcnf.sh -z -3 ${LMTPSOCK} -B '-6 R' -Ssender${TEST}@some.dom -Ruser@local.dom -E 0 -X 0 -A 1 -O ${EDBROK}
then
if test -s ${B1}
then
${VERBOSE} && echo "$0: ${B1} exist when it should not"
ERR=true
else
:
fi
${STE}/smtps3 -C ${LMTPDIR} -L unix:${LMTPSOCK} >> ${LMTPL} 2>&1 &
LMTPPID=$!
TAID=`grep 'ss_ta=' ${SCL} | head -n1 | sed -e 's/^.*ss_ta=//' -e 's/,.*$//'`
RCPTID=${TAID}-000000
if ../misc/qmgrctl -s ${RCPTID} ${QMCTLSOCKET}
then
sleep 1
i=0
while test ! -s ${B1}
do
sleep 1
i=`expr $i + 1 `
test $i -ge 9 && break
done
if test -s ${B1}
then
:
else
${VERBOSE} && echo "$0: ${B1} missing after qmgrctl -s"
ERR=true
fi
else
${VERBOSE} && echo "$0: qmgrctl -s failed"
ERR=true
fi
kill -TERM ${LMTPPID}
else
ERR=true
fi
${SD}/stopmts.sh
if ${ERR}
then
echo "$0: test ${TEST} failed"
ERRS=`expr ${ERRS} + 1 `
test X"${MTA_STOPONERROR}" != X && exit 1
fi
rm -f ${B1}
else
${VERBOSE} && echo "$0: test ${TEST} SKIPPED"
fi
rm -f ${MTMAP} ${ALIMAP}
# ----------------------------------------
# end
if test "${ERRS}" = "0"
then
exit 0
else
echo "${ERRS} error(s)"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1