3 # Copyright (c) 2011, Secure Endpoints Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
10 # - Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in
15 # the documentation and/or other materials provided with the
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 # OF THE POSSIBILITY OF SUCH DAMAGE.
31 env_setup
="@env_setup@"
36 # If there is no useful db support compile in, disable test
37 # (krb5_kt_get_entry() is tested in another test)
46 kadmin
="${kadmin} -l -r ${R1}"
47 kdc
="${kdc} --addresses=localhost -P $port"
49 cache
="FILE:${objdir}/cache.krb5"
51 kinit
="${kinit} -c $cache ${afs_no_afslog}"
52 klist
="${klist} -c $cache"
53 kgetcred
="${kgetcred} -c $cache"
54 kdestroy
="${kdestroy} -c $cache ${afs_no_unlog}"
56 KRB5_CONFIG
="${objdir}/krb5-canon.conf"
59 testfailed
="echo test failed; ${klist}; exit 1"
68 echo "Creating database"
69 initflags
="init --realm-max-ticket-life=1day --realm-max-renewable-life=1month"
71 ${kadmin} ${initflags} ${R1} ||
exit 1
72 ${kadmin} ${initflags} ${R2} ||
exit 1
73 ${kadmin} ${initflags} ${R3} ||
exit 1
75 ${kadmin} add
-p foo
--use-defaults foo@
${R1} ||
exit 1
77 ${kadmin} add -p cross1 --use-defaults krbtgt/${R1}@${R2} ||
exit 1
78 ${kadmin} add -p cross2 --use-defaults krbtgt/${R2}@${R1} ||
exit 1
79 ${kadmin} add -p cross3 --use-defaults krbtgt/${R3}@${R1} ||
exit 1
80 ${kadmin} add -p cross4 --use-defaults krbtgt/${R1}@${R3} ||
exit 1
81 ${kadmin} add -p cross5 --use-defaults krbtgt/${R3}@${R2} ||
exit 1
82 ${kadmin} add -p cross6 --use-defaults krbtgt/${R2}@${R3} ||
exit 1
84 ${kadmin} add
-p foo
--use-defaults host
/t1@
${R1} ||
exit 1
85 ${kadmin} add
-p foo
--use-defaults host
/t2@
${R2} ||
exit 1
86 ${kadmin} add
-p foo
--use-defaults host
/t3@
${R3} ||
exit 1
87 ${kadmin} add
-p foo
--use-defaults host
/t11.test1.h5l.se@
${R1} ||
exit 1
88 ${kadmin} add
-p foo
--use-defaults host
/t12.test1.h5l.se@
${R2} ||
exit 1
89 ${kadmin} add
-p foo
--use-defaults host
/t22.test2.h5l.se@
${R2} ||
exit 1
90 ${kadmin} add
-p foo
--use-defaults host
/t23.test2.h5l.se@
${R3} ||
exit 1
91 ${kadmin} add
-p foo
--use-defaults host
/t33.test3.h5l.se@
${R3} ||
exit 1
94 echo "Doing database check"
95 ${kadmin} check
${R1} ||
exit 1
96 ${kadmin} check
${R2} ||
exit 1
97 ${kadmin} check
${R3} ||
exit 1
99 echo foo
> ${objdir}/foopassword
101 echo "Starting kdc" ; > messages.log
106 if [ "$?" != 0 ] ; then
111 trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
115 echo "Getting client initial tickets";
116 ${kinit} --password-file=${objdir}/foopassword foo@${R1} || \
117 { ec
=1 ; eval "${testfailed}"; }
119 echo "get service tickets (success)"
120 for host in t1 t2 t3 t11 t12 t22 t33
; do
122 ${kgetcred} --name-type=SRV_HST host $host || { ec=1 ; eval "${testfailed}"; }
124 echo "get service tickets (failure)"
127 ${kgetcred} --name-type=SRV_HST host $host 2>/dev/null && { ec=1 ; eval "${testfailed}"; }
131 ${klist} |
grep 'host/t1@$' > /dev
/null ||
132 { ec
=1 ; echo "t1 referral entry not present"; eval "${testfailed}"; }
133 ${klist} |
grep "host/t1@${R1}" > /dev
/null ||
134 { ec
=1 ; echo "canonicalized t1 entry not present"; eval "${testfailed}"; }
135 ${klist} |
grep 'host/t2@$' > /dev
/null ||
136 { ec
=1 ; echo "t2 referral entry not present"; eval "${testfailed}"; }
137 ${klist} |
grep "host/t2@${R2}" > /dev
/null ||
138 { ec
=1 ; echo "canonicalized t2 entry not present"; eval "${testfailed}"; }
139 ${klist} |
grep 'host/t3@$' > /dev
/null ||
140 { ec
=1 ; echo "t3 referral entry not present"; eval "${testfailed}"; }
141 ${klist} |
grep "host/t3@${R3}" > /dev
/null ||
142 { ec
=1 ; echo "canonicalized t3 entry not present"; eval "${testfailed}"; }
143 ${klist} |
grep 'host/t11@$' > /dev
/null ||
144 { ec
=1 ; echo "t11 referral entry not present"; eval "${testfailed}"; }
145 ${klist} |
grep "host/t11.test1.h5l.se@${R1}" > /dev
/null ||
146 { ec
=1 ; echo "canonicalized t11 entry not present"; eval "${testfailed}"; }
147 ${klist} |
grep 'host/t12@$' > /dev
/null ||
148 { ec
=1 ; echo "t12 referral entry not present"; eval "${testfailed}"; }
149 ${klist} |
grep "host/t12.test1.h5l.se@${R2}" > /dev
/null ||
150 { ec
=1 ; echo "canonicalized t12 entry not present"; eval "${testfailed}"; }
151 ${klist} |
grep 'host/t22@$' > /dev
/null ||
152 { ec
=1 ; echo "t22 referral entry not present"; eval "${testfailed}"; }
153 ${klist} |
grep "host/t22.test2.h5l.se@${R2}" > /dev
/null ||
154 { ec
=1 ; echo "canonicalized t22 entry not present"; eval "${testfailed}"; }
155 ${klist} |
grep 'host/t33@$' > /dev
/null ||
156 { ec
=1 ; echo "t33 referral entry not present"; eval "${testfailed}"; }
157 ${klist} |
grep "host/t33.test3.h5l.se@${R3}" > /dev
/null ||
158 { ec
=1 ; echo "canonicalized t33 entry not present"; eval "${testfailed}"; }
165 # This may not be portable. It'd be nice to be able to set more of the
166 # resolver configuration via the environment!
167 LOCALDOMAIN
=test1.h5l.se
169 KRB5_CONFIG
="${objdir}/krb5-canon2.conf"
172 echo "Getting client initial tickets (round 2)";
173 ${kinit} --password-file=${objdir}/foopassword foo@${R1} || \
174 { ec
=1 ; eval "${testfailed}"; }
176 echo "get service tickets (success)"
177 for host in t1 t2 t3 t11
; do
179 ${kgetcred} --name-type=SRV_HST host $host || { ec=1 ; eval "${testfailed}"; }
181 echo "get service tickets (failure)"
182 for host in t12 t22 t23 t33
; do
184 ${kgetcred} --name-type=SRV_HST
host $host 2> /dev
/null
&&
185 { ec
=1 ; eval "${testfailed}"; }
189 ${klist} |
grep 'host/t1@$' > /dev
/null ||
190 { ec
=1 ; echo "t1 referral entry not present"; eval "${testfailed}"; }
191 ${klist} |
grep "host/t1@${R1}" > /dev
/null ||
192 { ec
=1 ; echo "canonicalized t1 entry not present"; eval "${testfailed}"; }
193 ${klist} |
grep 'host/t2@$' > /dev
/null ||
194 { ec
=1 ; echo "t2 referral entry not present"; eval "${testfailed}"; }
195 ${klist} |
grep "host/t2@${R2}" > /dev
/null ||
196 { ec
=1 ; echo "canonicalized t2 entry not present"; eval "${testfailed}"; }
197 ${klist} |
grep 'host/t3@$' > /dev
/null ||
198 { ec
=1 ; echo "t3 referral entry not present"; eval "${testfailed}"; }
199 ${klist} |
grep "host/t3@${R3}" > /dev
/null ||
200 { ec
=1 ; echo "canonicalized t3 entry not present"; eval "${testfailed}"; }
201 ${klist} |
grep 'host/t11@$' > /dev
/null ||
202 { ec
=1 ; echo "t11 referral entry not present"; eval "${testfailed}"; }
203 ${klist} |
grep "host/t11.test1.h5l.se@${R1}" > /dev
/null ||
204 { ec
=1 ; echo "canonicalized t11 entry not present"; eval "${testfailed}"; }
211 echo "killing kdc (${kdcpid})"
212 sh
${leaks_kill} kdc
$kdcpid ||
exit 1