| 1 |
#! /bin/sh |
| 2 |
# $OpenLDAP$ |
| 3 |
## This work is part of OpenLDAP Software <http://www.openldap.org/>. |
| 4 |
## |
| 5 |
## Copyright 1998-2024 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 "This test is no longer valid after the fixes in ITS#9015" |
| 17 |
echo "https://bugs.openldap.org/show_bug.cgi?id=9015" |
| 18 |
exit 0 |
| 19 |
|
| 20 |
echo "running defines.sh" |
| 21 |
. $SRCDIR/scripts/defines.sh |
| 22 |
|
| 23 |
if test $SYNCPROV = syncprovno; then |
| 24 |
echo "Syncrepl provider overlay not available, test skipped" |
| 25 |
exit 0 |
| 26 |
fi |
| 27 |
|
| 28 |
echo "" |
| 29 |
echo " This test tracks a case where a consumer fails to replicate from the provider" |
| 30 |
echo " when the provider is dynamically configured for replication." |
| 31 |
echo " See https://bugs.openldap.org/show_bug.cgi?id=8521 and" |
| 32 |
echo " See https://bugs.openldap.org/show_bug.cgi?id=8281 for more information." |
| 33 |
echo "" |
| 34 |
|
| 35 |
PRODIR=$TESTDIR/pro |
| 36 |
CONDIR=$TESTDIR/con1 |
| 37 |
CFPRO=$PRODIR/slapd.d |
| 38 |
CFCON=$CONDIR/slapd.d |
| 39 |
|
| 40 |
mkdir -p $TESTDIR $DBDIR1 $DBDIR2 $PRODIR $CONDIR $CFPRO $CFCON |
| 41 |
|
| 42 |
$SLAPPASSWD -g -n >$CONFIGPWF |
| 43 |
|
| 44 |
ITS=8521 |
| 45 |
ITSDIR=$DATADIR/regressions/its$ITS |
| 46 |
|
| 47 |
echo "Starting provider slapd on TCP/IP port $PORT1..." |
| 48 |
. $CONFFILTER $BACKEND < $ITSDIR/slapd-provider.ldif > $CONFLDIF |
| 49 |
$SLAPADD -F $CFPRO -n 0 -l $CONFLDIF |
| 50 |
$SLAPD -F $CFPRO -h $URI1 -d $LVL > $LOG1 2>&1 & |
| 51 |
PID=$! |
| 52 |
if test $WAIT != 0 ; then |
| 53 |
echo PID $PID |
| 54 |
read foo |
| 55 |
fi |
| 56 |
KILLPIDS="$PID" |
| 57 |
|
| 58 |
sleep 1 |
| 59 |
|
| 60 |
echo "Using ldapsearch to check that provider slapd is running..." |
| 61 |
for i in 0 1 2 3 4 5; do |
| 62 |
$LDAPSEARCH -s base -b "" -H $URI1 \ |
| 63 |
'objectclass=*' > /dev/null 2>&1 |
| 64 |
RC=$? |
| 65 |
if test $RC = 0 ; then |
| 66 |
break |
| 67 |
fi |
| 68 |
echo "Waiting 5 seconds for slapd to start..." |
| 69 |
sleep 5 |
| 70 |
done |
| 71 |
|
| 72 |
if test $RC != 0 ; then |
| 73 |
echo "ldapsearch failed ($RC)!" |
| 74 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 75 |
exit $RC |
| 76 |
fi |
| 77 |
|
| 78 |
echo "Starting consumer slapd on TCP/IP port $PORT2..." |
| 79 |
. $CONFFILTER $BACKEND < $ITSDIR/slapd-consumer.ldif > $CONFLDIF |
| 80 |
$SLAPADD -F $CFCON -n 0 -l $CONFLDIF |
| 81 |
$SLAPD -F $CFCON -h $URI2 -d $LVL > $LOG2 2>&1 & |
| 82 |
SLAVEPID=$! |
| 83 |
if test $WAIT != 0 ; then |
| 84 |
echo SLAVEPID $SLAVEPID |
| 85 |
read foo |
| 86 |
fi |
| 87 |
KILLPIDS="$KILLPIDS $SLAVEPID" |
| 88 |
|
| 89 |
sleep 1 |
| 90 |
|
| 91 |
echo "Using ldapsearch to check that consumer slapd is running..." |
| 92 |
for i in 0 1 2 3 4 5; do |
| 93 |
$LDAPSEARCH -s base -b "" -H $URI2 \ |
| 94 |
'objectclass=*' > /dev/null 2>&1 |
| 95 |
RC=$? |
| 96 |
if test $RC = 0 ; then |
| 97 |
break |
| 98 |
fi |
| 99 |
echo "Waiting 5 seconds for slapd to start..." |
| 100 |
sleep 5 |
| 101 |
done |
| 102 |
|
| 103 |
if test $RC != 0 ; then |
| 104 |
echo "ldapsearch failed ($RC)!" |
| 105 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 106 |
exit $RC |
| 107 |
fi |
| 108 |
|
| 109 |
echo "Setting serverID on provider..." |
| 110 |
$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 |
| 111 |
dn: cn=config |
| 112 |
changetype: modify |
| 113 |
add: olcServerId |
| 114 |
olcServerId: 1 |
| 115 |
EOF |
| 116 |
RC=$? |
| 117 |
|
| 118 |
if test $RC != 0 ; then |
| 119 |
echo "ldapmodify failed ($RC)!" |
| 120 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 121 |
exit $RC |
| 122 |
fi |
| 123 |
|
| 124 |
echo "Populating database on provider..." |
| 125 |
$LDAPADD -D $MANAGERDN -H $URI1 -w $PASSWD << EOMODS >> $TESTOUT 2>&1 |
| 126 |
dn: dc=example,dc=com |
| 127 |
changetype: add |
| 128 |
objectClass: domain |
| 129 |
objectClass: top |
| 130 |
dc: example |
| 131 |
|
| 132 |
dn: ou=LDAPRoles,dc=example,dc=com |
| 133 |
objectClass: top |
| 134 |
objectClass: organizationalUnit |
| 135 |
ou: LDAPRoles |
| 136 |
|
| 137 |
dn: dc=users,dc=example,dc=com |
| 138 |
changetype: add |
| 139 |
dc: users |
| 140 |
objectClass: domain |
| 141 |
objectClass: top |
| 142 |
|
| 143 |
dn: uid=johndoe,dc=users,dc=example,dc=com |
| 144 |
changetype: add |
| 145 |
objectClass: inetOrgPerson |
| 146 |
objectClass: top |
| 147 |
sn: Doe |
| 148 |
cn: Johndoe |
| 149 |
uid: johndoe |
| 150 |
|
| 151 |
dn: cn=replicator,ou=LDAPRoles,dc=example,dc=com |
| 152 |
objectClass: top |
| 153 |
objectClass: simpleSecurityObject |
| 154 |
objectClass: organizationalRole |
| 155 |
userPassword: secret |
| 156 |
cn: replicator |
| 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 |
if [ "$SYNCPROV" = syncprovmod ]; then |
| 167 |
echo "Configuring syncprov module on the provider..." |
| 168 |
$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1 |
| 169 |
dn: cn=module,cn=config |
| 170 |
objectClass: olcModuleList |
| 171 |
cn: module |
| 172 |
olcModulePath: $TESTWD/../servers/slapd/overlays |
| 173 |
olcModuleLoad: syncprov.la |
| 174 |
EOF |
| 175 |
RC=$? |
| 176 |
if test $RC != 0 ; then |
| 177 |
echo "ldapadd failed for moduleLoad ($RC)!" |
| 178 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 179 |
exit $RC |
| 180 |
fi |
| 181 |
fi |
| 182 |
|
| 183 |
echo "Configuring replication on the provider..." |
| 184 |
$LDAPMODIFY -D cn=config -H $URI1 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 |
| 185 |
dn: olcOverlay=syncprov,olcDatabase={1}$BACKEND,cn=config |
| 186 |
changetype: add |
| 187 |
objectClass: olcOverlayConfig |
| 188 |
objectClass: olcConfig |
| 189 |
objectClass: top |
| 190 |
objectClass: olcSyncprovConfig |
| 191 |
olcOverlay: syncprov |
| 192 |
olcSpSessionLog: 10000 |
| 193 |
olcSpCheckpoint: 100 10 |
| 194 |
|
| 195 |
dn: olcDatabase={1}$BACKEND,cn=config |
| 196 |
changetype: modify |
| 197 |
add: olcLimits |
| 198 |
olcLimits: dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com" |
| 199 |
time.soft=unlimited time.hard=unlimited size.soft=unlimited |
| 200 |
size.hard=unlimited |
| 201 |
|
| 202 |
dn: olcDatabase={1}$BACKEND,cn=config |
| 203 |
changetype: modify |
| 204 |
replace: olcAccess |
| 205 |
olcAccess: {0}to dn.subtree="dc=example,dc=com" by self write |
| 206 |
by dn.exact="cn=replicator,ou=LDAPRoles,dc=example,dc=com" read |
| 207 |
by anonymous auth by * read |
| 208 |
EOF |
| 209 |
|
| 210 |
RC=$? |
| 211 |
if test $RC != 0 ; then |
| 212 |
echo "ldapmodify failed ($RC)!" |
| 213 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 214 |
exit $RC |
| 215 |
fi |
| 216 |
|
| 217 |
echo "Configuring replication on the consumer..." |
| 218 |
$LDAPMODIFY -D cn=config -H $URI2 -y $CONFIGPWF <<EOF >>$TESTOUT 2>&1 |
| 219 |
dn: olcDatabase={1}$BACKEND,cn=config |
| 220 |
changetype: modify |
| 221 |
add: olcSyncrepl |
| 222 |
olcSyncrepl: rid=100 provider=$URI1 bindmethod=simple |
| 223 |
binddn="cn=replicator,ou=LDAPRoles,dc=example,dc=com" credentials=secret |
| 224 |
type=refreshAndPersist searchbase="dc=example,dc=com" filter="(objectclass=*)" |
| 225 |
scope=sub schemachecking=on interval=5 retry="5 +" sizeLimit=unlimited |
| 226 |
timelimit=unlimited |
| 227 |
- |
| 228 |
|
| 229 |
EOF |
| 230 |
RC=$? |
| 231 |
if test $RC != 0 ; then |
| 232 |
echo "ldapmodify failed for olcSyncrepl configuration ($RC)!" |
| 233 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 234 |
exit $RC |
| 235 |
fi |
| 236 |
|
| 237 |
echo "Sleeping 10 seconds to allow replication to initiate..." |
| 238 |
sleep 10 |
| 239 |
|
| 240 |
echo "Using ldapsearch to read all the entries from the provider..." |
| 241 |
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI1 \ |
| 242 |
'(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1 |
| 243 |
RC=$? |
| 244 |
|
| 245 |
if test $RC != 0 ; then |
| 246 |
echo "ldapsearch failed at provider ($RC)!" |
| 247 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 248 |
exit $RC |
| 249 |
fi |
| 250 |
|
| 251 |
echo "Using ldapsearch to read all the entries from the consumer..." |
| 252 |
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI2 \ |
| 253 |
'(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1 |
| 254 |
RC=$? |
| 255 |
|
| 256 |
if test $RC != 32 ; then |
| 257 |
echo "ldapsearch should have failed with error 32. Got $RC instead!" |
| 258 |
echo "This is a regression of ITS8281" |
| 259 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 260 |
exit $RC |
| 261 |
fi |
| 262 |
|
| 263 |
|
| 264 |
echo "Filtering provider results..." |
| 265 |
$LDIFFILTER < $MASTEROUT > $MASTERFLT |
| 266 |
echo "Filtering consumer results..." |
| 267 |
$LDIFFILTER < $SLAVEOUT > $SLAVEFLT |
| 268 |
|
| 269 |
echo "Comparing retrieved entries from provider and consumer..." |
| 270 |
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT |
| 271 |
|
| 272 |
if test $? = 0 ; then |
| 273 |
echo "test failed - provider and consumer databases match" |
| 274 |
echo "This is a regression of ITS8281" |
| 275 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 276 |
exit 1 |
| 277 |
fi |
| 278 |
|
| 279 |
echo "Modifying provider to force generation of a contextCSN" |
| 280 |
$LDAPMODIFY -v -D "$MANAGERDN" -H $URI1 -w $PASSWD > \ |
| 281 |
$TESTOUT 2>&1 << EOMODS |
| 282 |
dn: uid=Johndoe,dc=users,dc=example,dc=com |
| 283 |
changetype: modify |
| 284 |
replace: cn |
| 285 |
cn: John Doe |
| 286 |
EOMODS |
| 287 |
|
| 288 |
echo "Sleeping 30 seconds to allow consumer to reconnect and replicate..." |
| 289 |
sleep 30 |
| 290 |
|
| 291 |
echo "Using ldapsearch to read all the entries from the provider..." |
| 292 |
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI1 \ |
| 293 |
'(objectclass=*)' '*' $OPATTRS > $MASTEROUT 2>&1 |
| 294 |
RC=$? |
| 295 |
|
| 296 |
if test $RC != 0 ; then |
| 297 |
echo "ldapsearch failed at provider ($RC)!" |
| 298 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 299 |
exit $RC |
| 300 |
fi |
| 301 |
|
| 302 |
echo "Using ldapsearch to read all the entries from the consumer..." |
| 303 |
$LDAPSEARCH -S "" -D $MANAGERDN -w $PASSWD -b "$BASEDN" -H $URI2 \ |
| 304 |
'(objectclass=*)' '*' $OPATTRS > $SLAVEOUT 2>&1 |
| 305 |
RC=$? |
| 306 |
|
| 307 |
if test $RC != 0 ; then |
| 308 |
echo "ldapsearch failed at consumer ($RC)!" |
| 309 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 310 |
exit $RC |
| 311 |
fi |
| 312 |
|
| 313 |
|
| 314 |
echo "Filtering provider results..." |
| 315 |
$LDIFFILTER < $MASTEROUT > $MASTERFLT |
| 316 |
echo "Filtering consumer results..." |
| 317 |
$LDIFFILTER < $SLAVEOUT > $SLAVEFLT |
| 318 |
|
| 319 |
echo "Comparing retrieved entries from provider and consumer..." |
| 320 |
$CMP $MASTERFLT $SLAVEFLT > $CMPOUT |
| 321 |
|
| 322 |
if test $? != 0 ; then |
| 323 |
echo "test failed - provider and consumer databases differ" |
| 324 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 325 |
exit 1 |
| 326 |
fi |
| 327 |
|
| 328 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 329 |
|
| 330 |
echo |
| 331 |
echo ">>>>> Test succeeded" |
| 332 |
|
| 333 |
test $KILLSERVERS != no && wait |
| 334 |
|
| 335 |
exit 0 |