Sync usage with man page.
[netbsd-mini2440.git] / crypto / dist / heimdal / tests / gss / check-spnego.in
blob517b6b8ed5181cdfa6c3b54793903f0653ec7006
1 #!/bin/sh
3 # Copyright (c) 2006 Kungliga Tekniska Högskolan
4 # (Royal Institute of Technology, Stockholm, Sweden).
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
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
32 # SUCH DAMAGE.
34 # $Heimdal: check-spnego.in 21847 2007-08-08 06:55:32Z lha $
35 # $NetBSD$
38 srcdir="@srcdir@"
39 objdir="@objdir@"
41 # If there is no useful db support compile in, disable test
42 ../db/have-db || exit 77
44 R=TEST.H5L.SE
46 port=@port@
48 keytabfile=${objdir}/server.keytab
49 keytab="FILE:${keytabfile}"
50 cache="FILE:krb5ccfile"
51 cacheds="FILE:krb5ccfile-ds"
53 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
54 kinitds="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cacheds --no-afslog"
55 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
56 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
58 context="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_context"
60 KRB5_CONFIG="${objdir}/krb5.conf"
61 export KRB5_CONFIG
63 KRB5_KTNAME="${keytab}"
64 export KRB5_KTNAME
65 KRB5CCNAME="${cache}"
66 export KRB5CCNAME
67 NTLM_ACCEPTOR_CCACHE="${cacheds}"
68 export NTLM_ACCEPTOR_CCACHE
69 NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt"
70 export NTLM_USER_FILE
72 GSSAPI_SPNEGO_NAME=host@host.test.h5l.se
73 export GSSAPI_SPNEGO_NAME
75 rm -f ${keytabfile}
76 rm -f current-db*
77 rm -f out-*
78 rm -f mkey.file*
80 > messages.log
82 echo Creating database
83 ${kadmin} \
84 init \
85 --realm-max-ticket-life=1day \
86 --realm-max-renewable-life=1month \
87 ${R} || exit 1
89 ${kadmin} add -p p1 --use-defaults host/host.test.h5l.se@${R} || exit 1
90 ${kadmin} ext -k ${keytab} host/host.test.h5l.se@${R} || exit 1
92 ${kadmin} add -p kaka --use-defaults digest/${R}@${R} || exit 1
94 ${kadmin} add -p ds --use-defaults digestserver@${R} || exit 1
95 ${kadmin} modify --attributes=+allow-digest digestserver@${R} || exit 1
97 ${kadmin} add -p u1 --use-defaults user1@${R} || exit 1
99 echo "Doing database check"
100 ${kadmin} check ${R} || exit 1
102 echo u1 > ${objdir}/foopassword
103 echo ds > ${objdir}/barpassword
105 echo Starting kdc
106 ${kdc} &
107 kdcpid=$!
109 sh ${srcdir}/../kdc/wait-kdc.sh
110 if [ "$?" != 0 ] ; then
111 kill ${kdcpid}
112 exit 1
115 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
117 exitcode=0
119 echo "Getting client initial tickets"
120 ${kinit} --password-file=${objdir}/foopassword user1@${R} || exitcode=1
121 echo "Getting digestserver initial tickets"
122 ${kinitds} --password-file=${objdir}/barpassword digestserver@${R} || exitcode=1
124 echo "======context building for each mech"
126 for mech in ntlm krb5 ; do
127 echo "${mech}"
128 ${context} --mech-type=${mech} --ret-mech-type=${mech} \
129 --name-type=hostbased-service host@host.test.h5l.se || \
130 { exitcode=1 ; echo test failed; }
131 done
133 echo "spnego"
134 ${context} \
135 --mech-type=spnego \
136 --ret-mech-type=krb5 \
137 --name-type=hostbased-service \
138 host@host.test.h5l.se || \
139 { exitcode=1 ; echo test failed; }
141 echo "test failure cases"
142 ${context} --mech-type=ntlm --ret-mech-type=krb5 \
143 --name-type=hostbased-service host@host.test.h5l.se 2> /dev/null && \
144 { exitcode=1 ; echo test failed; }
146 ${context} --mech-type=krb5 --ret-mech-type=ntlm \
147 --name-type=hostbased-service host@host.test.h5l.se 2> /dev/null && \
148 { exitcode=1 ; echo test failed; }
150 echo "======spnego variants context building"
152 for arg in \
153 "" \
154 "--mutual" \
155 "--delegate" \
156 "--mutual --delegate" \
157 "--getverifymic --wrapunwrap" \
158 "--mutual --getverifymic --wrapunwrap" \
159 ; do
161 echo "no NTLM acceptor cred ${arg}"
162 NTLM_ACCEPTOR_CCACHE="${cacheds}-no"
163 ${context} --mech-type=spnego \
164 $arg \
165 --name-type=hostbased-service \
166 --ret-mech-type=krb5 \
167 host@host.test.h5l.se || \
168 { exitcode=1 ; echo test failed; }
169 NTLM_ACCEPTOR_CCACHE="${cacheds}"
171 echo "no NTLM initiator cred ${arg}"
172 NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt-no"
173 ${context} --mech-type=spnego \
174 $arg \
175 --name-type=hostbased-service \
176 --ret-mech-type=krb5 \
177 host@host.test.h5l.se || \
178 { exitcode=1 ; echo test failed; }
179 NTLM_USER_FILE="${srcdir}/ntlm-user-file.txt"
181 echo "no krb5 acceptor cred ${arg}"
182 KRB5_KTNAME="${keytab}-no"
183 ${context} --mech-type=spnego \
184 $arg \
185 --name-type=hostbased-service \
186 --ret-mech-type=ntlm \
187 host@host.test.h5l.se || \
188 { exitcode=1 ; echo test failed; }
189 KRB5_KTNAME="${keytab}"
191 echo "no krb5 initiator cred ${arg}"
192 KRB5CCNAME="${cache}-no"
193 ${context} --mech-type=spnego \
194 $arg \
195 --name-type=hostbased-service \
196 --ret-mech-type=ntlm \
197 host@host.test.h5l.se || \
198 { exitcode=1 ; echo test failed; }
199 KRB5CCNAME="${cache}"
201 done
203 trap "" EXIT
205 echo "killing kdc (${kdcpid})"
206 kill ${kdcpid} 2> /dev/null
208 exit $exitcode