1#! /bin/sh 2## $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 2016-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## 16## ACKNOWLEDGEMENTS: 17## This module was written in 2016-2017 by Ond��ej Kuzn��k for Symas Corp. 18 19OVERLAY_CONFIG=${OVERLAY_CONFIG-data/config.ldif} 20 21mkdir -p $TESTDIR $DBDIR1 22 23echo "Running slapadd to build slapd database..." 24. $CONFFILTER $BACKEND $MONITORDB < $CONF > $ADDCONF 25$SLAPADD -f $ADDCONF -l $LDIFORDERED 26RC=$? 27if test $RC != 0 ; then 28 echo "slapadd failed ($RC)!" 29 exit $RC 30fi 31 32mkdir $TESTDIR/confdir 33. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1 34 35$SLAPPASSWD -g -n >$CONFIGPWF 36echo "database config" >>$CONF1 37echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >>$CONF1 38 39echo "Starting slapd on TCP/IP port $PORT1 for configuration..." 40$SLAPD -f $CONF1 -F $TESTDIR/confdir -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 $SLEEP0 49 50for i in 0 1 2 3 4 5; do 51 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 52 'objectclass=*' > /dev/null 2>&1 53 RC=$? 54 if test $RC = 0 ; then 55 break 56 fi 57 echo "Waiting ${SLEEP1} seconds for slapd to start..." 58 sleep ${SLEEP1} 59done 60 61echo "Making a modification that will be hidden by the test config..." 62$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 63 -f data/hidden.ldif >> $TESTOUT 2>&1 64RC=$? 65if test $RC != 0 ; then 66 echo "ldapmodify failed ($RC)!" 67 test $KILLSERVERS != no && kill -HUP $KILLPIDS 68 exit $RC 69fi 70 71$LDAPSEARCH -D cn=config -H $URI1 -y $CONFIGPWF \ 72 -s base -b 'cn=module{0},cn=config' 1.1 >$TESTOUT 2>&1 73RC=$? 74case $RC in 750) 76 $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 77 >> $TESTOUT 2>&1 <<EOMOD 78dn: cn=module{0},cn=config 79changetype: modify 80add: olcModuleLoad 81olcModuleLoad: `pwd`/../variant.la 82EOMOD 83 ;; 8432) 85 $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 86 >> $TESTOUT 2>&1 <<EOMOD 87dn: cn=module,cn=config 88changetype: add 89objectClass: olcModuleList 90olcModuleLoad: `pwd`/../variant.la 91EOMOD 92 ;; 93*) 94 echo "Failed testing for module load entry" 95 exit $RC; 96 ;; 97esac 98 99RC=$? 100if test $RC != 0 ; then 101 echo "ldapmodify failed ($RC)!" 102 test $KILLSERVERS != no && kill -HUP $KILLPIDS 103 exit $RC 104fi 105 106echo "Loading test variant configuration..." 107. $CONFFILTER $BACKEND $MONITORDB < $OVERLAY_CONFIG | \ 108$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 109 > $TESTOUT 2>&1 110RC=$? 111if test $RC != 0 ; then 112 echo "ldapmodify failed ($RC)!" 113 test $KILLSERVERS != no && kill -HUP $KILLPIDS 114 exit $RC 115fi 116