| 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 "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 |
|
| 24 |
mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B |
| 25 |
|
| 26 |
echo "Running slapadd to build glued slapd databases..." |
| 27 |
. $CONFFILTER $BACKEND < $GLUECONF > $CONF1 |
| 28 |
$SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1 |
| 29 |
RC=$? |
| 30 |
if test $RC != 0 ; then |
| 31 |
echo "slapadd failed ($RC)!" |
| 32 |
exit $RC |
| 33 |
fi |
| 34 |
|
| 35 |
rm -rf $DBDIR1A/* $DBDIR1B/* |
| 36 |
cp -pr $DBDIR1C $DBDIR2C |
| 37 |
|
| 38 |
echo "Starting slapd 1 on TCP/IP port $PORT1..." |
| 39 |
. $CONFFILTER $BACKEND < $GLUESYNCCONF1 > $CONF1 |
| 40 |
$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & |
| 41 |
PID=$! |
| 42 |
if test $WAIT != 0 ; then |
| 43 |
echo PID $PID |
| 44 |
read foo |
| 45 |
fi |
| 46 |
KILLPIDS="$PID" |
| 47 |
|
| 48 |
sleep 1 |
| 49 |
|
| 50 |
echo "Using ldapsearch to check that slapd 1 is running..." |
| 51 |
for i in 0 1 2 3 4 5; do |
| 52 |
$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ |
| 53 |
'(objectclass=*)' > /dev/null 2>&1 |
| 54 |
RC=$? |
| 55 |
if test $RC = 0 ; then |
| 56 |
break |
| 57 |
fi |
| 58 |
echo "Waiting 5 seconds for slapd to start..." |
| 59 |
sleep 5 |
| 60 |
done |
| 61 |
|
| 62 |
echo "Starting slapd 2 on TCP/IP port $PORT2..." |
| 63 |
. $CONFFILTER $BACKEND < $GLUESYNCCONF2 > $CONF2 |
| 64 |
$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & |
| 65 |
PID=$! |
| 66 |
if test $WAIT != 0 ; then |
| 67 |
echo PID $PID |
| 68 |
read foo |
| 69 |
fi |
| 70 |
KILLPIDS="$KILLPIDS $PID" |
| 71 |
|
| 72 |
sleep 1 |
| 73 |
|
| 74 |
echo "Using ldapsearch to check that slapd 2 is running..." |
| 75 |
for i in 0 1 2 3 4 5; do |
| 76 |
$LDAPSEARCH -s base -b "$MONITOR" -H $URI2 \ |
| 77 |
'(objectclass=*)' > /dev/null 2>&1 |
| 78 |
RC=$? |
| 79 |
if test $RC = 0 ; then |
| 80 |
break |
| 81 |
fi |
| 82 |
echo "Waiting 5 seconds for slapd to start..." |
| 83 |
sleep 5 |
| 84 |
done |
| 85 |
|
| 86 |
SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com" |
| 87 |
SUBTREE2="ou=Groups,dc=example,dc=com" |
| 88 |
|
| 89 |
echo "Using ldapadd to populate subtree=\"${SUBTREE1}\" on port $PORT1..." |
| 90 |
$LDAPADD -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 \ |
| 91 |
-f $LDIFORDERED -c \ |
| 92 |
> /dev/null 2>&1 |
| 93 |
RC=$? |
| 94 |
case $RC in |
| 95 |
0) |
| 96 |
echo "ldapadd should have failed ($RC)!" |
| 97 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 98 |
exit 1 |
| 99 |
;; |
| 100 |
10|68) |
| 101 |
# Fine if we get alreadyExists or referrals |
| 102 |
;; |
| 103 |
*) |
| 104 |
echo "ldapadd failed ($RC)!" |
| 105 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 106 |
exit $RC |
| 107 |
;; |
| 108 |
esac |
| 109 |
|
| 110 |
echo "Using ldapadd to populate subtree=\"${SUBTREE2}\" on port $PORT2..." |
| 111 |
$LDAPADD -D "cn=Manager 2,$BASEDN" -w $PASSWD -H $URI2 \ |
| 112 |
-f $LDIFORDERED -c \ |
| 113 |
> /dev/null 2>&1 |
| 114 |
RC=$? |
| 115 |
case $RC in |
| 116 |
0) |
| 117 |
echo "ldapadd should have failed ($RC)!" |
| 118 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 119 |
exit 1 |
| 120 |
;; |
| 121 |
10|68) |
| 122 |
# Fine if we get alreadyExists or referrals |
| 123 |
;; |
| 124 |
*) |
| 125 |
echo "ldapadd failed ($RC)!" |
| 126 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 127 |
exit $RC |
| 128 |
;; |
| 129 |
esac |
| 130 |
|
| 131 |
echo "Waiting $SLEEP1 seconds for shadow subtrees to sync..." |
| 132 |
sleep $SLEEP1 |
| 133 |
|
| 134 |
echo "Filtering original ldif used to create database..." |
| 135 |
$LDIFFILTER < $GLUESYNCOUT > $LDIFFLT |
| 136 |
|
| 137 |
for n in 1 2 ; do |
| 138 |
URI=`eval echo '$URI'$n` |
| 139 |
echo "Using ldapsearch to read all the entries from server $n..." |
| 140 |
$LDAPSEARCH -b "$BASEDN" -H $URI \ |
| 141 |
-S "" '(objectclass=*)' > "${SEARCHOUT}.${n}" 2>&1 |
| 142 |
RC=$? |
| 143 |
|
| 144 |
if test $RC != 0 ; then |
| 145 |
echo "ldapsearch failed ($RC)!" |
| 146 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 147 |
exit $RC |
| 148 |
fi |
| 149 |
|
| 150 |
echo "Filtering ldapsearch results..." |
| 151 |
$LDIFFILTER < "${SEARCHOUT}.${n}" > $SEARCHFLT |
| 152 |
echo "Comparing filter output..." |
| 153 |
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT |
| 154 |
|
| 155 |
if test $? != 0 ; then |
| 156 |
echo "comparison failed - database was not created correctly" |
| 157 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 158 |
exit 1 |
| 159 |
fi |
| 160 |
done |
| 161 |
|
| 162 |
echo "Testing ldapdelete propagation..." |
| 163 |
$LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \ |
| 164 |
> $TESTOUT 2>&1 |
| 165 |
RC=$? |
| 166 |
if test $RC != 0 ; then |
| 167 |
echo "ldapdelete failed ($RC)!" |
| 168 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 169 |
exit $RC |
| 170 |
fi |
| 171 |
|
| 172 |
# This usually propagates immediately |
| 173 |
sleep $SLEEP1 |
| 174 |
|
| 175 |
$LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1 |
| 176 |
RC=$? |
| 177 |
if test $RC = 0 && test $BACKEND != null ; then |
| 178 |
echo "ldapsearch should have failed ($RC)!" |
| 179 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 180 |
exit 1 |
| 181 |
fi |
| 182 |
|
| 183 |
test $KILLSERVERS != no && kill -HUP $KILLPIDS |
| 184 |
|
| 185 |
echo ">>>>> Test succeeded" |
| 186 |
|
| 187 |
test $KILLSERVERS != no && wait |
| 188 |
|
| 189 |
exit 0 |