3 # Copyright (c) 2006 - 2008 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
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.
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.
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
40 # If there is no useful db support compile in, disable test
41 ..
/db
/have-db ||
exit 77
47 keytabfile
=${objdir}/server.keytab
48 keytab
="FILE:${keytabfile}"
49 nokeytab
="FILE:no-such-keytab"
50 cache
="FILE:krb5ccfile"
52 kinit
="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
53 klist
="${TESTS_ENVIRONMENT} ../../kuser/klist -c $cache"
54 kgetcred
="${TESTS_ENVIRONMENT} ../../kuser/kgetcred -c $cache"
55 kadmin
="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
56 kdc
="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
57 ktutil
="${TESTS_ENVIRONMENT} ../../admin/ktutil"
59 context
="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
61 KRB5_CONFIG
="${objdir}/krb5.conf"
74 echo Creating database
77 --realm-max-ticket-life=1day \
78 --realm-max-renewable-life=1month \
81 # add both lucid and lucid.test.h5l.se to simulate aliases
82 ${kadmin} add
-p p1
--use-defaults host
/lucid.
test.h5l.se@
${R} ||
exit 1
83 ${kadmin} ext -k ${keytab} host/lucid.test.h5l.se@${R} ||
exit 1
84 ${kadmin} add
-p p1
--use-defaults host
/lucid@
${R} ||
exit 1
85 ${kadmin} ext -k ${keytab} host/lucid@${R} ||
exit 1
87 ${kadmin} add
-p p1
--use-defaults host
/ok-delegate.
test.h5l.se@
${R} ||
exit 1
88 ${kadmin} mod
--attributes=+ok-as-delegate host
/ok-delegate.
test.h5l.se@
${R} ||
exit 1
89 ${kadmin} ext -k ${keytab} host/ok-delegate.test.h5l.se@${R} ||
exit 1
92 ${kadmin} add
-p p1
--use-defaults host
/short@
${R} ||
exit 1
93 ${kadmin} mod --alias=host/long.test.h5l.se@${R} host/short@${R} ||
exit 1
94 # XXX ext should ext aliases too
95 ${kadmin} ext -k ${keytab} host/short@${R} ||
exit 1
96 ${ktutil} -k ${keytab} rename --no-delete host/short@${R} host/long.test.h5l.se@${R} ||
exit 1
98 ${kadmin} add -p kaka --use-defaults digest/${R}@${R} ||
exit 1
100 ${kadmin} add
-p u1
--use-defaults user1@
${R} ||
exit 1
102 # Create a server principal with no AES
103 ${kadmin} add
-p p1
--use-defaults host
/no-aes.
test.h5l.se@
${R} ||
exit 1
104 ${kadmin} get host
/no-aes.
test.h5l.se@
${R} > tempfile ||
exit 1
105 ${kadmin} del_enctype host
/no-aes.
test.h5l.se@
${R} \
106 aes256-cts-hmac-sha1-96 aes128-cts-hmac-sha1-96 ||
exit 1
107 ${kadmin} ext -k ${keytab} host/no-aes.test.h5l.se@${R} ||
exit 1
109 echo "Doing database check"
110 ${kadmin} check
${R} ||
exit 1
112 echo u1
> ${objdir}/foopassword
118 sh
${srcdir}/..
/kdc
/wait-kdc.sh
119 if [ "$?" != 0 ] ; then
124 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
128 echo "Getting client initial tickets"
129 ${kinit} --password-file=${objdir}/foopassword --forwardable user1@${R} || exitcode
=1
131 echo "======test unreadable/non existant keytab and its error message"
132 ${context} --mech-type=krb5
host@lucid.
test.h5l.se || \
133 { exitcode
=1 ; echo "test failed"; }
135 mv ${keytabfile} ${keytabfile}.no
137 echo "checking non existant keytabfile (krb5)"
138 ${context} --mech-type=krb5
host@lucid.
test.h5l.se
> test_context.log
2>&1 && \
139 { exitcode
=1 ; echo "test failed"; }
140 grep ${keytabfile} test_context.log
> /dev
/null || \
141 { exitcode
=1 ; echo "string missing failed"; }
142 echo "checking non existant keytabfile (spengo)"
143 ${context} --mech-type=spnego
host@lucid.
test.h5l.se
> test_context.log
2>&1 && \
144 { exitcode
=1 ; echo "test failed"; }
145 grep ${keytabfile} test_context.log
> /dev
/null || \
146 { exitcode
=1 ; echo "string missing failed"; }
148 mv ${keytabfile}.no
${keytabfile}
150 echo "======test naming combinations"
152 ${context} --name-type=hostbased-service
host@lucid.
test.h5l.se || \
153 { exitcode
=1 ; echo "test failed"; }
155 ${context} --name-type=krb5-principal-name host
/lucid.
test.h5l.se@
${R} || \
156 { exitcode
=1 ; echo "test failed"; }
157 echo "plain (krb5 realmless)"
158 ${context} --name-type=krb5-principal-name host
/lucid.
test.h5l.se || \
159 { exitcode
=1 ; echo "test failed"; }
160 echo "dns canon on (long name) OFF, need dns_wrapper"
161 #${context} --dns-canon host@lucid.test.h5l.se || \
162 # { exitcode=1 ; echo "test failed"; }
163 echo "dns canon off (long name)"
164 ${context} --no-dns-canon host@lucid.
test.h5l.se || \
165 { exitcode
=1 ; echo "test failed"; }
166 echo "dns canon off (short name)"
167 ${context} --no-dns-canon host@lucid || \
168 { exitcode
=1 ; echo "test failed"; }
169 echo "dns canon off (short name, krb5)"
170 ${context} --no-dns-canon --name-type=krb5-principal-name host
/lucid@
${R} || \
171 { exitcode
=1 ; echo "test failed"; }
172 echo "dns canon off (short name, krb5)"
173 ${context} --no-dns-canon --name-type=krb5-principal-name host
/lucid || \
174 { exitcode
=1 ; echo "test failed"; }
176 echo "======test context building"
177 for mech
in krb5 krb5iov spnego spnegoiov
; do
178 if [ "$mech" = "krb5iov" ] ; then
182 if [ "$mech" = "spnegoiov" ] ; then
187 echo "${mech} no-mutual ${iov}"
188 ${context} --mech-type=${mech} \
189 --wrapunwrap ${iov} \
190 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
191 { exitcode
=1 ; echo "test failed"; }
193 echo "${mech} mutual ${iov}"
194 ${context} --mech-type=${mech} \
196 --wrapunwrap ${iov} \
197 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
198 { exitcode
=1 ; echo "test failed"; }
200 echo "${mech} delegate ${iov}"
201 ${context} --mech-type=${mech} \
203 --wrapunwrap ${iov} \
204 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
205 { exitcode
=1 ; echo "test failed"; }
207 echo "${mech} mutual delegate ${iov}"
208 ${context} --mech-type=${mech} \
209 --mutual --delegate \
210 --wrapunwrap ${iov} \
211 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
212 { exitcode
=1 ; echo "test failed"; }
215 echo "======dce-style"
216 for mech
in krb5 krb5iov spnego
; do
218 if [ "$mech" = "krb5iov" ] ; then
222 if [ "$mech" = "spnegoiov" ] ; then
227 echo "${mech}: dce-style ${iov}"
229 --mech-type=${mech} \
232 --wrapunwrap ${iov} \
233 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
234 { exitcode
=1 ; echo "test failed"; }
238 echo "test gsskrb5_register_acceptor_identity (both positive and negative)"
240 cp ${keytabfile} ${keytabfile}.new
241 for mech
in krb5 spnego
; do
242 echo "${mech}: acceptor_identity positive"
243 ${context} --gsskrb5-acceptor-identity=${keytabfile}.new \
244 --mech-type=$mech host@lucid.
test.h5l.se || \
245 { exitcode
=1 ; echo "test failed"; }
247 echo "${mech}: acceptor_identity negative"
248 ${context} --gsskrb5-acceptor-identity=${keytabfile}.foo \
249 --mech-type=$mech host@lucid.
test.h5l.se
2>/dev
/null
&& \
250 { exitcode
=1 ; echo "test failed"; }
256 #echo "sasl-digest-md5"
257 #${context} --mech-type=sasl-digest-md5 \
258 # --name-type=hostbased-service \
259 # host@lucid.test.h5l.se || \
260 # { exitcode=1 ; echo "test failed"; }
263 echo "====== gss-api session key check"
265 # this will break when oneone invents a cooler enctype then aes256-cts-hmac-sha1-96
266 coolenctype
="aes256-cts-hmac-sha1-96"
268 echo "Getting client initial tickets"
269 ${kinit} --password-file=${objdir}/foopassword user1@${R} || \
270 { echo "kinit failed"; exitcode
=1; }
272 echo "Building context on cred w/o aes, but still ${coolenctype} session key"
276 --session-enctype=${coolenctype} \
277 --name-type=hostbased-service
host@no-aes.
test.h5l.se || \
278 { exitcode
=1 ; echo "test failed"; }
280 echo "====== ok-as-delegate"
282 echo "Getting client initial tickets"
283 ${kinit} --forwardable \
284 --password-file=${objdir}/foopassword user1@
${R} || exitcode
=1
286 echo "ok-as-delegate not used"
290 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
291 { exitcode
=1 ; echo "test failed"; }
293 echo "host without ok-as-delegate with policy-delegate"
297 --server-no-delegate \
298 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
299 { exitcode
=1 ; echo "test failed"; }
301 echo "ok-as-delegate used by policy"
305 --name-type=hostbased-service
host@ok-delegate.
test.h5l.se || \
306 { exitcode
=1 ; echo "test failed"; }
308 echo "Getting client initial tickets with --ok-as-delgate"
309 ${kinit} --ok-as-delegate --forwardable \
310 --password-file=${objdir}/foopassword user1@
${R} || exitcode
=1
312 echo "policy delegate to non delegate host"
316 --server-no-delegate \
317 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
318 { exitcode
=1 ; echo "test failed"; }
320 echo "ok-as-delegate"
324 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
325 { exitcode
=1 ; echo "test failed"; }
327 echo "======export/import cred"
329 echo "export-import cred (krb5)"
333 --export-import-cred \
334 --name-type=hostbased-service
host@ok-delegate.
test.h5l.se || \
335 { exitcode
=1 ; echo "test failed"; }
337 echo "export-import cred (spnego)"
341 --export-import-cred \
342 --name-type=hostbased-service
host@ok-delegate.
test.h5l.se || \
343 { exitcode
=1 ; echo "test failed"; }
346 echo "======time diffs between client and server"
348 echo "Getting client initial ticket"
349 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode
=1
351 echo "No time offset"
354 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
355 { exitcode
=1 ; echo "test failed"; }
357 echo "Getting client initial ticket"
358 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode
=1
360 echo "Server time offset"
364 --server-time-offset=3600 \
366 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
367 { exitcode
=1 ; echo "test failed"; }
369 echo "Server time offset (cached ?)"
373 --server-time-offset=3600 \
375 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
376 { exitcode
=1 ; echo "test failed"; }
378 echo "Getting client initial ticket"
379 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode
=1
380 # Pre-poplute the cache since tgs-req will fail since our time is wrong
381 ${kgetcred} host
/lucid.
test.h5l.se@
${R} || exitcode
=1
383 echo "Client time offset"
387 --client-time-offset=3600 \
388 --name-type=hostbased-service
host@lucid.
test.h5l.se || \
389 { exitcode
=1 ; echo "test failed"; }
391 echo "Getting client initial tickets (use-referrals)"
393 --password-file=${objdir}/foopassword \
394 --use-referrals user1@
${R} || exitcode
=1
396 # XXX these tests really need to use somethat that resolve to something
400 { exitcode
=1 ; echo "test failed"; }
404 --name-type=krb5-principal-name host
/short || \
405 { exitcode
=1 ; echo "test failed"; }
409 host@long.
test.h5l.se || \
410 { exitcode
=1 ; echo "test failed"; }
414 --name-type=krb5-principal-name \
415 host
/long.
test.h5l.se || \
416 { exitcode
=1 ; echo "test failed"; }
420 echo "killing kdc (${kdcpid})"
421 kill ${kdcpid} 2> /dev
/null
423 [ "$exitcode" = 0 ] && echo "all ok"