1 1.1 lukem #! /bin/sh 2 1.1.1.4 tron # $OpenLDAP$ 3 1.1 lukem ## This work is part of OpenLDAP Software <http://www.openldap.org/>. 4 1.1 lukem ## 5 1.1.1.10 christos ## Copyright 1998-2024 The OpenLDAP Foundation. 6 1.1 lukem ## All rights reserved. 7 1.1 lukem ## 8 1.1 lukem ## Redistribution and use in source and binary forms, with or without 9 1.1 lukem ## modification, are permitted only as authorized by the OpenLDAP 10 1.1 lukem ## Public License. 11 1.1 lukem ## 12 1.1 lukem ## A copy of this license is available in the file LICENSE in the 13 1.1 lukem ## top-level directory of the distribution or, alternatively, at 14 1.1 lukem ## <http://www.OpenLDAP.org/license.html>. 15 1.1 lukem 16 1.1 lukem echo "running defines.sh" 17 1.1 lukem . $SRCDIR/scripts/defines.sh 18 1.1 lukem 19 1.1 lukem mkdir -p $TESTDIR $DBDIR1 20 1.1 lukem 21 1.1 lukem echo "Starting slapd on TCP/IP port $PORT1..." 22 1.1.1.9 christos . $CONFFILTER $BACKEND < $PWCONF > $CONF1 23 1.1.1.9 christos $SLAPD -f $CONF1 -h $URI1 -d $LVL > $LOG1 2>&1 & 24 1.1 lukem PID=$! 25 1.1 lukem if test $WAIT != 0 ; then 26 1.1 lukem echo PID $PID 27 1.1 lukem read foo 28 1.1 lukem fi 29 1.1 lukem KILLPIDS="$PID" 30 1.1 lukem 31 1.1 lukem sleep 1 32 1.1 lukem 33 1.1 lukem echo "Using ldapsearch to check that slapd is running..." 34 1.1 lukem for i in 0 1 2 3 4 5; do 35 1.1.1.9 christos $LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \ 36 1.1 lukem 'objectclass=*' > /dev/null 2>&1 37 1.1 lukem RC=$? 38 1.1 lukem if test $RC = 0 ; then 39 1.1 lukem break 40 1.1 lukem fi 41 1.1 lukem echo "Waiting 5 seconds for slapd to start..." 42 1.1 lukem sleep 5 43 1.1 lukem done 44 1.1 lukem 45 1.1 lukem echo "Using ldapadd to populate the database..." 46 1.1.1.9 christos $LDAPADD -D "$MANAGERDN" -H $URI1 -w $PASSWD < \ 47 1.1 lukem $LDIFPASSWD > $TESTOUT 2>&1 48 1.1 lukem RC=$? 49 1.1 lukem if test $RC != 0 ; then 50 1.1 lukem echo "ldapadd failed ($RC)!" 51 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 52 1.1 lukem exit $RC 53 1.1 lukem fi 54 1.1 lukem 55 1.1 lukem echo > $SEARCHOUT 56 1.1 lukem echo > $TESTOUT 57 1.1 lukem 58 1.1 lukem echo "Using ldapsearch to verify population ..." 59 1.1 lukem echo "++ Initial search" >> $SEARCHOUT 60 1.1.1.9 christos $LDAPSEARCH -H $URI1 \ 61 1.1 lukem -D "$MANAGERDN" -w $PASSWD \ 62 1.1 lukem -b "$BASEDN" \ 63 1.1 lukem 'objectclass=*' >> $SEARCHOUT 2>&1 64 1.1 lukem 65 1.1 lukem echo "Using ldappasswd to test a few error conditions ..." 66 1.1 lukem echo "Pass 0" >> $TESTOUT 67 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 68 1.1 lukem -w secret -a "" -s newsecret \ 69 1.1 lukem -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1 70 1.1 lukem RC=$? 71 1.1 lukem if test $RC = 0 ; then 72 1.1 lukem echo "ldappasswd unexpectantly passed ($RC)! old empty" 73 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 74 1.1 lukem exit 1 75 1.1 lukem fi 76 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 77 1.1 lukem -w secret -a oldsecret -s "" \ 78 1.1 lukem -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1 79 1.1 lukem RC=$? 80 1.1 lukem if test $RC = 0 ; then 81 1.1 lukem echo "ldappasswd unexpectantly passed ($RC)! new empty" 82 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 83 1.1 lukem exit 1 84 1.1 lukem fi 85 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 86 1.1 lukem -w secret -a oldsecret -s newsecret \ 87 1.1 lukem -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1 88 1.1 lukem RC=$? 89 1.1 lukem if test $RC = 0 ; then 90 1.1 lukem echo "ldappasswd unexpectantly passed ($RC)! wrong old" 91 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 92 1.1 lukem exit 1 93 1.1 lukem fi 94 1.1 lukem 95 1.1 lukem echo "Using ldappasswd (PASS 1) ..." 96 1.1 lukem echo "Pass 1" >> $TESTOUT 97 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 98 1.1 lukem -w secret -s newsecret \ 99 1.1 lukem -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1 100 1.1 lukem RC=$? 101 1.1 lukem if test $RC != 0 ; then 102 1.1 lukem echo "ldappasswd failed ($RC)!" 103 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 104 1.1 lukem exit $RC 105 1.1 lukem fi 106 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 107 1.1 lukem -w $PASSWD -s newsecret \ 108 1.1 lukem -D "$MANAGERDN" "cn=smd5, $BASEDN" >> $TESTOUT 2>&1 109 1.1 lukem RC=$? 110 1.1 lukem if test $RC != 0 ; then 111 1.1 lukem echo "ldappasswd failed ($RC)!" 112 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 113 1.1 lukem exit $RC 114 1.1 lukem fi 115 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 116 1.1 lukem -w secret -s newsecret \ 117 1.1 lukem -D "cn=sha, $BASEDN" >> $TESTOUT 2>&1 118 1.1 lukem RC=$? 119 1.1 lukem if test $RC != 0 ; then 120 1.1 lukem echo "ldappasswd failed ($RC)!" 121 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 122 1.1 lukem exit $RC 123 1.1 lukem fi 124 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 125 1.1 lukem -w secret -s newsecret \ 126 1.1 lukem -D "cn=ssha, $BASEDN" >> $TESTOUT 2>&1 127 1.1 lukem RC=$? 128 1.1 lukem if test $RC != 0 ; then 129 1.1 lukem echo "ldappasswd failed ($RC)!" 130 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 131 1.1 lukem exit $RC 132 1.1 lukem fi 133 1.1 lukem 134 1.1 lukem echo "" >> $TESTOUT 135 1.1 lukem echo "Pass 2" >> $TESTOUT 136 1.1 lukem echo "Using ldappasswd (PASS 2) ..." 137 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 138 1.1 lukem -w newsecret \ 139 1.1 lukem -D "cn=md5, $BASEDN" >> $TESTOUT 2>&1 140 1.1 lukem RC=$? 141 1.1 lukem if test $RC != 0 ; then 142 1.1 lukem echo "ldappasswd failed ($RC)!" 143 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 144 1.1 lukem exit $RC 145 1.1 lukem fi 146 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 147 1.1 lukem -w newsecret \ 148 1.1 lukem -D "cn=smd5, $BASEDN" >> $TESTOUT 2>&1 149 1.1 lukem RC=$? 150 1.1 lukem if test $RC != 0 ; then 151 1.1 lukem echo "ldappasswd failed ($RC)!" 152 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 153 1.1 lukem exit $RC 154 1.1 lukem fi 155 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 156 1.1 lukem -w newsecret \ 157 1.1 lukem -D "cn=sha, $BASEDN" >> $TESTOUT 2>&1 158 1.1 lukem RC=$? 159 1.1 lukem if test $RC != 0 ; then 160 1.1 lukem echo "ldappasswd failed ($RC)!" 161 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 162 1.1 lukem exit $RC 163 1.1 lukem fi 164 1.1.1.9 christos $LDAPPASSWD -H $URI1 \ 165 1.1 lukem -w newsecret \ 166 1.1 lukem -D "cn=ssha, $BASEDN" >> $TESTOUT 2>&1 167 1.1 lukem RC=$? 168 1.1 lukem if test $RC != 0 ; then 169 1.1 lukem echo "ldappasswd failed ($RC)!" 170 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 171 1.1 lukem exit $RC 172 1.1 lukem fi 173 1.1 lukem 174 1.1 lukem echo "Logging end state with ldapsearch..." 175 1.1 lukem echo "" >> $TESTOUT 176 1.1 lukem echo "++ End search" >> $TESTOUT 177 1.1.1.9 christos $LDAPSEARCH -H $URI1 \ 178 1.1 lukem -D "$MANAGERDN" -w $PASSWD \ 179 1.1 lukem -b "$BASEDN" \ 180 1.1 lukem 'objectclass=*' >> $TESTOUT 2>&1 181 1.1 lukem 182 1.1 lukem 183 1.1 lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS 184 1.1 lukem 185 1.1 lukem echo ">>>>> Test succeeded" 186 1.1 lukem 187 1.1 lukem test $KILLSERVERS != no && wait 188 1.1 lukem 189 1.1 lukem exit 0 190