etc/services - sync with NetBSD-8
[minix.git] / crypto / external / bsd / heimdal / dist / tests / kdc / check-iprop.in
blobba9aff14e752e75121927025bf950a1521dfa146
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 top_builddir="@top_builddir@"
35 env_setup="@env_setup@"
36 objdir="@objdir@"
38 . ${env_setup}
40 # If there is no useful db support compile in, disable test
41 ${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="${kdc} --addresses=localhost -P $port"
56 kadmin="${kadmin} -r $R"
57 kinit="${kinit} -c $cache ${afs_no_afslog}"
59 KRB5_CONFIG="${objdir}/krb5.conf"
60 export KRB5_CONFIG
62 rm -f ${keytabfile}
63 rm -f current-db*
64 rm -f current*.log
65 rm -f out-*
66 rm -f mkey.file*
67 rm -f messages.log
69 > messages.log
71 echo Creating database
72 ${kadmin} -l \
73 init \
74 --realm-max-ticket-life=1day \
75 --realm-max-renewable-life=1month \
76 ${R} || exit 1
78 ${kadmin} -l add -p foo --use-defaults user@${R} || exit 1
80 ${kadmin} -l add --random-key --use-defaults iprop/localhost@${R} || exit 1
81 ${kadmin} -l ext -k ${keytab} iprop/localhost@${R} || exit 1
82 ${kadmin} -l add --random-key --use-defaults iprop/slave.test.h5l.se@${R} || exit 1
83 ${kadmin} -l ext -k ${keytab} iprop/slave.test.h5l.se@${R} || exit 1
85 echo foo > ${objdir}/foopassword
87 # -- foo
88 ipds=
89 ipdm=
90 kdcpid=
92 > iprop-stats
93 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
95 echo Starting kdc
96 ${kdc} &
97 kdcpid=$!
99 sh ${wait_kdc} || exit 1
101 echo "starting master"
102 env ${HEIM_MALLOC_DEBUG} \
103 ${ipropd_master} --hostname=localhost -k ${keytab} \
104 --database=${objdir}/current-db &
105 ipdm=$!
106 sh ${wait_kdc} ipropd-master || exit 1
108 echo "starting slave"
109 env ${HEIM_MALLOC_DEBUG} \
110 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
111 ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
112 ipds=$!
113 sh ${wait_kdc} ipropd-slave || exit 1
115 echo "checking slave is up"
116 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
118 # ----------------- checking: pushing lives changes
120 echo "Add host"
121 ${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1
122 sleep 2
123 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
124 ${kadmin} -l get host/foo@${R} > /dev/null || exit 1
126 echo "Rename host"
127 ${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1
128 sleep 2
129 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
130 ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1
131 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
132 ${kadmin} -l get host/bar@${R} > /dev/null || exit 1
134 echo "Delete host"
135 ${kadmin} -l delete host/bar@${R} || exit 1
136 sleep 2
137 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
138 ${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1
140 echo "kill slave"
141 > iprop-stats
142 sh ${leaks_kill} ipropd-slave $ipds || exit 1
143 sleep 2
145 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1
147 # ----------------- checking: slave is missing changes while down
149 echo "doing changes while slave is down"
150 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
151 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
153 echo "Makeing a copy of the master log file"
154 cp ${objdir}/current.log ${objdir}/current.log.tmp
156 # ----------------- checking: checking that master and slaves resyncs
158 echo "starting slave again"
159 > iprop-stats
160 > messages.log
161 env ${HEIM_MALLOC_DEBUG} \
162 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
163 ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
164 ipds=$!
165 sh ${wait_kdc} ipropd-slave || exit 1
167 echo "checking slave is up again"
168 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
169 echo "checking for replay problems"
170 ${EGREP} 'Entry already exists in database' messages.log && exit 1
172 echo "kill slave and remove log and database"
173 sh ${leaks_kill} ipropd-slave $ipds || exit 1
174 sleep 2
176 rm current.slave.log current-db.slave* || exit 1
177 > iprop-stats
178 > messages.log
179 env ${HEIM_MALLOC_DEBUG} \
180 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
181 ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
182 ipds=$!
183 sh ${wait_kdc} ipropd-slave || exit 1
185 echo "checking slave is up again"
186 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
187 echo "checking for replay problems"
188 ${EGREP} 'Entry already exists in database' messages.log && exit 1
190 # ----------------- checking: checking live truncation of master log
192 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
193 sleep 2
195 echo "live truncate on master log"
196 ${iprop_log} truncate || exit 1
197 sleep 2
199 echo "Killing master and slave"
200 sh ${leaks_kill} ipropd-master $ipdm || exit 1
201 sh ${leaks_kill} ipropd-slave $ipds || exit 1
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 ${iprop_log} last-version > slave-last.tmp
209 ${iprop_log} 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 env ${HEIM_MALLOC_DEBUG} \
221 ${ipropd_master} --hostname=localhost -k ${keytab} \
222 --database=${objdir}/current-db &
223 ipdm=$!
224 sh ${wait_kdc} ipropd-master || exit 1
226 echo "starting slave"
227 env ${HEIM_MALLOC_DEBUG} \
228 KRB5_CONFIG="${objdir}/krb5-slave.conf" \
229 ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} localhost &
230 ipds=$!
231 sh ${wait_kdc} ipropd-slave || exit 1
233 echo "checking slave is up again"
234 ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1
235 echo "checking for replay problems"
236 ${EGREP} 'Entry already exists in database' messages.log && exit 1
238 echo "pushing one change"
239 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
240 sleep 2
242 echo "Killing master"
243 sh ${leaks_kill} ipropd-master $ipdm || exit 1
245 sleep 4
247 if ! tail -30 messages.log | grep 'disconnected for server' > /dev/null; then
248 echo "client didnt disconnect"
249 exit 1
252 echo "probing for slave pid"
253 kill -0 ${ipds} || { echo "slave no longer there"; exit 1; }
255 > messages.log
257 echo "Staring master again"
258 env ${HEIM_MALLOC_DEBUG} \
259 ${ipropd_master} --hostname=localhost -k ${keytab} \
260 --database=${objdir}/current-db &
261 ipdm=$!
262 sh ${wait_kdc} ipropd-master || exit 1
264 echo "probing for slave pid"
265 kill -0 ${ipds} || { echo "slave no longer there"; exit 1; }
267 sh ${wait_kdc} ipropd-slave messages.log "connection successful to master" || exit 1
269 sh ${wait_kdc} ipropd-slave messages.log "ipropd-slave started at version" || exit 1
271 echo "pushing one change"
272 ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1
273 sleep 2
275 echo "shutting down all services"
277 trap "" EXIT
278 sh ${leaks_kill} kdc $kdcpid || exit 1
279 sh ${leaks_kill} ipropd-master $ipdm || exit 1
280 sh ${leaks_kill} ipropd-slave $ipds || exit 1
282 echo "compare versions on master and slave logs"
283 KRB5_CONFIG=${objdir}/krb5-slave.conf \
284 ${iprop_log} last-version > slave-last.tmp
285 ${iprop_log} last-version > master-last.tmp
286 cmp master-last.tmp slave-last.tmp || exit 1
288 exit $ec