No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / tests / kdc / check-iprop.in
blob7ba6fe3d9ec6820a5fc733ec6a92ec9475457580
1 #!/bin/sh
3 # Copyright (c) 2006 - 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@"
40 EGREP="@EGREP@"
42 # If there is no useful db support compile in, disable test
43 ../db/have-db || exit 77
45 # Dont run this test in AFS, since it lacks support for AF_UNIX
46 expr "X`/bin/pwd || pwd`" : "X/afs/.*" > /dev/null 2>/dev/null && exit 77
48 R=TEST.H5L.SE
50 port=@port@
52 cache="FILE:${objdir}/cache.krb5"
53 keytabfile=${objdir}/iprop.keytab
54 keytab="FILE:${keytabfile}"
56 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
57 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -r $R"
58 ipropdslave="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-slave"
59 ipropdmaster="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-master"
60 iproplog="${TESTS_ENVIRONMENT} ../../lib/kadm5/iprop-log"
62 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
64 KRB5_CONFIG="${objdir}/krb5.conf"
65 export KRB5_CONFIG
67 rm -f ${keytabfile}
68 rm -f current-db*
69 rm -f current*.log
70 rm -f out-*
71 rm -f mkey.file*
72 rm -f messages.log
74 > messages.log
76 echo Creating database
77 ${kadmin} -l \
78 init \
79 --realm-max-ticket-life=1day \
80 --realm-max-renewable-life=1month \
81 ${R} || exit 1
83 ${kadmin} -l add -p foo --use-defaults user@${R} || exit 1
85 ${kadmin} -l add --random-key --use-defaults iprop/localhost@${R} || exit 1
86 ${kadmin} -l ext -k ${keytab} iprop/localhost@${R} || exit 1
87 ${kadmin} -l add --random-key --use-defaults iprop/slave@${R} || exit 1
88 ${kadmin} -l ext -k ${keytab} iprop/slave@${R} || exit 1
90 echo foo > ${objdir}/foopassword
92 # -- foo
93 ipds=
94 ipdm=
95 kdcpid=
97 > iprop-stats
98 trap "echo 'killing ipropd s + m + kdc'; kill \${ipdm} \${ipds} \${kdcpid} >/dev/null 2>/dev/null; tail messages.log ; tail iprop-stats; exit 1;" EXIT
100 echo Starting kdc
101 ${kdc} &
102 kdcpid=$!
104 sh ${srcdir}/wait-kdc.sh || exit 1
106 echo "starting master"
107 ${ipropdmaster} --hostname=localhost -k ${keytab} \
108 --database=${objdir}/current-db &
109 ipdm=$!
110 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
112 echo "starting slave"
113 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
114 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
115 ipds=$!
116 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
118 echo "checking slave is up"
119 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
121 # ----------------- checking: pushing lives changes
123 echo "Add host"
124 ${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1
125 sleep 2
126 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
127 ${kadmin} -l get host/foo@${R} > /dev/null || exit 1
129 echo "Rename host"
130 ${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1
131 sleep 2
132 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
133 ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1
134 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
135 ${kadmin} -l get host/bar@${R} > /dev/null || exit 1
137 echo "Delete host"
138 ${kadmin} -l delete host/bar@${R} || exit 1
139 sleep 2
140 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
141 ${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1
143 echo "kill slave"
144 > iprop-stats
145 kill ${ipds}
146 sleep 2
148 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1
150 # ----------------- checking: slave is missing changes while down
152 echo "doing changes while slave is down"
153 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
154 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
156 echo "Makeing a copy of the master log file"
157 cp ${objdir}/current.log ${objdir}/current.log.tmp
159 # ----------------- checking: checking that master and slaves resyncs
161 echo "starting slave again"
162 > iprop-stats
163 > messages.log
164 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
165 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
166 ipds=$!
167 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
169 echo "checking slave is up again"
170 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
171 echo "checking for replay problems"
172 ${EGREP} 'Entry already exists in database' messages.log && exit 1
174 echo "kill slave and remove log and database"
175 kill ${ipds}
176 sleep 2
178 rm current.slave.log current-db.slave* || exit 1
179 > iprop-stats
180 > messages.log
181 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
182 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
183 ipds=$!
184 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
186 echo "checking slave is up again"
187 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
188 echo "checking for replay problems"
189 ${EGREP} 'Entry already exists in database' messages.log && exit 1
191 # ----------------- checking: checking live truncation of master log
193 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
194 sleep 2
196 echo "live truncate on master log"
197 ${iproplog} truncate || exit 1
198 sleep 2
200 echo "Killing master and slave"
201 kill ${ipdm} ${ipds} >/dev/null 2>/dev/null
203 sleep 2
204 ${EGREP} "^master down at " iprop-stats > /dev/null || exit 1
206 echo "compare versions on master and slave logs"
207 KRB5_CONFIG=${objdir}/krb5-slave.conf \
208 ${iproplog} last-version > slave-last.tmp
209 ${iproplog} last-version > master-last.tmp
210 cmp master-last.tmp slave-last.tmp || exit 1
212 # ----------------- checking: master going backward
213 > iprop-stats
214 > messages.log
216 echo "Going back to old version of the master log file"
217 cp ${objdir}/current.log.tmp ${objdir}/current.log
219 echo "starting master"
220 ${ipropdmaster} --hostname=localhost -k ${keytab} \
221 --database=${objdir}/current-db &
222 ipdm=$!
223 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
225 echo "starting slave"
226 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
227 ${ipropdslave} --hostname=slave -k ${keytab} localhost &
228 ipds=$!
229 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
231 echo "checking slave is up again"
232 ${EGREP} 'iprop/slave@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
233 echo "checking for replay problems"
234 ${EGREP} 'Entry already exists in database' messages.log && exit 1
236 echo "pushing one change"
237 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
238 sleep 2
240 trap "" EXIT
241 kill ${ipdm} ${ipds} ${kdcpid}
243 echo "compare versions on master and slave logs"
244 KRB5_CONFIG=${objdir}/krb5-slave.conf \
245 ${iproplog} last-version > slave-last.tmp
246 ${iproplog} last-version > master-last.tmp
247 cmp master-last.tmp slave-last.tmp || exit 1
249 exit $ec