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