1#!/bin/sh 2# $OpenLDAP$ 3## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4## 5## Copyright 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 $ARGON2 = argon2no; then 20 echo "argon2 overlay not available, test skipped" 21 exit 0 22fi 23 24USERDN="cn=argon2,$BASEDN" 25 26CONFDIR=$TESTDIR/slapd.d 27mkdir -p $TESTDIR $CONFDIR $DBDIR1 28 29$SLAPPASSWD -g -n >$CONFIGPWF 30 31cat > $TESTDIR/config.ldif <<EOF 32dn: cn=config 33objectClass: olcGlobal 34cn: config 35olcArgsFile: $TESTDIR/slapd.args 36olcPidFile: $TESTDIR/slapd.pid 37 38dn: cn=schema,cn=config 39objectClass: olcSchemaConfig 40cn: schema 41 42include: file://$TESTWD/schema/core.ldif 43include: file://$TESTWD/schema/cosine.ldif 44include: file://$TESTWD/schema/inetorgperson.ldif 45EOF 46 47if [ "$BACKENDTYPE" = mod ]; then 48 cat >> $TESTDIR/config.ldif <<EOF 49 50dn: cn=module,cn=config 51objectClass: olcModuleList 52cn: module 53olcModulePath: $TESTWD/../servers/slapd/back-$BACKEND 54olcModuleLoad: back_$BACKEND.la 55EOF 56fi 57 58if [ "$ARGON2" = argon2yes ]; then 59 cat >> $TESTDIR/config.ldif <<EOF 60 61dn: cn=module,cn=config 62objectClass: olcModuleList 63cn: module 64olcModulePath: $TESTWD/../servers/slapd/pwmods 65olcModuleLoad: argon2.la 66EOF 67fi 68 69cat >> $TESTDIR/config.ldif <<EOF 70 71dn: olcDatabase={-1}frontend,cn=config 72objectClass: olcDatabaseConfig 73objectClass: olcFrontendConfig 74olcDatabase: {-1}frontend 75olcPasswordHash: {ARGON2} 76 77dn: olcDatabase=config,cn=config 78objectClass: olcDatabaseConfig 79olcDatabase: config 80olcRootPW:< file://$CONFIGPWF 81 82dn: olcDatabase={1}$BACKEND,cn=config 83objectClass: olcDatabaseConfig 84objectClass: olc${BACKEND}Config 85olcDatabase: $BACKEND 86olcSuffix: $BASEDN 87olcRootDN: $MANAGERDN 88olcRootPW: $PASSWD 89olcDbDirectory: $TESTDIR/db.1.a 90EOF 91 92if [ "$INDEXDB" = indexdb ]; then 93 cat >> $TESTDIR/config.ldif <<EOF 94olcDbIndex: objectClass eq,pres 95olcDbIndex: ou,cn,mail,surname,givenname eq,pres,sub 96EOF 97fi 98 99$SLAPADD -F $CONFDIR -n 0 -l $TESTDIR/config.ldif 100 101echo "Starting slapd on TCP/IP port $PORT1..." 102$SLAPD -F $CONFDIR -h $URI1 -d $LVL > $LOG1 2>&1 & 103PID=$! 104if test $WAIT != 0 ; then 105 echo PID $PID 106 read foo 107fi 108KILLPIDS="$PID" 109sleep 1 110 111echo "Using ldapsearch to check that slapd is running..." 112for i in 0 1 2 3 4 5; do 113 $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 114 'objectclass=*' > /dev/null 2>&1 115 RC=$? 116 if test $RC = 0 ; then 117 break 118 fi 119 echo "Waiting 5 seconds for slapd to start..." 120 sleep 5 121done 122if test $RC != 0 ; then 123 echo "ldapsearch failed ($RC)!" 124 test $KILLSERVERS != no && kill -HUP $KILLPIDS 125 exit $RC 126fi 127 128echo "Adding basic structure..." 129$LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD -f $LDIFPASSWD >/dev/null 2>&1 130RC=$? 131if test $RC != 0 ; then 132 echo "ldapadd failed ($RC)!" 133 test $KILLSERVERS != no && kill -HUP $PID 134 exit $RC 135fi 136 137BINDPW=secret 138echo "Testing ldapwhoami as ${USERDN}..." 139$LDAPWHOAMI -H $URI1 -D "$USERDN" -w $BINDPW 140 141RC=$? 142if test $RC != 0 ; then 143 echo "ldapwhoami failed ($RC)!" 144 test $KILLSERVERS != no && kill -HUP $KILLPIDS 145 exit $RC 146fi 147 148test $KILLSERVERS != no && kill -HUP $PID 149 150echo ">>>>> Test succeeded" 151 152test $KILLSERVERS != no && wait 153 154exit 0 155