1#!/bin/sh 2# 3# Copyright (c) 2007 Kungliga Tekniska Högskolan 4# (Royal Institute of Technology, Stockholm, Sweden). 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 11# 1. Redistributions of source code must retain the above copyright 12# notice, this list of conditions and the following disclaimer. 13# 14# 2. Redistributions in binary form must reproduce the above copyright 15# notice, this list of conditions and the following disclaimer in the 16# documentation and/or other materials provided with the distribution. 17# 18# 3. Neither the name of the Institute nor the names of its contributors 19# may be used to endorse or promote products derived from this software 20# without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 23# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 26# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32# SUCH DAMAGE. 33# 34# Id 35# 36 37srcdir="@srcdir@" 38objdir="@objdir@" 39 40# If there is no useful db support compile in, disable test 41../db/have-db || exit 77 42 43R=TEST.H5L.SE 44 45port=@port@ 46 47keytabfile=${objdir}/server.keytab 48keytab="FILE:${keytabfile}" 49nokeytab="FILE:no-such-keytab" 50cache="FILE:krb5ccfile" 51cache2="FILE:krb5ccfile2" 52nocache="FILE:no-such-cache" 53 54kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache ${afs_no_afslog}" 55kdestroy="${TESTS_ENVIRONMENT} ../../kuser/kdestroy -c $cache ${afs_no_unlog}" 56klist="${TESTS_ENVIRONMENT} ../../kuser/klist -c $cache" 57kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R" 58kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port" 59 60acquire_cred="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_acquire_cred" 61test_kcred="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_kcred" 62 63KRB5_CONFIG="${objdir}/krb5.conf" 64export KRB5_CONFIG 65 66KRB5_KTNAME="${keytab}" 67export KRB5_KTNAME 68KRB5CCNAME="${cache}" 69export KRB5CCNAME 70 71rm -f ${keytabfile} 72rm -f current-db* 73rm -f out-* 74rm -f mkey.file* 75 76> messages.log 77 78echo Creating database 79${kadmin} \ 80 init \ 81 --realm-max-ticket-life=1day \ 82 --realm-max-renewable-life=1month \ 83 ${R} || exit 1 84 85echo upw > ${objdir}/foopassword 86 87${kadmin} add -p upw --use-defaults user@${R} || exit 1 88${kadmin} add -p upw --use-defaults another@${R} || exit 1 89${kadmin} add -p p1 --use-defaults host/host.test.h5l.se@${R} || exit 1 90${kadmin} ext -k ${keytab} host/host.test.h5l.se@${R} || exit 1 91 92echo "Doing database check" 93${kadmin} check ${R} || exit 1 94 95echo Starting kdc 96${kdc} & 97kdcpid=$! 98 99sh ${srcdir}/../kdc/wait-kdc.sh 100if [ "$?" != 0 ] ; then 101 kill ${kdcpid} 102 exit 1 103fi 104 105trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT 106 107exitcode=0 108 109echo "initial ticket" 110${kinit} --password-file=${objdir}/foopassword user@${R} || exitcode=1 111 112echo "keytab" 113${acquire_cred} \ 114 --acquire-type=accept \ 115 --acquire-name=host@host.test.h5l.se || exit 1 116 117echo "keytab w/o name" 118${acquire_cred} \ 119 --acquire-type=accept || exit 1 120 121echo "keytab w/ wrong name" 122${acquire_cred} \ 123 --acquire-type=accept \ 124 --acquire-name=host@host2.test.h5l.se 2>/dev/null && exit 1 125 126echo "init using keytab" 127${acquire_cred} \ 128 --acquire-type=initiate \ 129 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1 130 131echo "init using keytab (loop 10)" 132${acquire_cred} \ 133 --acquire-type=initiate \ 134 --loops=10 \ 135 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1 136 137echo "init using keytab (loop 10, target)" 138${acquire_cred} \ 139 --acquire-type=initiate \ 140 --loops=10 \ 141 --target=host@host.test.h5l.se \ 142 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1 143 144echo "init using keytab (loop 10, kerberos)" 145${acquire_cred} \ 146 --acquire-type=initiate \ 147 --loops=10 \ 148 --kerberos \ 149 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1 150 151echo "init using keytab (loop 10, target, kerberos)" 152${acquire_cred} \ 153 --acquire-type=initiate \ 154 --loops=10 \ 155 --kerberos \ 156 --target=host@host.test.h5l.se \ 157 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1 158 159echo "init using existing cc" 160${acquire_cred} \ 161 --name-type=user-name \ 162 --acquire-type=initiate \ 163 --acquire-name=user || exit 1 164 165KRB5CCNAME=${nocache} 166 167echo "fail init using existing cc" 168${acquire_cred} \ 169 --name-type=user-name \ 170 --acquire-type=initiate \ 171 --acquire-name=user 2>/dev/null && exit 1 172 173echo "use gss_krb5_ccache_name for user" 174${acquire_cred} \ 175 --name-type=user-name \ 176 --ccache=${cache} \ 177 --acquire-type=initiate \ 178 --acquire-name=user >/dev/null || exit 1 179 180KRB5CCNAME=${cache} 181KRB5_KTNAME=${nokeytab} 182 183echo "kcred" 184${test_kcred} || exit 1 185 186${kdestroy} 187 188KRB5_KTNAME="${keytab}" 189 190echo "init using keytab" 191${acquire_cred} \ 192 --acquire-type=initiate \ 193 --acquire-name=host@host.test.h5l.se 2>/dev/null || exit 1 194 195echo "init using keytab (ccache)" 196${acquire_cred} \ 197 --acquire-type=initiate \ 198 --ccache=${cache} \ 199 --acquire-name=host@host.test.h5l.se 2>/dev/null || exit 1 200 201trap "" EXIT 202 203echo "killing kdc (${kdcpid})" 204kill ${kdcpid} 2> /dev/null 205 206exit $exitcode 207