3 # Copyright (c) 2007 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
37 env_setup
="@env_setup@"
43 # If there is no useful db support compiled in, disable test
44 ..
/db
/have-db ||
exit 77
50 keytabfile
=${objdir}/server.keytab
51 keytab
="FILE:${keytabfile}"
52 nokeytab
="FILE:no-such-keytab"
53 cache
="FILE:krb5ccfile"
54 cache2
="FILE:krb5ccfile2"
55 nocache
="FILE:no-such-cache"
57 kadmin
="${kadmin} -l -r $R"
58 kdc
="${kdc} --addresses=localhost -P $port"
60 acquire_cred
="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_acquire_cred"
61 test_kcred
="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_kcred"
62 test_add_store_cred
="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_add_store_cred"
64 KRB5_CONFIG
="${objdir}/krb5.conf"
67 KRB5_KTNAME
="${keytab}"
79 echo upw
> ${objdir}/foopassword
81 echo Creating database
82 ${kadmin} <<EOF || exit 1
83 init --realm-max-ticket-life=1day --realm-max-renewable-life=1month ${R}
84 add -p upw --use-defaults user@${R}
85 add -p upw --use-defaults another@${R}
86 add -p p1 --use-defaults host/host.test.h5l.se@${R}
87 ext -k ${keytab} host/host.test.h5l.se@${R}
92 ${kdc} --detach --testing ||
{ echo "kdc failed to start"; cat messages.log
; exit 1; }
96 echo signal killing kdc
102 trap cleanup EXIT INT TERM
106 echo "initial ticket"
107 ${kinit} -c ${cache} --password-file=${objdir}/foopassword user@${R} || exitcode
=1
109 echo "copy ccache with gss_store_cred"
110 # Note we test that the ccache used for storing is token-expanded
111 ${test_add_store_cred} --default --overwrite --env ${cache} "${cache2}%{null}" || exit 1
112 ${klist} -c ${cache2} || exit 1
116 --acquire-type=accept \
117 --acquire-name=host@host.test.h5l.se || exit 1
119 echo "keytab w
/ short-form name and name canon rules
"
121 --acquire-type=accept \
122 --acquire-name=host@host || exit 1
124 echo "keytab w
/o name
"
126 --acquire-type=accept || exit 1
128 echo "keytab w
/ wrong name
"
130 --acquire-type=accept --kerberos \
131 --acquire-name=host@host2.test.h5l.se 2>/dev/null && exit 1
133 echo "init using keytab
"
136 --acquire-type=initiate \
137 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1
139 echo "init using keytab
(loop
10)"
142 --acquire-type=initiate \
144 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1
146 echo "init using keytab
(loop
10, target
)"
149 --acquire-type=initiate \
151 --target=host@host.test.h5l.se \
152 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1
154 echo "init using keytab
(loop
10, kerberos
)"
156 --acquire-type=initiate \
159 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1
161 echo "init using keytab
(loop
10, target
, kerberos
)"
163 --acquire-type=initiate \
166 --target=host@host.test.h5l.se \
167 --acquire-name=host@host.test.h5l.se > /dev/null || exit 1
169 echo "init using existing cc
"
172 --name-type=user-name \
173 --acquire-type=initiate \
174 --acquire-name=user || exit 1
176 KRB5CCNAME=${nocache}
178 echo "fail init using existing cc
"
181 --name-type=user-name \
182 --acquire-type=initiate \
183 --acquire-name=user 2>/dev/null && exit 1
185 echo "use gss_krb5_ccache_name
for user
"
188 --name-type=user-name \
190 --acquire-type=initiate \
191 --acquire-name=user >/dev/null || exit 1
194 KRB5_KTNAME=${nokeytab}
197 ${test_kcred} || exit 1
199 ${kdestroy} -c ${cache}
201 KRB5_KTNAME="${keytab}"
203 echo "init using keytab
"
206 --acquire-type=initiate \
207 --acquire-name=host@host.test.h5l.se 2>/dev/null || exit 1
209 echo "init using keytab
(ccache
)"
212 --acquire-type=initiate \
214 --acquire-name=host@host.test.h5l.se 2>/dev/null || exit 1
218 echo "killing kdc
(${kdcpid})"
219 kill ${kdcpid} 2> /dev/null