]> git.sur5r.net Git - openldap/blob - tests/data/regressions/its8444/its8444
bacfa8afa60b92fd3154582b9082b3567344fafc
[openldap] / tests / data / regressions / its8444 / its8444
1 #! /bin/sh
2 # $OpenLDAP$
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
4 ##
5 ## Copyright 1998-2016 The OpenLDAP Foundation.
6 ## All rights reserved.
7 ##
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
10 ## Public License.
11 ##
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>.
15
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
18
19 if test $SYNCPROV = syncprovno; then
20         echo "Syncrepl provider overlay not available, test skipped"
21         exit 0
22 fi
23 if test $ACCESSLOG = accesslogno; then
24         echo "Accesslog overlay not available, test skipped"
25         exit 0
26 fi
27 if test $DYNLIST = dynlistno; then
28         echo "Accesslog overlay not available, test skipped"
29         exit 0
30 fi
31 if test $MEMBEROF = memberofno; then
32         echo "Memberof overlay not available, test skipped"
33         exit 0
34 fi
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"
38         exit 0
39 fi
40
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."
44
45 MMR=4
46 XDIR=$TESTDIR/srv
47
48 mkdir -p $TESTDIR
49
50 $SLAPPASSWD -g -n >$CONFIGPWF
51
52 ITS=8444
53 ITSDIR=$DATADIR/regressions/its$ITS
54
55 echo "Initializing server configurations..."
56
57 n=1
58 while [ $n -le $MMR ]; do
59         DBDIR=${XDIR}$n/db
60         CFDIR=${XDIR}$n/slapd.d
61
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
65         n=`expr $n + 1`
66 done
67
68 KILLPIDS=
69 n=1
70 while [ $n -le $MMR ]; do
71         MYURI=`eval echo '$URI'$n`
72         MYLOG=`eval echo '$LOG'$n`
73         CFDIR=${XDIR}$n/slapd.d
74
75         echo "Starting provider slapd on TCP/IP URI $MYURI"
76         $SLAPD -F $CFDIR -h $MYURI -d $LVL $TIMING > $MYLOG 2>&1 &
77
78         PID=$!
79         if test $WAIT != 0 ; then
80                 echo PID $PID
81                 read foo
82         fi
83         KILLPIDS="$PID $KILLPIDS"
84         sleep 1
85
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
90                 RC=$?
91                 if test $RC = 0 ; then
92                         break
93                 fi
94                 echo "Waiting 5 seconds for slapd to start..."
95                 sleep 5
96         done
97
98         if test $RC != 0 ; then
99                 echo "ldapsearch failed ($RC)!"
100                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101                 exit $RC
102         fi
103         n=`expr $n + 1`
104 done
105
106 echo "Populating database on first provider..."
107 $LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1
108 dn: $BASEDN
109 objectClass: organization
110 objectClass: dcObject
111 o: Example, Inc.
112 dc: example
113
114 dn: ou=People,$BASEDN
115 objectClass: organizationalUnit
116 ou: People
117
118 dn: ou=Groups,$BASEDN
119 objectClass: organizationalUnit
120 ou: Groups
121
122 dn: cn=Roger Rabbit,ou=People,$BASEDN
123 objectClass: inetOrgPerson
124 cn: Roger Rabbit
125 sn: Rabbit
126
127 dn: cn=Baby Herman,ou=People,$BASEDN
128 objectClass: inetOrgPerson
129 cn: Baby Herman
130 sn: Herman
131
132 dn: cn=Jessica_Rabbit,ou=People,$BASEDN
133 objectClass: inetOrgPerson
134 cn: Jessica_Rabbit
135 sn: Rabbit
136
137 dn: cn=Bugs_Bunny,ou=People,$BASEDN
138 objectClass: inetOrgPerson
139 cn: Bugs_Bunny
140 sn: Bunny
141
142 dn: cn=Daffy_Duck,ou=People,$BASEDN
143 objectClass: inetOrgPerson
144 cn: Daffy_Duck
145 sn: Duck
146
147 dn: cn=Elmer_Fudd,ou=People,$BASEDN
148 objectClass: inetOrgPerson
149 cn: Elmer_Fudd
150 sn: Fudd
151
152 dn: cn=Cartoonia,ou=Groups,$BASEDN
153 objectClass: groupOfNames
154 cn: Cartoonia
155 member: cn=Roger Rabbit,ou=People,$BASEDN
156 member: cn=Baby Herman,ou=People,$BASEDN
157 EOMODS
158
159 RC=$?
160 if test $RC != 0 ; then
161         echo "ldapadd failed ($RC)!"
162         test $KILLSERVERS != no && kill -HUP $KILLPIDS
163         exit $RC
164 fi
165
166 echo "Sleeping 10 seconds to allow replication to initiate..."
167 sleep 10
168
169 echo "Looping 50 times adding and deleting members to the Cartoonia group..."
170 modloop=1
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
177 changetype: modify
178 add: member
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
183 EOF
184
185         sleep 3
186         
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
192 changetype: modify
193 delete: member
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
198 EOF
199         sleep 3
200
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
207                 n=1
208                 while [ $n -le $MMR ]; do
209                         >$SEARCHOUT
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
214                         RC=$?
215                         if test $RC != 0 ; then
216                                 echo "ldapsearch failed ($RC)!"
217                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
218                                 exit $RC
219                         fi
220                         grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
221                         RC=$?
222                         
223                         if test $RC != 1 ; then
224                                 echo "User delete failed on one or more consumer."
225                                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
226                                 exit $RC
227                         fi
228                         n=`expr $n + 1`
229                 done
230         done
231         modloop=`expr $modloop + 1`
232 done
233
234 echo "Looping 50 times deleting and adding Cartoonia group..."
235 modloop=1
236 while [ $modloop -le 50 ]; do
237         >$SEARCHOUT
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
243 changetype: delete
244 EOF
245
246         sleep 3
247
248         echo "Searching entire database on each provider after deleting Cartoonia group"
249
250         n=1
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
256                 RC=$?
257                 if test $RC != 0 ; then
258                         echo "ldapsearch failed ($RC)!"
259                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
260                         exit $RC
261                 fi
262                 n=`expr $n + 1`
263         done
264
265         grep "cn=Cartoonia" $SEARCHOUT >/dev/null 2>&1
266         RC=$?
267
268         if test $RC != 1 ; then
269                 echo "Group delete failed on one or more consumer."
270                 test $KILLSERVERS != no && kill -HUP $KILLPIDS
271                 exit $RC
272         fi
273
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
279 changetype: add
280 objectClass: groupOfNames
281 cn: Cartoonia
282 member: cn=Roger Rabbit,ou=People,$BASEDN
283 member: cn=Baby Herman,ou=People,$BASEDN
284 EOF
285
286         sleep 3
287
288         echo "Searching entire database on each provider after re-adding Cartoonia group"
289
290         n=1
291         while [ $n -le $MMR ]; do
292                 >$SEARCHOUT
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
297                 RC=$?
298                 if test $RC != 0 ; then
299                         echo "ldapsearch failed ($RC)!"
300                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
301                         exit $RC
302                 fi
303                 grep "memberOf:" $SEARCHOUT >/dev/null 2>&1
304                 RC=$?
305                 
306                 if test $RC != 0 ; then
307                         echo "Group add failed on one or more consumer."
308                         test $KILLSERVERS != no && kill -HUP $KILLPIDS
309                         exit $RC
310                 fi
311
312                 n=`expr $n + 1`
313         done
314         modloop=`expr $modloop + 1`
315 done
316
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318
319 echo ">>>>> Test succeeded"
320
321 test $KILLSERVERS != no && wait
322
323 exit 0