3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
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>.
20 echo "Test does not support $BACKEND backend"
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
27 mkdir -p $TESTDIR $DBDIR1
29 echo "Running slapadd to build slapd database..."
30 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFORDERED
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
49 echo "Testing slapd access control..."
50 for i in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 'objectclass=*' > /dev/null 2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 cat /dev/null > $SEARCHOUT
69 echo "# Try to read an entry inside the Alumni Association container.
70 # It should give us noSuchObject if we're not bound..." \
72 # FIXME: temporarily remove the "No such object" message to make
73 # the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
74 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "(objectclass=*)" \
75 2>&1 | grep -v "^No such object" >> $SEARCHOUT
77 echo "# ... and should return all attributes if we're bound as anyone
80 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
81 -D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
84 echo "# Checking exact/regex attrval clause" >> $SEARCHOUT
85 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
86 -D "$BABSDN" -w bjensen \
87 -b "$MELLIOTDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
88 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
89 -D "$BJORNSDN" -w bjorn \
90 -b "$MELLIOTDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
92 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
93 -D "$BABSDN" -w bjensen \
94 -b "$JOHNDDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
95 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
96 -D "$BJORNSDN" -w bjorn \
97 -b "$JOHNDDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
99 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
100 -D "$BABSDN" -w bjensen \
101 -b "$BJORNSDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
102 $LDAPSEARCH -h $LOCALHOST -p $PORT1 \
103 -D "$BJORNSDN" -w bjorn \
104 -b "$BABSDN" -s base "(objectclass=*)" cn >> $SEARCHOUT 2>&1
106 # check selfwrite access (ITS#4587). 6 attempts are made:
107 # 1) delete someone else (should fail)
108 # 2) delete self (should succeed)
109 # 3) add someone else (should fail)
110 # 4) add someone else and self (should fail)
111 # 5) add self and someone else (should fail)
112 # 6) add self (should succeed)
114 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
115 $TESTOUT 2>&1 << EOMODS
116 dn: cn=All Staff,ou=Groups,dc=example,dc=com
126 echo "ldapmodify should have failed ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "ldapmodify failed ($RC)!"
132 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
138 $TESTOUT 2>&1 << EOMODS
139 dn: cn=All Staff,ou=Groups,dc=example,dc=com
145 if test $RC != 0 ; then
146 echo "ldapmodify failed ($RC)!"
147 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
152 $TESTOUT 2>&1 << EOMODS
153 dn: cn=All Staff,ou=Groups,dc=example,dc=com
156 member: cn=Foo,ou=Bar
163 echo "ldapmodify should have failed ($RC)!"
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
168 echo "ldapmodify failed ($RC)!"
169 test $KILLSERVERS != no && kill -HUP $KILLPIDS
174 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
175 $TESTOUT 2>&1 << EOMODS
176 dn: cn=All Staff,ou=Groups,dc=example,dc=com
179 member: cn=Foo,ou=Bar
187 echo "ldapmodify should have failed ($RC)!"
188 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 echo "ldapmodify failed ($RC)!"
193 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
199 $TESTOUT 2>&1 << EOMODS
200 dn: cn=All Staff,ou=Groups,dc=example,dc=com
204 member: cn=Foo,ou=Bar
211 echo "ldapmodify should have failed ($RC)!"
212 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 echo "ldapmodify failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
223 $TESTOUT 2>&1 << EOMODS
224 dn: cn=All Staff,ou=Groups,dc=example,dc=com
230 if test $RC != 0 ; then
231 echo "ldapmodify failed ($RC)!"
232 test $KILLSERVERS != no && kill -HUP $KILLPIDS
237 # Check group access. Try to modify Babs' entry. Two attempts:
238 # 1) bound as "James A Jones 1" - should fail
239 # 2) bound as "Bjorn Jensen" - should succeed
241 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
242 $TESTOUT 2>&1 << EOMODS5
253 echo "ldapmodify should have failed ($RC)!"
254 test $KILLSERVERS != no && kill -HUP $KILLPIDS
258 echo "ldapmodify failed ($RC)!"
259 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
265 $TESTOUT 2>&1 << EOMODS6
269 homephone: +1 313 555 5444
276 echo "ldapmodify failed ($RC)!"
277 test $KILLSERVERS != no && kill -HUP $KILLPIDS
283 # Try to add a "member" attribute to the "ITD Staff" group. It should
284 # fail when we add some DN other than our own, and should succeed when
287 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
288 $TESTOUT 2>&1 << EOMODS1
290 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
293 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
300 echo "ldapmodify should have failed ($RC)!"
301 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 echo "ldapmodify failed ($RC)!"
306 test $KILLSERVERS != no && kill -HUP $KILLPIDS
311 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
312 $TESTOUT 2>&1 << EOMODS2
315 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
318 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
325 echo "ldapmodify failed ($RC)!"
326 test $KILLSERVERS != no && kill -HUP $KILLPIDS
332 # Try to modify the "ITD Staff" group. Two attempts are made:
333 # 1) bound as "James A Jones 1" - should fail
334 # 2) bound as "Bjorn Jensen" - should succeed
336 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
337 $TESTOUT 2>&1 << EOMODS3
339 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
348 echo "ldapmodify should have failed ($RC)!"
349 test $KILLSERVERS != no && kill -HUP $KILLPIDS
353 echo "ldapmodify failed ($RC)!"
354 test $KILLSERVERS != no && kill -HUP $KILLPIDS
359 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
360 $TESTOUT 2>&1 << EOMODS4
364 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
378 echo "ldapmodify failed ($RC)!"
379 test $KILLSERVERS != no && kill -HUP $KILLPIDS
385 # Try to modify the "ITD Staff" group. Two attempts are made:
386 # 1) bound as "James A Jones 1" - should succeed
387 # 2) bound as "Barbara Jensen" - should fail
388 # should exploit sets
390 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
391 $TESTOUT 2>&1 << EOMODS5
392 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
395 description: added by jaj (should succeed)
403 echo "ldapmodify failed ($RC)!"
404 test $KILLSERVERS != no && kill -HUP $KILLPIDS
409 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
410 $TESTOUT 2>&1 << EOMODS6
411 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
414 description: added by bjensen (should fail)
422 echo "ldapmodify should have failed ($RC)!"
423 test $KILLSERVERS != no && kill -HUP $KILLPIDS
427 echo "ldapmodify failed ($RC)!"
428 test $KILLSERVERS != no && kill -HUP $KILLPIDS
433 $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
434 $TESTOUT 2>&1 << EOMODS7
435 dn: ou=Add & Delete,dc=example,dc=com
437 objectClass: organizationalUnit
441 if test $RC != 0 ; then
442 echo "ldapmodify failed ($RC)!"
443 test $KILLSERVERS != no && kill -HUP $KILLPIDS
447 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
448 $TESTOUT 2>&1 << EOMODS8
449 dn: cn=Added by Babs (must fail),ou=Add & Delete,dc=example,dc=com
451 objectClass: inetOrgPerson
452 cn: Added by Babs (must fail)
460 echo "ldapmodify should have failed ($RC)!"
461 test $KILLSERVERS != no && kill -HUP $KILLPIDS
465 echo "ldapmodify failed ($RC)!"
466 test $KILLSERVERS != no && kill -HUP $KILLPIDS
471 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
472 $TESTOUT 2>&1 << EOMODS9
473 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
475 objectClass: inetOrgPerson
476 cn: Added by Bjorn (must succeed)
479 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
481 objectClass: inetOrgPerson
482 cn: Added by Bjorn (will be deleted)
485 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
487 objectClass: inetOrgPerson
488 cn: Added by Bjorn (will be renamed)
491 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
494 description: this attribute value has been added __after__entry creation
495 description: this attribute value will be deleted by Babs (must succeed)
496 description: Bjorn will try to delete this attribute value (should fail)
504 echo "ldapmodify failed ($RC)!"
505 test $KILLSERVERS != no && kill -HUP $KILLPIDS
510 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
511 $TESTOUT 2>&1 << EOMODS10
512 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
520 echo "ldapmodify should have failed ($RC)!"
521 test $KILLSERVERS != no && kill -HUP $KILLPIDS
525 echo "ldapmodify failed ($RC)!"
526 test $KILLSERVERS != no && kill -HUP $KILLPIDS
531 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
532 $TESTOUT 2>&1 << EOMODS11
533 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
535 newrdn: cn=Added by Bjorn (renamed by Bjorn)
543 echo "ldapmodify should have failed ($RC)!"
544 test $KILLSERVERS != no && kill -HUP $KILLPIDS
548 echo "ldapmodify failed ($RC)!"
549 test $KILLSERVERS != no && kill -HUP $KILLPIDS
554 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
555 $TESTOUT 2>&1 << EOMODS12
556 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
558 newrdn: cn=Added by Bjorn (renamed by Babs)
566 echo "ldapmodify should have failed ($RC)!"
567 test $KILLSERVERS != no && kill -HUP $KILLPIDS
571 echo "ldapmodify failed ($RC)!"
572 test $KILLSERVERS != no && kill -HUP $KILLPIDS
577 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
578 $TESTOUT 2>&1 << EOMODS13
579 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
581 newrdn: cn=Added by Bjorn (renamed by Jaj)
589 echo "ldapmodify failed ($RC)!"
590 test $KILLSERVERS != no && kill -HUP $KILLPIDS
595 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
596 $TESTOUT 2>&1 << EOMODS14
597 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
600 description: Bjorn will try to delete this attribute value (should fail)
608 echo "ldapmodify should have failed ($RC)!"
609 test $KILLSERVERS != no && kill -HUP $KILLPIDS
613 echo "ldapmodify failed ($RC)!"
614 test $KILLSERVERS != no && kill -HUP $KILLPIDS
619 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
620 $TESTOUT 2>&1 << EOMODS15
621 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
624 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
627 description: this attribute value will be deleted by Babs (must succeed)
635 echo "ldapmodify failed ($RC)!"
636 test $KILLSERVERS != no && kill -HUP $KILLPIDS
641 echo "Using ldapsearch to retrieve all the entries..."
642 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
643 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
644 'objectClass=*' >> $SEARCHOUT 2>&1
646 test $KILLSERVERS != no && kill -HUP $KILLPIDS
647 if test $RC != 0 ; then
648 echo "ldapsearch failed ($RC)!"
654 echo "Filtering ldapsearch results..."
655 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
656 echo "Filtering original ldif used to create database..."
657 . $LDIFFILTER < $LDIF > $LDIFFLT
658 echo "Comparing filter output..."
659 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
661 if test $? != 0 ; then
662 echo "comparison failed - operations did not complete correctly"
666 echo ">>>>> Test succeeded"
668 test $KILLSERVERS != no && wait