1#! /bin/sh 2# $OpenLDAP$ */ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 1998-2021 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 16echo "running defines.sh" 17. $SRCDIR/scripts/defines.sh 18 19if test $SYNCPROV = syncprovno; then 20 echo "Syncrepl provider overlay not available, test skipped" 21 exit 0 22fi 23 24mkdir -p $TESTDIR $DBDIR1A $DBDIR1B $DBDIR1C $DBDIR2A $DBDIR2B 25 26echo "Running slapadd to build glued slapd databases..." 27. $CONFFILTER $BACKEND < $GLUECONF > $CONF1 28$SLAPADD -d $LVL -f $CONF1 -l $LDIFORDERED > $SLAPADDLOG1 2>&1 29RC=$? 30if test $RC != 0 ; then 31 echo "slapadd failed ($RC)!" 32 exit $RC 33fi 34 35rm -rf $DBDIR1A/* $DBDIR1B/* 36cp -pr $DBDIR1C $DBDIR2C 37 38echo "Starting slapd 1 on TCP/IP port $PORT1..." 39. $CONFFILTER $BACKEND < $GLUESYNCCONF1 > $CONF1 40$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 41PID=$! 42if test $WAIT != 0 ; then 43 echo PID $PID 44 read foo 45fi 46KILLPIDS="$PID" 47 48sleep 1 49 50echo "Using ldapsearch to check that slapd 1 is running..." 51for 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 60done 61 62echo "Starting slapd 2 on TCP/IP port $PORT2..." 63. $CONFFILTER $BACKEND < $GLUESYNCCONF2 > $CONF2 64$SLAPD -f $CONF2 -h $URI2 -d $LVL > $LOG2 2>&1 & 65PID=$! 66if test $WAIT != 0 ; then 67 echo PID $PID 68 read foo 69fi 70KILLPIDS="$KILLPIDS $PID" 71 72sleep 1 73 74echo "Using ldapsearch to check that slapd 2 is running..." 75for 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 84done 85 86SUBTREE1="ou=Information Technology Division,ou=People,dc=example,dc=com" 87SUBTREE2="ou=Groups,dc=example,dc=com" 88 89echo "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 93RC=$? 94case $RC in 950) 96 echo "ldapadd should have failed ($RC)!" 97 test $KILLSERVERS != no && kill -HUP $KILLPIDS 98 exit -1 99 ;; 10010|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 ;; 108esac 109 110echo "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 114RC=$? 115case $RC in 1160) 117 echo "ldapadd should have failed ($RC)!" 118 test $KILLSERVERS != no && kill -HUP $KILLPIDS 119 exit -1 120 ;; 12110|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 ;; 129esac 130 131echo "Waiting $SLEEP1 seconds for shadow subtrees to sync..." 132sleep $SLEEP1 133 134echo "Filtering original ldif used to create database..." 135$LDIFFILTER < $GLUESYNCOUT > $LDIFFLT 136 137for 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 160done 161 162echo "Testing ldapdelete propagation..." 163$LDAPDELETE -D "cn=Manager 1,$BASEDN" -w $PASSWD -H $URI1 "$BABSDN" \ 164 > $TESTOUT 2>&1 165RC=$? 166if test $RC != 0 ; then 167 echo "ldapdelete failed ($RC)!" 168 test $KILLSERVERS != no && kill -HUP $KILLPIDS 169 exit $RC 170fi 171 172# This usually propagates immediately 173sleep 1 174 175$LDAPSEARCH -H $URI2 -b "$BABSDN" > $TESTOUT 2>&1 176RC=$? 177if test $RC = 0 && test $BACKEND != null ; then 178 echo "ldapsearch should have failed ($RC)!" 179 test $KILLSERVERS != no && kill -HUP $KILLPIDS 180 exit -1 181fi 182 183test $KILLSERVERS != no && kill -HUP $KILLPIDS 184 185echo ">>>>> Test succeeded" 186 187test $KILLSERVERS != no && wait 188 189exit 0 190