]> git.sur5r.net Git - openldap/blob - tests/scripts/test006-acls
sh portability changes
[openldap] / tests / scripts / test006-acls
1 #! /bin/sh
2
3 if test $# -eq 0 ; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8 if test $# -eq 1 ; then
9         BACKEND=$1; shift
10 fi
11
12 echo "running defines.sh $SRCDIR $BACKEND"
13 . $SRCDIR/scripts/defines.sh
14
15 echo "Cleaning up in $DBDIR..."
16
17 rm -f $DBDIR/[!C]*
18
19 echo "Running ldif2ldbm to build slapd database..."
20 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
21 RC=$?
22 if test $RC != 0 ; then
23         echo "ldif2ldbm failed!"
24         exit $RC
25 fi
26
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $ACLCONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
29 PID=$!
30
31 echo "Testing slapd access control..."
32 for i in 0 1 2 3 4 5; do
33         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
34                 'cn=Monitor' > /dev/null 2>&1
35         RC=$?
36         if test $RC = 1 ; then
37                 echo "Waiting 5 seconds for slapd to start..."
38                 sleep 5
39         fi
40 done
41
42 if test $RC != 0 ; then
43         echo "ldapsearch failed!"
44         kill -HUP $PID
45         exit $RC
46 fi
47
48 cat /dev/null > $SEARCHOUT
49
50 #
51 # Try to read an entry inside the Alumni Association container.  It should
52 # give us nothing if we're not bound, and should return all attributes
53 # if we're bound as anyone under UM.
54 #
55 $LDAPSEARCH -L -b "$JAJDN" -h localhost -p $PORT "objectclass=*" \
56         >> $SEARCHOUT 2>&1
57
58 $LDAPSEARCH -L -b "$JAJDN" -h localhost -p $PORT \
59         -D "$BABSDN" -w bjensen "objectclass=*"  >> $SEARCHOUT 2>&1
60
61
62 #
63 # Try to add a "member" attribute to the "All Staff" group.  It should
64 # fail when we add some DN other than our own, and should succeed when
65 # we add our own DN.
66 # bjensen
67 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
68         /dev/null 2>&1 << EOMODS1
69 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
70 changetype: modify
71 add: member
72 member: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
73
74 EOMODS1
75
76 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
77         /dev/null 2>&1 << EOMODS2
78 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
79 changetype: modify
80 add: member
81 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
82
83 EOMODS2
84
85 #
86 # Try to modify the "All Staff" group.  Two attempts are made:
87 # 1) bound as "James A Jones 1" - should fail
88 # 2) bound as "Barbara Jensen" - should succeed
89 #
90 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
91         /dev/null 2>&1 << EOMODS3
92 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
93 changetype: modify
94 delete: member
95
96 EOMODS3
97
98 $LDAPMODIFY -D "$BJORNSDN" -h localhost -p $PORT -w bjorn > \
99         /dev/null 2>&1 << EOMODS4
100 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
101 changetype: modify
102 add: telephonenumber
103 telephonenumber: +1 810 555 1212
104
105 EOMODS4
106
107 echo "Using ldapsearch to retrieve all the entries..."
108 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
109             'objectClass=*' | . $SRCDIR/scripts/acfilter.sh >> $SEARCHOUT 2>&1
110 RC=$?
111 kill -HUP $PID
112 if test $RC != 0 ; then
113         echo "ldapsearch failed!"
114         exit $RC
115 fi
116
117 echo "Comparing database to reference file"
118 cmp $SEARCHOUT $ACLOUTMASTER
119 if test $? != 0 ; then
120         echo "comparison failed - modify operations did not complete correctly"
121         exit 1
122 fi
123
124 echo ">>>>> Test succeeded"
125
126
127 exit 0