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 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*e670fd5cSchristosecho "running defines.sh" 17*e670fd5cSchristos. $SRCDIR/scripts/defines.sh 18*e670fd5cSchristos 19*e670fd5cSchristosif test $DEREF = derefno; then 20*e670fd5cSchristos echo "Deref overlay not available, test skipped" 21*e670fd5cSchristos exit 0 22*e670fd5cSchristosfi 23*e670fd5cSchristos 24*e670fd5cSchristosmkdir -p $TESTDIR $DBDIR1 25*e670fd5cSchristos 26*e670fd5cSchristos$SLAPPASSWD -g -n >$CONFIGPWF 27*e670fd5cSchristosecho "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf 28*e670fd5cSchristos 29*e670fd5cSchristosecho "Running slapadd to build slapd database..." 30*e670fd5cSchristos. $CONFFILTER $BACKEND < $DEREFCONF > $CONF1 31*e670fd5cSchristos$SLAPADD -f $CONF1 -l $LDIFDEREF 32*e670fd5cSchristosRC=$? 33*e670fd5cSchristosif test $RC != 0 ; then 34*e670fd5cSchristos echo "slapadd failed ($RC)!" 35*e670fd5cSchristos exit $RC 36*e670fd5cSchristosfi 37*e670fd5cSchristos 38*e670fd5cSchristosecho "Starting slapd on TCP/IP port $PORT1..." 39*e670fd5cSchristos$SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 40*e670fd5cSchristosPID=$! 41*e670fd5cSchristosif test $WAIT != 0 ; then 42*e670fd5cSchristos echo PID $PID 43*e670fd5cSchristos read foo 44*e670fd5cSchristosfi 45*e670fd5cSchristosKILLPIDS="$PID" 46*e670fd5cSchristos 47*e670fd5cSchristossleep 1 48*e670fd5cSchristos 49*e670fd5cSchristosecho "Testing slapd deref control operations..." 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 5 seconds for slapd to start..." 58*e670fd5cSchristos sleep 5 59*e670fd5cSchristosdone 60*e670fd5cSchristos 61*e670fd5cSchristosif test $RC != 0 ; then 62*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 63*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 64*e670fd5cSchristos exit $RC 65*e670fd5cSchristosfi 66*e670fd5cSchristos 67*e670fd5cSchristosecho "Sending deref control..." 68*e670fd5cSchristos 69*e670fd5cSchristos$LDAPSEARCH -b "$DEREFBASEDN" -H $URI1 \ 70*e670fd5cSchristos -E 'deref=member:uid' > $SEARCHOUT 2>&1 71*e670fd5cSchristos 72*e670fd5cSchristosRC=$? 73*e670fd5cSchristosif test $RC != 0 ; then 74*e670fd5cSchristos echo "ldapsearch failed ($RC)!" 75*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 76*e670fd5cSchristos exit $RC 77*e670fd5cSchristosfi 78*e670fd5cSchristos 79*e670fd5cSchristosecho "Comparing output..." 80*e670fd5cSchristos$CMP $SEARCHOUT $DEREFOUT > $CMPOUT 81*e670fd5cSchristos 82*e670fd5cSchristosif test $? != 0 ; then 83*e670fd5cSchristos echo "Comparison failed" 84*e670fd5cSchristos test $KILLSERVERS != no && kill -HUP $KILLPIDS 85*e670fd5cSchristos exit 1 86*e670fd5cSchristosfi 87*e670fd5cSchristos 88*e670fd5cSchristostest $KILLSERVERS != no && kill -HUP $KILLPIDS 89*e670fd5cSchristos 90*e670fd5cSchristostest $KILLSERVERS != no && wait 91*e670fd5cSchristos 92*e670fd5cSchristosecho ">>>>> Test succeeded" 93*e670fd5cSchristos 94*e670fd5cSchristosexit 0 95