Expand PMF_FN_* macros.
[netbsd-mini2440.git] / crypto / dist / heimdal / tests / gss / check-basic.in
blobfca736fa8e5d69d489aea281f5c21182d9a9c3ec
1 #!/bin/sh
3 # Copyright (c) 2007 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$
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 nokeytab="FILE:no-such-keytab"
51 cache="FILE:krb5ccfile"
52 nocache="FILE:no-such-cache"
54 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
55 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -l -r $R"
56 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
58 acquire_cred="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_acquire_cred"
59 test_kcred="${TESTS_ENVIRONMENT} ../../lib/gssapi/test_kcred"
61 KRB5_CONFIG="${objdir}/krb5.conf"
62 export KRB5_CONFIG
64 KRB5_KTNAME="${keytab}"
65 export KRB5_KTNAME
66 KRB5CCNAME="${cache}"
67 export KRB5CCNAME
69 rm -f ${keytabfile}
70 rm -f current-db*
71 rm -f out-*
72 rm -f mkey.file*
74 > messages.log
76 echo Creating database
77 ${kadmin} \
78 init \
79 --realm-max-ticket-life=1day \
80 --realm-max-renewable-life=1month \
81 ${R} || exit 1
83 echo upw > ${objdir}/foopassword
85 ${kadmin} add -p upw --use-defaults user@${R} || exit 1
86 ${kadmin} add -p upw --use-defaults another@${R} || exit 1
87 ${kadmin} add -p p1 --use-defaults host/host.test.h5l.se@${R} || exit 1
88 ${kadmin} ext -k ${keytab} host/host.test.h5l.se@${R} || exit 1
90 echo "Doing database check"
91 ${kadmin} check ${R} || exit 1
93 echo Starting kdc
94 ${kdc} &
95 kdcpid=$!
97 sh ${srcdir}/../kdc/wait-kdc.sh
98 if [ "$?" != 0 ] ; then
99 kill ${kdcpid}
100 exit 1
103 trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
105 exitcode=0
107 echo "initial ticket"
108 ${kinit} --password-file=${objdir}/foopassword user@${R} || exitcode=1
110 echo "keytab"
111 ${acquire_cred} \
112 --acquire-type=accept \
113 --acquire-name=host@host.test.h5l.se || exit 1
114 echo "keytab w/o name"
115 ${acquire_cred} \
116 --acquire-type=accept || exit 1
117 echo "keytab w/ wrong name"
118 ${acquire_cred} \
119 --acquire-type=accept \
120 --acquire-name=host@host2.test.h5l.se 2>/dev/null && exit 1
121 echo "init using keytab"
122 ${acquire_cred} \
123 --acquire-type=initiate \
124 --acquire-name=host@host.test.h5l.se || exit 1
125 echo "init using existing cc"
126 ${acquire_cred} \
127 --name-type=user-name \
128 --acquire-type=initiate \
129 --acquire-name=user || exit 1
131 KRB5CCNAME=${nocache}
133 echo "fail init using existing cc"
134 ${acquire_cred} \
135 --name-type=user-name \
136 --acquire-type=initiate \
137 --acquire-name=user 2>/dev/null && exit 1
139 echo "use gss_krb5_ccache_name"
140 ${acquire_cred} \
141 --name-type=user-name \
142 --ccache=${cache} \
143 --acquire-type=initiate \
144 --acquire-name=user >/dev/null || exit 1
146 KRB5CCNAME=${cache}
147 KRB5_KTNAME=${nokeytab}
149 echo "kcred"
150 ${test_kcred} || exit 1
152 trap "" EXIT
154 echo "killing kdc (${kdcpid})"
155 kill ${kdcpid} 2> /dev/null
157 exit $exitcode