3 # Copyright (c) 2006 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 cache
="FILE:krb5ccfile"
53 cacheds
="FILE:krb5ccfile-ds"
55 kinit
="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache ${afs_no_afslog} --forwardable"
56 kinitds
="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cacheds ${afs_no_afslog}"
57 kadmin
="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
58 kdc
="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
60 context
="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
62 KRB5_CONFIG
="${objdir}/krb5.conf"
66 KRB5_KTNAME
="${keytab}"
70 NTLM_ACCEPTOR_CCACHE
="${cacheds}"
71 export NTLM_ACCEPTOR_CCACHE
72 NTLM_USER_FILE
="${srcdir}/ntlm-user-file.txt"
75 GSSAPI_SPNEGO_NAME
=host@
host.
test.h5l.se
76 export GSSAPI_SPNEGO_NAME
85 echo Creating database
86 ${kadmin} <<EOF || exit 1
87 init --realm-max-ticket-life=1day --realm-max-renewable-life=1month ${R}
88 add -p p1 --use-defaults host/host.test.h5l.se@${R}
89 ext -k ${keytab} host/host.test.h5l.se@${R}
90 add -p kaka --use-defaults digest/${R}@${R}
91 add -p ds --use-defaults digestserver@${R}
92 modify --attributes=+allow-digest digestserver@${R}
93 add -p u1 --use-defaults user1@${R}
97 echo u1
> ${objdir}/foopassword
98 echo ds
> ${objdir}/barpassword
101 ${kdc} --detach --testing ||
{ echo "kdc failed to start"; cat messages.log
; exit 1; }
105 echo signal killing kdc
107 trap '' EXIT INT TERM
111 trap cleanup EXIT INT TERM
115 echo "Getting client initial tickets"
116 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode
=1
117 echo "Getting digestserver initial tickets"
118 ${kinitds} --password-file=${objdir}/barpassword digestserver@${R} || exitcode
=1
120 echo "======context building for each mech"
122 for mech
in ntlm krb5
; do
124 ${context} --mech-type=${mech} --ret-mech-type=${mech} \
125 --client-ccache="${cache}" \
126 --gsskrb5-acceptor-identity="${keytab}" \
127 --name-type=hostbased-service
host@
host.
test.h5l.se || \
128 { exitcode
=1 ; echo test failed
; }
133 --client-ccache="${cache}" \
135 --ret-mech-type=krb5 \
136 --name-type=hostbased-service \
137 --export-import-context \
138 host@
host.
test.h5l.se || \
139 { exitcode
=1 ; echo test failed
; }
141 echo "spnego (split tokens)"
144 --client-ccache="${cache}" \
146 --ret-mech-type=krb5 \
147 --name-type=hostbased-service \
148 --export-import-context \
149 host@
host.
test.h5l.se || \
150 { exitcode
=1 ; echo test failed
; }
152 echo "test failure cases"
153 ${context} --mech-type=ntlm
--ret-mech-type=krb5 \
154 --client-ccache="${cache}" \
155 --name-type=hostbased-service
host@
host.
test.h5l.se
2> /dev
/null
&& \
156 { exitcode
=1 ; echo test failed
; }
158 ${context} --mech-type=krb5
--ret-mech-type=ntlm \
159 --client-ccache="${cache}" \
160 --name-type=hostbased-service
host@
host.
test.h5l.se
2> /dev
/null
&& \
161 { exitcode
=1 ; echo test failed
; }
163 echo "======spnego variants context building"
169 "--mutual --delegate" \
170 "--getverifymic --wrapunwrap" \
171 "--mutual --getverifymic --wrapunwrap" \
174 echo "no NTLM acceptor cred ${arg}"
175 NTLM_ACCEPTOR_CCACHE
="${cacheds}-no"
176 ${context} --mech-type=spnego \
178 --name-type=hostbased-service \
179 --ret-mech-type=krb5 \
180 host@
host.
test.h5l.se || \
181 { exitcode
=1 ; echo test failed
; }
182 NTLM_ACCEPTOR_CCACHE
="${cacheds}"
184 echo "no NTLM initiator cred ${arg}"
185 NTLM_USER_FILE
="${srcdir}/ntlm-user-file.txt-no"
186 ${context} --mech-type=spnego \
188 --name-type=hostbased-service \
189 --ret-mech-type=krb5 \
190 host@
host.
test.h5l.se || \
191 { exitcode
=1 ; echo test failed
; }
192 NTLM_USER_FILE
="${srcdir}/ntlm-user-file.txt"
194 echo "no krb5 acceptor cred ${arg}"
195 KRB5_KTNAME
="${keytab}-no"
196 ${context} --mech-type=spnego \
198 --server-no-delegate \
199 --name-type=hostbased-service \
200 --ret-mech-type=ntlm \
201 host@
host.
test.h5l.se || \
202 { exitcode
=1 ; echo test failed
; }
203 KRB5_KTNAME
="${keytab}"
205 echo "no explicit krb5 acceptor cred ${arg}"
206 ${context} --mech-type=spnego \
208 --gsskrb5-acceptor-identity="${keytab}-no" \
209 --server-no-delegate \
210 --name-type=hostbased-service \
211 --ret-mech-type=krb5 \
212 host@
host.
test.h5l.se
2>/dev
/null
&& \
213 { exitcode
=1 ; echo test failed
; }
215 echo "no krb5 initiator cred ${arg}"
216 KRB5CCNAME
="${cache}-no"
217 ${context} --mech-type=spnego \
219 --server-no-delegate \
220 --name-type=hostbased-service \
221 --ret-mech-type=ntlm \
222 host@
host.
test.h5l.se || \
223 { exitcode
=1 ; echo test failed
; }
224 KRB5CCNAME
="${cache}"
226 echo "no explicit krb5 initiator cred ${arg}"
227 ${context} --mech-type=spnego \
229 --client-ccache="${cache}-no" \
230 --server-no-delegate \
231 --name-type=hostbased-service \
232 --ret-mech-type=krb5 \
233 host@
host.
test.h5l.se
2>/dev
/null
&& \
234 { exitcode
=1 ; echo test failed
; }
240 echo "killing kdc (${kdcpid})"
241 kill ${kdcpid} 2> /dev
/null