3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2016 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $SYNCPROV = syncprovno; then
20 echo "Syncrepl provider overlay not available, test skipped"
23 if test $ACCESSLOG = accesslogno; then
24 echo "Accesslog overlay not available, test skipped"
27 if test $DYNLIST = dynlistno; then
28 echo "Accesslog overlay not available, test skipped"
31 if test $MEMBEROF = memberofno; then
32 echo "Memberof overlay not available, test skipped"
35 if test $BACKEND = ldif ; then
36 # Onelevel search does not return entries in order of creation or CSN.
37 echo "$BACKEND backend unsuitable for syncprov logdb, test skipped"
41 echo "This test tracks a case where the memberof overlay incorrectly writes to"
42 echo "the accesslog DB when a group is deleted."
43 echo "See http://www.openldap.org/its/index.cgi/?findid=8444 for more information."
50 $SLAPPASSWD -g -n >$CONFIGPWF
53 ITSDIR=$DATADIR/regressions/its$ITS
55 echo "Initializing server configurations..."
58 while [ $n -le $MMR ]; do
60 CFDIR=${XDIR}$n/slapd.d
62 mkdir -p ${XDIR}$n $DBDIR.1 $DBDIR.2 $CFDIR
63 . $CONFFILTER $BACKEND $MONITORDB < $ITSDIR/slapd-provider${n}.ldif > $CONFLDIF
64 $SLAPADD -F $CFDIR -n 0 -l $CONFLDIF
70 while [ $n -le $MMR ]; do
71 MYURI=`eval echo '$URI'$n`
72 MYLOG=`eval echo '$LOG'$n`
73 CFDIR=${XDIR}$n/slapd.d
75 echo "Starting provider slapd on TCP/IP URI $MYURI"
76 $SLAPD -F $CFDIR -h $MYURI -d $LVL $TIMING > $MYLOG 2>&1 &
79 if test $WAIT != 0 ; then
83 KILLPIDS="$PID $KILLPIDS"
86 echo "Using ldapsearch to check that provider slapd is running..."
87 for i in 0 1 2 3 4 5; do
88 $LDAPSEARCH -s base -b "" -H $MYURI \
89 'objectclass=*' > /dev/null 2>&1
91 if test $RC = 0 ; then
94 echo "Waiting 5 seconds for slapd to start..."
98 if test $RC != 0 ; then
99 echo "ldapsearch failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Populating database on first provider..."
107 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
109 objectClass: organization
110 objectClass: dcObject
114 dn: ou=People,$BASEDN
115 objectClass: organizationalUnit
118 dn: ou=Groups,$BASEDN
119 objectClass: organizationalUnit
122 dn: cn=Roger Rabbit,ou=People,$BASEDN
123 objectClass: inetOrgPerson
127 dn: cn=Baby Herman,ou=People,$BASEDN
128 objectClass: inetOrgPerson
132 dn: cn=Jessica_Rabbit,ou=People,$BASEDN
133 objectClass: inetOrgPerson
137 dn: cn=Bugs_Bunny,ou=People,$BASEDN
138 objectClass: inetOrgPerson
142 dn: cn=Daffy_Duck,ou=People,$BASEDN
143 objectClass: inetOrgPerson
147 dn: cn=Elmer_Fudd,ou=People,$BASEDN
148 objectClass: inetOrgPerson
152 dn: cn=Cartoonia,ou=Groups,$BASEDN
153 objectClass: groupOfNames
155 member: cn=Roger Rabbit,ou=People,$BASEDN
156 member: cn=Baby Herman,ou=People,$BASEDN
160 if test $RC != 0 ; then
161 echo "ldapadd failed ($RC)!"
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 echo "Sleeping 10 seconds to allow replication to initiate..."
169 echo "Looping 50 times adding and deleting members to the Cartoonia group..."
171 while [ $modloop -le 50 ]; do
172 echo "Adding new members to the group (${modloop}/50)..."
173 $LDAPMODIFY -H $URI1 \
174 -D "cn=Manager,$BASEDN" -w $PASSWD \
175 >> $TESTOUT 2>&1 << EOF
176 dn: cn=Cartoonia,ou=Groups,$BASEDN
179 member: cn=Jessica_Rabbit,ou=People,$BASEDN
180 member: cn=Elmer_Fudd,ou=People,$BASEDN
181 member: cn=Daffy_Duck,ou=People,$BASEDN
182 member: cn=Bugs_Bunny,ou=People,$BASEDN
187 echo "Deleting new members from the group..."
188 $LDAPMODIFY -H $URI1 \
189 -D "cn=Manager,$BASEDN" -w $PASSWD \
190 >> $TESTOUT 2>&1 << EOF
191 dn: cn=Cartoonia,ou=Groups,$BASEDN
194 member: cn=Jessica_Rabbit,ou=People,$BASEDN
195 member: cn=Elmer_Fudd,ou=People,$BASEDN
196 member: cn=Daffy_Duck,ou=People,$BASEDN
197 member: cn=Bugs_Bunny,ou=People,$BASEDN
201 echo "Searching new members to see if they still have memberOf present..."
202 TOON1="cn=Jessica_Rabbit,ou=People,$BASEDN"
203 TOON2="cn=Elmer_Fudd,ou=People,$BASEDN"
204 TOON3="cn=Daffy_Duck,ou=People,$BASEDN"
205 TOON4="cn=Bugs_Bunny,ou=People,$BASEDN"
206 for member in $TOON1 $TOON2 $TOON3 $TOON4; do
208 while [ $n -le $MMR ]; do
210 echo "# Searching member $member after removal from Cartoonia group, provider $n" >> $SEARCHOUT
211 MYURI=`eval echo '$URI'$n`
212 $LDAPSEARCH -S "" -b "$member" -s base -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
213 '(objectClass=*)' 'memberOf' >> $SEARCHOUT 2>&1
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
223 if test $RC != 1 ; then
224 echo "User delete failed on one or more consumer."
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
231 modloop=`expr $modloop + 1`
234 echo "Looping 50 times deleting and adding Cartoonia group..."
236 while [ $modloop -le 50 ]; do
238 echo "Running ldapdelete to remove a group (${modloop}/50)..."
239 $LDAPMODIFY -H $URI1 \
240 -D "cn=Manager,$BASEDN" -w $PASSWD \
241 >> $TESTOUT 2>&1 << EOF
242 dn: cn=Cartoonia,ou=Groups,$BASEDN
248 echo "Searching entire database on each provider after deleting Cartoonia group"
251 while [ $n -le $MMR ]; do
252 echo "# Searching the entire database after deleting Cartoonia, provider $n" >> $SEARCHOUT
253 MYURI=`eval echo '$URI'$n`
254 $LDAPSEARCH -S "" -b "$BASEDN" -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
255 '(objectClass=*)' '*' >> $SEARCHOUT 2>&1
257 if test $RC != 0 ; then
258 echo "ldapsearch failed ($RC)!"
259 test $KILLSERVERS != no && kill -HUP $KILLPIDS
265 grep "cn=Cartoonia" $SEARCHOUT >/dev/null 2>&1
268 if test $RC != 1 ; then
269 echo "Group delete failed on one or more consumer."
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 echo "Running ldapmodify to add the group back..."
275 $LDAPMODIFY -H $URI1 \
276 -D "cn=Manager,$BASEDN" -w $PASSWD \
277 >> $TESTOUT 2>&1 <<EOF
278 dn: cn=Cartoonia,ou=Groups,$BASEDN
280 objectClass: groupOfNames
282 member: cn=Roger Rabbit,ou=People,$BASEDN
283 member: cn=Baby Herman,ou=People,$BASEDN
288 echo "Searching entire database on each provider after re-adding Cartoonia group"
291 while [ $n -le $MMR ]; do
293 echo "# Searching the entire database after re-adding Cartoonia, provider $n" >> $SEARCHOUT
294 MYURI=`eval echo '$URI'$n`
295 $LDAPSEARCH -S "" -b "$BASEDN" -H $MYURI -D "cn=manager,$BASEDN" -w $PASSWD \
296 '(objectClass=*)' '*' memberOf>> $SEARCHOUT 2>&1
298 if test $RC != 0 ; then
299 echo "ldapsearch failed ($RC)!"
300 test $KILLSERVERS != no && kill -HUP $KILLPIDS
303 grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
306 if test $RC != 0 ; then
307 echo "Group add failed on one or more consumer."
308 test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 modloop=`expr $modloop + 1`
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
319 echo ">>>>> Test succeeded"
321 test $KILLSERVERS != no && wait