#!/bin/sh
top_builddir="@top_builddir@"
env_setup="@env_setup@"
objdir="@objdir@"
testfailed="echo test failed; cat messages.log; exit 1"
. ${env_setup}
${have_db} || exit 77
R=TEST.H5L.SE
R2=TEST2.H5L.SE
port=@port@
kadmin="${kadmin} -l -r $R"
kdc="${kdc} --addresses=localhost -P $port"
afsserver=afs/test.h5l.se
hostserver=host/server.test.h5l.se
cache="FILE:${objdir}/cache.krb5"
kinit="${kinit} -c $cache ${afs_no_afslog}"
klist="${klist} -c $cache"
kgetcred="${kgetcred} -c $cache"
kdestroy="${kdestroy} -c $cache ${afs_no_unlog}"
KRB5_CONFIG="${objdir}/krb5.conf"
export KRB5_CONFIG
rm -f ${keytabfile}
rm -f current-db*
rm -f out-*
rm -f mkey.file*
> messages.log
echo Creating database
${kadmin} \
init \
--realm-max-ticket-life=1day \
--realm-max-renewable-life=1month \
${R} || exit 1
${kadmin} \
init \
--realm-max-ticket-life=1day \
--realm-max-renewable-life=1month \
${R2} || exit 1
${kadmin} cpw -r krbtgt/${R}@${R} || exit 1
${kadmin} add -p foo --use-defaults foo@${R} || exit 1
${kadmin} add -p kaka --use-defaults ${afsserver}@${R} || exit 1
${kadmin} add -p kaka --use-defaults ${hostserver}@${R} || exit 1
${kadmin} add_enctype -r ${afsserver}@${R} des-cbc-crc || exit 1
${kadmin} add_enctype -r ${hostserver}@${R} des-cbc-crc || exit 1
echo "Doing database check"
${kadmin} check ${R} || exit 1
echo foo > ${objdir}/foopassword
echo Starting kdc
${kdc} &
kdcpid=$!
sh ${wait_kdc}
if [ "$?" != 0 ] ; then
kill -9 ${kdcpid}
exit 1
fi
trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
ec=0
echo "Getting client initial tickets"; > messages.log
${kinit} --password-file=${objdir}/foopassword foo@$R || \
{ ec=1 ; eval "${testfailed}"; }
echo "Getting non des tickets (afs)"; > messages.log
${kgetcred} ${afsserver}@${R} || { ec=1 ; eval "${testfailed}"; }
${klist} -v | grep des-cbc-crc > /dev/null && { ec=1 ; eval "${testfailed}"; }
echo "Getting non des tickets (host/)"; > messages.log
${kgetcred} ${hostserver}@${R} || { ec=1 ; eval "${testfailed}"; }
${klist} -v | grep des-cbc-crc > /dev/null && { ec=1 ; eval "${testfailed}"; }
${kdestroy}
echo "Getting client initial tickets"; > messages.log
${kinit} --password-file=${objdir}/foopassword foo@$R || \
{ ec=1 ; eval "${testfailed}"; }
echo "Getting des tickets (fail test)"; > messages.log
${kgetcred} -e des-cbc-crc ${hostserver}@${R} 2>/dev/null && \
{ ec=1 ; eval "${testfailed}"; }
echo "Getting non des tickets"; > messages.log
${kgetcred} ${afsserver}@${R} || { ec=1 ; eval "${testfailed}"; }
${klist} -v | grep des-cbc-crc > /dev/null && { ec=1 ; eval "${testfailed}"; }
KRB5_CONFIG="${objdir}/krb5-weak.conf"
echo "Getting client initial tickets"; > messages.log
${kinit} --password-file=${objdir}/foopassword foo@$R || \
{ ec=1 ; eval "${testfailed}"; }
echo "Getting non des tickets (host/), failure test"; > messages.log
${kgetcred} -e des-cbc-crc ${hostserver}@${R} 2>/dev/null && \
{ ec=1 ; eval "${testfailed}"; }
${klist} -v | grep des-cbc-crc > /dev/null && { ec=1 ; eval "${testfailed}"; }
echo "Getting des tickets (afs)"; > messages.log
${kgetcred} -e des-cbc-crc ${afsserver}@${R} || { ec=1 ; eval "${testfailed}"; }
${klist} -v | grep des-cbc-crc > /dev/null || { ec=1 ; eval "${testfailed}"; }
${kdestroy}
${kdestroy}
echo "killing kdc (${kdcpid})"
sh ${leaks_kill} kdc $kdcpid || exit 1
trap "" EXIT
exit $ec