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