heimdal Extend the 'hdb as a keytab' code [HEIMDAL-600]
[heimdal.git] / tests / kdc / check-iprop.in
blob90814d1528ac11b0bc95361233bd611a7578c7d1
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 # $Id$
37 srcdir="@srcdir@"
38 objdir="@objdir@"
39 EGREP="@EGREP@"
41 # If there is no useful db support compile in, disable test
42 ../db/have-db || exit 77
44 # Dont run this test in AFS, since it lacks support for AF_UNIX
45 expr "X`/bin/pwd || pwd`" : "X/afs/.*" > /dev/null 2>/dev/null && exit 77
47 R=TEST.H5L.SE
49 port=@port@
51 cache="FILE:${objdir}/cache.krb5"
52 keytabfile=${objdir}/iprop.keytab
53 keytab="FILE:${keytabfile}"
55 kdc="${TESTS_ENVIRONMENT} ../../kdc/kdc --addresses=localhost -P $port"
56 kadmin="${TESTS_ENVIRONMENT} ../../kadmin/kadmin -r $R"
57 ipropdslave="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-slave"
58 ipropdmaster="${TESTS_ENVIRONMENT} ../../lib/kadm5/ipropd-master"
59 iproplog="${TESTS_ENVIRONMENT} ../../lib/kadm5/iprop-log"
61 kinit="${TESTS_ENVIRONMENT} ../../kuser/kinit -c $cache --no-afslog"
63 KRB5_CONFIG="${objdir}/krb5.conf"
64 export KRB5_CONFIG
66 rm -f ${keytabfile}
67 rm -f current-db*
68 rm -f current*.log
69 rm -f out-*
70 rm -f mkey.file*
71 rm -f messages.log
73 > messages.log
75 echo Creating database
76 ${kadmin} -l \
77 init \
78 --realm-max-ticket-life=1day \
79 --realm-max-renewable-life=1month \
80 ${R} || exit 1
82 ${kadmin} -l add -p foo --use-defaults user@${R} || exit 1
84 ${kadmin} -l add --random-key --use-defaults iprop/localhost@${R} || exit 1
85 ${kadmin} -l ext -k ${keytab} iprop/localhost@${R} || exit 1
86 ${kadmin} -l add --random-key --use-defaults iprop/slave.test.h5l.se@${R} || exit 1
87 ${kadmin} -l ext -k ${keytab} iprop/slave.test.h5l.se@${R} || exit 1
89 echo foo > ${objdir}/foopassword
91 # -- foo
92 ipds=
93 ipdm=
94 kdcpid=
96 > iprop-stats
97 trap "echo 'killing ipropd s + m + kdc'; kill -9 \${ipdm} \${ipds} \${kdcpid} >/dev/null 2>/dev/null; tail messages.log ; tail iprop-stats; exit 1;" EXIT
99 echo Starting kdc
100 ${kdc} &
101 kdcpid=$!
103 sh ${srcdir}/wait-kdc.sh || exit 1
105 echo "starting master"
106 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-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 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-slave \
114 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
115 ${ipropdslave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
116 ipds=$!
117 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
119 echo "checking slave is up"
120 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
122 # ----------------- checking: pushing lives changes
124 echo "Add host"
125 ${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1
126 sleep 2
127 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
128 ${kadmin} -l get host/foo@${R} > /dev/null || exit 1
130 echo "Rename host"
131 ${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1
132 sleep 2
133 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
134 ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1
135 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
136 ${kadmin} -l get host/bar@${R} > /dev/null || exit 1
138 echo "Delete host"
139 ${kadmin} -l delete host/bar@${R} || exit 1
140 sleep 2
141 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
142 ${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1
144 echo "kill slave"
145 > iprop-stats
146 sh ${srcdir}/leaks-kill.sh ipropd-slave $ipds || exit 1
147 sleep 2
149 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1
151 # ----------------- checking: slave is missing changes while down
153 echo "doing changes while slave is down"
154 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
155 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
157 echo "Makeing a copy of the master log file"
158 cp ${objdir}/current.log ${objdir}/current.log.tmp
160 # ----------------- checking: checking that master and slaves resyncs
162 echo "starting slave again"
163 > iprop-stats
164 > messages.log
165 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-slave \
166 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
167 ${ipropdslave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
168 ipds=$!
169 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
171 echo "checking slave is up again"
172 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
173 echo "checking for replay problems"
174 ${EGREP} 'Entry already exists in database' messages.log && exit 1
176 echo "kill slave and remove log and database"
177 sh ${srcdir}/leaks-kill.sh ipropd-slave $ipds || exit 1
178 sleep 2
180 rm current.slave.log current-db.slave* || exit 1
181 > iprop-stats
182 > messages.log
183 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-slave \
184 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
185 ${ipropdslave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
186 ipds=$!
187 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
189 echo "checking slave is up again"
190 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
191 echo "checking for replay problems"
192 ${EGREP} 'Entry already exists in database' messages.log && exit 1
194 # ----------------- checking: checking live truncation of master log
196 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
197 sleep 2
199 echo "live truncate on master log"
200 ${iproplog} truncate || exit 1
201 sleep 2
203 echo "Killing master and slave"
204 sh ${srcdir}/leaks-kill.sh ipropd-master $ipdm || exit 1
205 sh ${srcdir}/leaks-kill.sh ipropd-slave $ipds || exit 1
207 #sleep 2
208 #${EGREP} "^master down at " iprop-stats > /dev/null || exit 1
210 echo "compare versions on master and slave logs"
211 KRB5_CONFIG=${objdir}/krb5-slave.conf \
212 ${iproplog} last-version > slave-last.tmp
213 ${iproplog} last-version > master-last.tmp
214 cmp master-last.tmp slave-last.tmp || exit 1
216 # ----------------- checking: master going backward
217 > iprop-stats
218 > messages.log
220 echo "Going back to old version of the master log file"
221 cp ${objdir}/current.log.tmp ${objdir}/current.log
223 echo "starting master"
224 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-master \
225 ${ipropdmaster} --hostname=localhost -k ${keytab} \
226 --database=${objdir}/current-db &
227 ipdm=$!
228 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
230 echo "starting slave"
231 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-slave \
232 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
233 ${ipropdslave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
234 ipds=$!
235 sh ${srcdir}/wait-kdc.sh ipropd-slave || exit 1
237 echo "checking slave is up again"
238 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
239 echo "checking for replay problems"
240 ${EGREP} 'Entry already exists in database' messages.log && exit 1
242 echo "pushing one change"
243 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
244 sleep 2
246 echo "Killing master"
247 sh ${srcdir}/leaks-kill.sh ipropd-master $ipdm || exit 1
249 sleep 4
251 if ! tail -30 messages.log | grep 'disconnected for server' > /dev/null; then
252 echo "client didnt disconnect"
253 exit 1
256 echo "probing for slave pid"
257 kill -0 ${ipds} || { echo "slave no longer there"; exit 1; }
259 echo "Staring master again"
260 MallocStackLogging=1 MallocStackLoggingNoCompact=1 MallocErrorAbort=1 MallocLogFile=${objdir}/malloc-log-master \
261 ${ipropdmaster} --hostname=localhost -k ${keytab} \
262 --database=${objdir}/current-db &
263 ipdm=$!
264 sh ${srcdir}/wait-kdc.sh ipropd-master || exit 1
266 echo "probing for slave pid"
267 kill -0 ${ipds} || { echo "slave no longer there"; exit 1; }
269 sh ${srcdir}/wait-kdc.sh ipropd-slave messages.log "connection successful to master" || exit 1
271 sh ${srcdir}/wait-kdc.sh ipropd-slave messages.log "ipropd-slave started at version" || exit 1
273 echo "pushing one change"
274 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
275 sleep 2
277 echo "shutting down all services"
279 trap "" EXIT
280 sh ${srcdir}/leaks-kill.sh kdc $kdcpid || exit 1
281 sh ${srcdir}/leaks-kill.sh ipropd-master $ipdm || exit 1
282 sh ${srcdir}/leaks-kill.sh ipropd-slave $ipds || exit 1
284 echo "compare versions on master and slave logs"
285 KRB5_CONFIG=${objdir}/krb5-slave.conf \
286 ${iproplog} last-version > slave-last.tmp
287 ${iproplog} last-version > master-last.tmp
288 cmp master-last.tmp slave-last.tmp || exit 1
290 exit $ec