1#!/bin/sh 2# 3# Copyright (c) 2006 - 2007 Kungliga Tekniska Högskolan 4# (Royal Institute of Technology, Stockholm, Sweden). 5# All rights reserved. 6# 7# Portions Copyright (c) 2009 - 2010 Apple Inc. All rights reserved. 8# 9# Redistribution and use in source and binary forms, with or without 10# modification, are permitted provided that the following conditions 11# are met: 12# 13# 1. Redistributions of source code must retain the above copyright 14# notice, this list of conditions and the following disclaimer. 15# 16# 2. Redistributions in binary form must reproduce the above copyright 17# notice, this list of conditions and the following disclaimer in the 18# documentation and/or other materials provided with the distribution. 19# 20# 3. Neither the name of the Institute nor the names of its contributors 21# may be used to endorse or promote products derived from this software 22# without specific prior written permission. 23# 24# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 25# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 28# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34# SUCH DAMAGE. 35 36env_setup="@env_setup@" 37confdir="@confdir@" 38testdir="@testdir@" 39 40. ${env_setup} 41 42KRB5_CONFIG="${1-${confdir}/krb5.conf}" 43export KRB5_CONFIG 44 45logfile=${testdir}/messages.log 46 47testfailed="echo test failed; cat ${logfile}; exit 1" 48 49# If there is no useful db support compile in, disable test 50${have_db} || exit 77 51 52mkdir -p "${testdir}" 53rm -rf "${testdir}/"* 54 55R=TEST.H5L.SE 56 57port=@port@ 58 59kadmin="${kadmin} -l -r $R" 60kdc="${kdc} --addresses=localhost -P $port" 61 62server=host/datan.test.h5l.se 63cache="FILE:${testdir}/cache.krb5" 64keytabfile=${testdir}/server.keytab 65keytab="FILE:${keytabfile}" 66 67kinit="${kinit} -c $cache" 68klist="${klist} -c $cache" 69kgetcred="${kgetcred} -c $cache" 70kgetcred_imp="${kgetcred} --out-cache=${ocache}" 71kdestroy="${kdestroy} -c $cache" 72 73rm -f ${testdir}/${keytabfile} 74rm -f ${testdir}/current-db* 75rm -f ${testdir}/out-* 76rm -f ${testdir}/mkey.file* 77 78> ${logfile} 79 80echo Creating database 81${kadmin} \ 82 init \ 83 --realm-max-ticket-life=1day \ 84 --realm-max-renewable-life=1month \ 85 ${R} || exit 1 86 87${kadmin} add -p foo --use-defaults fooFOOfooFOOfoo@${R} || exit 1 88${kadmin} add -p kaka --use-defaults ${server}@${R} || exit 1 89${kadmin} ext -k ${keytab} ${server}@${R} || exit 1 90 91echo "Doing database check" 92${kadmin} check ${R} || exit 1 93 94echo foo > ${testdir}/foopassword 95 96echo Starting kdc 97env MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${testdir}/malloc-log \ 98${kdc} & 99kdcpid=$! 100 101sh ${wait_kdc} KDC ${logfile} 102if [ "$?" != 0 ] ; then 103 kill -9 ${kdcpid} 104 exit 1 105fi 106 107trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 108 109ec=0 110 111echo "Getting client initial tickets"; > ${logfile} 112${kinit} --password-file=${testdir}/foopassword fooFOOfooFOOfoo@$R || \ 113 { ec=1 ; eval "${testfailed}"; } 114echo "Getting tickets"; > ${logfile} 115${kgetcred} ${server}@${R} || { ec=1 ; eval "${testfailed}"; } 116echo "Listing tickets"; > ${logfile} 117${klist} > /dev/null || { ec=1 ; eval "${testfailed}"; } 118${test_ap_req} ${server}@${R} ${keytab} ${cache} || \ 119 { ec=1 ; eval "${testfailed}"; } 120${kdestroy} 121 122echo "fuzzer tests" 123 124#${test_gic} --fuzzer=linear-size \ 125# --client=foo@$R --password=foo --debug || \ 126# { echo "fuzzer failed"; exit 1; } 127 128${test_gic} --fuzzer=linear \ 129 --client=fooFOOfooFOOfoo@$R --password=foo --debug || \ 130 { echo "fuzzer failed"; exit 1; } 131 132${test_gic} --fuzzer=random \ 133 --client=fooFOOfooFOOfoo@$R --password=foo --debug || \ 134 { echo "fuzzer failed"; exit 1; } 135 136 137echo "killing kdc (${kdcpid})" 138sh ${leaks_kill} kdc $kdcpid || exit 1 139 140trap "" EXIT 141 142exit $ec 143