PageRenderTime 32ms CodeModel.GetById 14ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/crypto/heimdal/tests/kdc/check-iprop.in

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