1*e670fd5cSchristos#! /bin/sh 2*e670fd5cSchristos## $OpenLDAP$ 3*e670fd5cSchristos## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4*e670fd5cSchristos## 5*e670fd5cSchristos## Copyright 2016-2021 The OpenLDAP Foundation. 6*e670fd5cSchristos## All rights reserved. 7*e670fd5cSchristos## 8*e670fd5cSchristos## Redistribution and use in source and binary forms, with or without 9*e670fd5cSchristos## modification, are permitted only as authorized by the OpenLDAP 10*e670fd5cSchristos## Public License. 11*e670fd5cSchristos## 12*e670fd5cSchristos## A copy of this license is available in the file LICENSE in the 13*e670fd5cSchristos## top-level directory of the distribution or, alternatively, at 14*e670fd5cSchristos## <http://www.OpenLDAP.org/license.html>. 15*e670fd5cSchristos## 16*e670fd5cSchristos## ACKNOWLEDGEMENTS: 17*e670fd5cSchristos## This module was written in 2016-2017 by Ondřej Kuzník for Symas Corp. 18*e670fd5cSchristos 19*e670fd5cSchristosOVERLAY_CONFIG=${OVERLAY_CONFIG-data/config.ldif} 20*e670fd5cSchristos 21*e670fd5cSchristosmkdir -p $TESTDIR $DBDIR1 22*e670fd5cSchristos 23*e670fd5cSchristosecho "Running slapadd to build slapd database..." 24*e670fd5cSchristos. $CONFFILTER $BACKEND $MONITORDB < $CONF > $ADDCONF 25*e670fd5cSchristos$SLAPADD -f $ADDCONF -l $LDIFORDERED 26*e670fd5cSchristosRC=$? 27*e670fd5cSchristosif test $RC != 0 ; then 28*e670fd5cSchristos echo "slapadd failed ($RC)!" 29*e670fd5cSchristos exit $RC 30*e670fd5cSchristosfi 31*e670fd5cSchristos 32*e670fd5cSchristosmkdir $TESTDIR/confdir 33*e670fd5cSchristos. $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1 34*e670fd5cSchristos 35*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF 36*e670fd5cSchristosecho "database config" >>$CONF1 37*e670fd5cSchristosecho "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >>$CONF1 38*e670fd5cSchristos 39*e670fd5cSchristosecho "Starting slapd on TCP/IP port $PORT1 for configuration..." 40*e670fd5cSchristos$SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL > $LOG1 2>&1 & 41*e670fd5cSchristosPID=$! 42*e670fd5cSchristosif test $WAIT != 0 ; then 43*e670fd5cSchristos echo PID $PID 44*e670fd5cSchristos read foo 45*e670fd5cSchristosfi 46*e670fd5cSchristosKILLPIDS="$PID" 47*e670fd5cSchristos 48*e670fd5cSchristossleep $SLEEP0 49*e670fd5cSchristos 50*e670fd5cSchristosfor i in 0 1 2 3 4 5; do 51*e670fd5cSchristos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 52*e670fd5cSchristos 'objectclass=*' > /dev/null 2>&1 53*e670fd5cSchristos RC=$? 54*e670fd5cSchristos if test $RC = 0 ; then 55*e670fd5cSchristos break 56*e670fd5cSchristos fi 57*e670fd5cSchristos echo "Waiting ${SLEEP1} seconds for slapd to start..." 58*e670fd5cSchristos sleep ${SLEEP1} 59*e670fd5cSchristosdone 60*e670fd5cSchristos 61*e670fd5cSchristosecho "Making a modification that will be hidden by the test config..." 62*e670fd5cSchristos$LDAPMODIFY -D $MANAGERDN -H $URI1 -w $PASSWD \ 63*e670fd5cSchristos -f data/hidden.ldif >> $TESTOUT 2>&1 64*e670fd5cSchristosRC=$? 65*e670fd5cSchristosif test $RC != 0 ; then 66*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 67*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 68*e670fd5cSchristos exit $RC 69*e670fd5cSchristosfi 70*e670fd5cSchristos 71*e670fd5cSchristos$LDAPSEARCH -D cn=config -H $URI1 -y $CONFIGPWF \ 72*e670fd5cSchristos -s base -b 'cn=module{0},cn=config' 1.1 >$TESTOUT 2>&1 73*e670fd5cSchristosRC=$? 74*e670fd5cSchristoscase $RC in 75*e670fd5cSchristos0) 76*e670fd5cSchristos $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 77*e670fd5cSchristos >> $TESTOUT 2>&1 <<EOMOD 78*e670fd5cSchristosdn: cn=module{0},cn=config 79*e670fd5cSchristoschangetype: modify 80*e670fd5cSchristosadd: olcModuleLoad 81*e670fd5cSchristosolcModuleLoad: `pwd`/../variant.la 82*e670fd5cSchristosEOMOD 83*e670fd5cSchristos ;; 84*e670fd5cSchristos32) 85*e670fd5cSchristos $LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 86*e670fd5cSchristos >> $TESTOUT 2>&1 <<EOMOD 87*e670fd5cSchristosdn: cn=module,cn=config 88*e670fd5cSchristoschangetype: add 89*e670fd5cSchristosobjectClass: olcModuleList 90*e670fd5cSchristosolcModuleLoad: `pwd`/../variant.la 91*e670fd5cSchristosEOMOD 92*e670fd5cSchristos ;; 93*e670fd5cSchristos*) 94*e670fd5cSchristos echo "Failed testing for module load entry" 95*e670fd5cSchristos exit $RC; 96*e670fd5cSchristos ;; 97*e670fd5cSchristosesac 98*e670fd5cSchristos 99*e670fd5cSchristosRC=$? 100*e670fd5cSchristosif test $RC != 0 ; then 101*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 102*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 103*e670fd5cSchristos exit $RC 104*e670fd5cSchristosfi 105*e670fd5cSchristos 106*e670fd5cSchristosecho "Loading test variant configuration..." 107*e670fd5cSchristos. $CONFFILTER $BACKEND $MONITORDB < $OVERLAY_CONFIG | \ 108*e670fd5cSchristos$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \ 109*e670fd5cSchristos > $TESTOUT 2>&1 110*e670fd5cSchristosRC=$? 111*e670fd5cSchristosif test $RC != 0 ; then 112*e670fd5cSchristos echo "ldapmodify failed ($RC)!" 113*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 114*e670fd5cSchristos exit $RC 115*e670fd5cSchristosfi 116