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