]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - crypto/heimdal/tests/gss/check-spnego.in
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / crypto / heimdal / tests / gss / check-spnego.in
1 #!/bin/sh
2 #
3 # Copyright (c) 2006 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: check-spnego.in 21847 2007-08-08 06:55:32Z lha $
35 #
36
37 srcdir="@srcdir@"
38 objdir="@objdir@"
39
40 # If there is no useful db support compile in, disable test
41 ../db/have-db || exit 77
42
43 R=TEST.H5L.SE
44
45 port=@port@
46
47 keytabfile=${objdir}/server.keytab
48 keytab="FILE:${keytabfile}"
49 cache="FILE:krb5ccfile"
50 cacheds="FILE:krb5ccfile-ds"
51
52 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
53 kinitds="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cacheds --no-afslog"
54 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
55 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
56
57 context="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
58
59 KRB5_CONFIG="${objdir}/krb5.conf"
60 export KRB5_CONFIG
61
62 KRB5_KTNAME="${keytab}"
63 export KRB5_KTNAME
64 KRB5CCNAME="${cache}"
65 export KRB5CCNAME
66 NTLM_ACCEPTOR_CCACHE="${cacheds}"
67 export NTLM_ACCEPTOR_CCACHE
68 NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt"
69 export NTLM_USER_FILE
70
71 GSSAPI_SPNEGO_NAME=host@host.test.h5l.se
72 export GSSAPI_SPNEGO_NAME
73
74 rm -f ${keytabfile}
75 rm -f current-db*
76 rm -f out-*
77 rm -f mkey.file*
78
79 > messages.log
80
81 echo Creating database
82 ${kadmin} \
83     init \
84     --realm-max-ticket-life=1day \
85     --realm-max-renewable-life=1month \
86     ${R} || exit 1
87
88 ${kadmin} add -p p1 --use-defaults host/host.test.h5l.se@${R} || exit 1
89 ${kadmin} ext -k ${keytab} host/host.test.h5l.se@${R} || exit 1
90
91 ${kadmin} add -p kaka --use-defaults digest/${R}@${R} || exit 1
92
93 ${kadmin} add -p ds --use-defaults digestserver@${R} || exit 1
94 ${kadmin} modify --attributes=+allow-digest digestserver@${R} || exit 1
95
96 ${kadmin} add -p u1 --use-defaults user1@${R} || exit 1
97
98 echo "Doing database check"
99 ${kadmin} check ${R} || exit 1
100
101 echo u1 > ${objdir}/foopassword
102 echo ds > ${objdir}/barpassword
103
104 echo Starting kdc
105 ${kdc} &
106 kdcpid=$!
107
108 sh ${srcdir}/../kdc/wait-kdc.sh
109 if [ "$?" != 0 ] ; then
110     kill ${kdcpid}
111     exit 1
112 fi
113
114 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
115
116 exitcode=0
117
118 echo "Getting client initial tickets"
119 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode=1
120 echo "Getting digestserver initial tickets"
121 ${kinitds} --password-file=${objdir}/barpassword digestserver@${R} || exitcode=1
122
123 echo "======context building for each mech"
124
125 for mech in ntlm krb5 ; do 
126     echo "${mech}"
127     ${context} --mech-type=${mech} --ret-mech-type=${mech} \
128         --name-type=hostbased-service host@host.test.h5l.se || \
129         { exitcode=1 ; echo test failed; }
130 done
131
132 echo "spnego"
133 ${context} \
134     --mech-type=spnego \
135     --ret-mech-type=krb5 \
136     --name-type=hostbased-service \
137     host@host.test.h5l.se || \
138     { exitcode=1 ; echo test failed; }
139
140 echo "test failure cases"
141 ${context} --mech-type=ntlm --ret-mech-type=krb5 \
142     --name-type=hostbased-service host@host.test.h5l.se 2> /dev/null && \
143     { exitcode=1 ; echo test failed; }
144
145 ${context} --mech-type=krb5 --ret-mech-type=ntlm \
146     --name-type=hostbased-service host@host.test.h5l.se 2> /dev/null && \
147     { exitcode=1 ; echo test failed; }
148
149 echo "======spnego variants context building"
150
151 for arg in \
152      "" \
153      "--mutual" \
154      "--delegate" \
155      "--mutual --delegate" \
156      "--getverifymic --wrapunwrap" \
157      "--mutual --getverifymic --wrapunwrap" \
158     ; do
159
160     echo "no NTLM acceptor cred ${arg}"
161     NTLM_ACCEPTOR_CCACHE="${cacheds}-no"
162     ${context} --mech-type=spnego \
163         $arg \
164         --name-type=hostbased-service \
165         --ret-mech-type=krb5  \
166         host@host.test.h5l.se || \
167         { exitcode=1 ; echo test failed; }
168     NTLM_ACCEPTOR_CCACHE="${cacheds}"
169
170     echo "no NTLM initiator cred ${arg}"
171     NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt-no"
172     ${context} --mech-type=spnego \
173         $arg \
174         --name-type=hostbased-service \
175         --ret-mech-type=krb5 \
176         host@host.test.h5l.se || \
177         { exitcode=1 ; echo test failed; }
178     NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt"
179
180     echo "no krb5 acceptor cred ${arg}"
181     KRB5_KTNAME="${keytab}-no"
182     ${context} --mech-type=spnego \
183         $arg \
184         --name-type=hostbased-service \
185         --ret-mech-type=ntlm \
186         host@host.test.h5l.se || \
187         { exitcode=1 ; echo test failed; }
188     KRB5_KTNAME="${keytab}"
189
190     echo "no krb5 initiator cred ${arg}"
191     KRB5CCNAME="${cache}-no"
192     ${context} --mech-type=spnego \
193         $arg \
194         --name-type=hostbased-service \
195         --ret-mech-type=ntlm \
196         host@host.test.h5l.se || \
197         { exitcode=1 ; echo test failed; }
198     KRB5CCNAME="${cache}"
199
200 done
201
202 trap "" EXIT
203
204 echo "killing kdc (${kdcpid})"
205 kill ${kdcpid} 2> /dev/null
206
207 exit $exitcode
208
209