3 # Copyright (c) 2006 - 2008 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
34 env_setup
="@env_setup@"
39 KRB5_CONFIG
="${objdir}/krb5-kinit.conf"
41 KRB5CCNAME
="${objdir}/foocc"
44 testfailed
="echo test failed; exit 1"
46 # If there is no useful db support compiled in, disable test
54 kinit
="${kinit} --password-file=${objdir}/foopassword ${afs_no_afslog} -c ${objdir}/foocc"
55 klist
="${klist} -c ${objdir}/foocc"
56 kgetcred
="${kgetcred} -c ${objdir}/foocc"
57 kdestroy
="${kdestroy} ${afs_no_unlog}"
58 kadmin
="${kadmin} -l -r $R"
59 kdc
="${kdc} --addresses=localhost -P $port"
62 cache
="FILE:${objdir}/cache.krb5"
63 keytabfile
=${objdir}/server.keytab
64 keytab
="FILE:${keytabfile}"
71 cred_life
=$
((torture_time
/ 10))
72 cred_renew_life
=$
((torture_time
/ 2))
73 out
=${objdir}/out-kinit-torture-kgetcred
74 kinit_out
=${objdir}/out-kinit-torture-kinit
80 echo "This is a MANUAL test."
87 cp "${objdir}/krb5.conf" "${objdir}/krb5-kinit.conf"
89 echo "Creating database"
92 --realm-max-ticket-life=1day \
93 --realm-max-renewable-life=1month \
97 ${kadmin} add
-p foo
--use-defaults foo@
${R} ||
exit 1
99 echo "Creating torture principals"
100 for i
in $
(seq 0 $
((num_princs
- 1)) ); do
101 ${kadmin} add -r --use-defaults svc${i}@${R} ||
exit 1
104 echo "Doing database check"
105 ${kadmin} check
${R} ||
exit 1
107 echo foo
> ${objdir}/foopassword
109 echo Starting kdc
; > messages.log
110 ${kdc} --detach --testing ||
{ echo "kdc failed to start"; cat messages.log
; exit 1; }
113 trap "kill -9 ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
117 echo "begin torture (output in $out)"
119 cat /dev
/null
> "$out"
120 while (($
(date +%s
) < (secs
+ torture_time
) )); do
122 for i
in $
(seq 0 1000); do
123 printf '%d\n' $
((i
% num_princs
))
124 done |
xargs -P $num_concurrent -I '{}' ${kgetcred} "svc{}@${R}"
125 ${klist} -v ||
exit 1
126 if ! kill -0 $parent_shell_proc; then
127 printf 'Parent shell script exited; exiting'
129 grep 'Matching credential .* not found' messages.log
> /dev
/null
&&
130 echo "THAT DID NOT WORK RIGHT"
138 echo "checking that we have tickets"
139 ${kinit} -l $cred_life -r $cred_renew_life foo@${R} || { ec=1 ; eval "${testfailed}"; }
140 ${klist} -v || { ec=1 ; eval "${testfailed}"; }
142 ${kinit} -l $cred_life -r $cred_renew_life foo@${R} "$0" torture-me || { ec=1 ; eval "${testfailed}"; }
144 echo "killing kdc (${kdcpid})"
145 sh
${leaks_kill} kdc
$kdcpid ||
exit 1