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 40if [ "$UID" != 0 ] ; then 41 echo "must run script as root since it create users" 42 exit 1 43fi 44 45u=heimdaltestuser 46r=WELLKNOWN:COM.APPLE.LKDC 47 48. ${env_setup} 49 50KRB5_CONFIG="${1-${confdir}/krb5.conf}" 51export KRB5_CONFIG 52 53logfile=${testdir}/messages.log 54cache="FILE:${testdir}/cache.krb5" 55 56testfailed="echo test failed; cat ${logfile}; exit 1" 57 58kdc="${kdc} --addresses=localhost" 59 60kinit="${kinit} -c $cache" 61klist="${klist} -c $cache" 62kgetcred="${kgetcred} -c $cache" 63kdestroy="${kdestroy} -c $cache" 64 65rm -f ${testdir}/out-* 66 67> ${logfile} 68 69dscl . -delete /Users/$u > /dev/null 2>/dev/null 70dscl . -create /Users/$u || exit 1 71dscl . -append /Users/$u RealName "Heimdal testuser" || exit 1 72 73$hodadmin . principal-delete $ u> /dev/null 2>/dev/null 74$hodadmin . principal-create $u || exit 1 75$hodadmin . password $u foo || exit 1 76$hodadmin . password $u foo || exit 1 77$hodadmin . principal-clearflags $u Invalid Forwardable || exit 1 78$hodadmin . principal-setflags $u Forwardable || exit 1 79 80echo foo > ${testdir}/foopassword 81 82echo Starting kdc 83env MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${testdir}/malloc-log \ 84${kdc} & 85kdcpid=$! 86 87sh ${wait_kdc} KDC ${logfile} 88if [ "$?" != 0 ] ; then 89 kill -9 ${kdcpid} 90 exit 1 91fi 92 93trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 94 95ec=0 96 97echo "Getting client initial tickets ${a}"; > ${logfile} 98${kinit} --kdc-hostname=localhost --canon --password-file=${testdir}/foopassword ${u}@${r} || \ 99 { ec=1 ; eval "${testfailed}"; } 100echo "Getting tickets"; > ${logfile} 101${kgetcred} host/${r}@${r} || { ec=1 ; eval "${testfailed}"; } 102echo "Listing tickets"; > ${logfile} 103${klist} > /dev/null || { ec=1 ; eval "${testfailed}"; } 104${kdestroy} 105 106echo "killing kdc (${kdcpid})" 107sh ${leaks_kill} kdc $kdcpid || exit 1 108 109dscl localhost -delete /Users/$u 110 111trap "" EXIT 112 113exit $ec 114