Home | History | Annotate | Line # | Download | only in scripts
      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 if test $MEMBEROF = memberofno; then 
     20       1.1     lukem 	echo "Memberof overlay not available, test skipped"
     21       1.1     lukem 	exit 0
     22       1.1     lukem fi 
     23       1.1     lukem 
     24       1.1     lukem mkdir -p $TESTDIR $DBDIR1 $TESTDIR/confdir
     25       1.1     lukem 
     26       1.1     lukem $SLAPPASSWD -g -n >$CONFIGPWF
     27       1.1     lukem echo "rootpw `$SLAPPASSWD -T $CONFIGPWF`" >$TESTDIR/configpw.conf
     28       1.1     lukem 
     29       1.1     lukem echo "Starting slapd on TCP/IP port $PORT1..."
     30   1.1.1.9  christos . $CONFFILTER $BACKEND < $NAKEDCONF > $CONF1
     31   1.1.1.9  christos $SLAPD -f $CONF1 -F $TESTDIR/confdir -h $URI1 -d $LVL > $LOG1 2>&1 &
     32       1.1     lukem PID=$!
     33       1.1     lukem if test $WAIT != 0 ; then
     34       1.1     lukem     echo PID $PID
     35       1.1     lukem     read foo
     36       1.1     lukem fi
     37       1.1     lukem KILLPIDS="$PID"
     38       1.1     lukem 
     39       1.1     lukem sleep 1
     40       1.1     lukem for i in 0 1 2 3 4 5; do
     41   1.1.1.9  christos 	$LDAPSEARCH -s base -b "$MONITOR" -H $URI1 \
     42       1.1     lukem 		'objectclass=*' > /dev/null 2>&1
     43       1.1     lukem 	RC=$?
     44       1.1     lukem 	if test $RC = 0 ; then
     45       1.1     lukem 		break
     46       1.1     lukem 	fi
     47       1.1     lukem 	echo "Waiting 5 seconds for slapd to start..."
     48       1.1     lukem 	sleep 5
     49       1.1     lukem done
     50       1.1     lukem if test $RC != 0 ; then
     51       1.1     lukem 	echo "ldapsearch failed ($RC)!"
     52       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
     53       1.1     lukem 	exit $RC
     54       1.1     lukem fi
     55       1.1     lukem 
     56       1.1     lukem cat /dev/null > $TESTOUT
     57       1.1     lukem 
     58       1.1     lukem if [ "$MEMBEROF" = memberofmod ]; then
     59   1.1.1.4      tron 	echo "Inserting memberof overlay on provider..."
     60       1.1     lukem 	$LDAPADD -D cn=config -H $URI1 -y $CONFIGPWF <<EOF > $TESTOUT 2>&1
     61       1.1     lukem dn: cn=module,cn=config
     62       1.1     lukem objectClass: olcModuleList
     63       1.1     lukem cn: module
     64       1.1     lukem olcModulePath: ../servers/slapd/overlays
     65       1.1     lukem olcModuleLoad: memberof.la
     66       1.1     lukem EOF
     67       1.1     lukem 	RC=$?
     68       1.1     lukem 	if test $RC != 0 ; then
     69       1.1     lukem 		echo "ldapadd failed for moduleLoad ($RC)!"
     70       1.1     lukem 		test $KILLSERVERS != no && kill -HUP $KILLPIDS
     71       1.1     lukem 		exit $RC
     72       1.1     lukem 	fi
     73       1.1     lukem fi
     74       1.1     lukem 
     75   1.1.1.9  christos indexInclude="" mainInclude="" nullExclude=""
     76   1.1.1.4      tron test $INDEXDB = indexdb	|| indexInclude="# "
     77   1.1.1.4      tron test $MAINDB  = maindb	|| mainInclude="# "
     78   1.1.1.3      adam case $BACKEND in
     79   1.1.1.3      adam null) nullExclude="# " ;;
     80   1.1.1.3      adam esac
     81   1.1.1.3      adam 
     82       1.1     lukem echo "Running ldapadd to build slapd config database..."
     83   1.1.1.9  christos $LDAPADD -H $URI1 -D 'cn=config' -w `cat $CONFIGPWF` \
     84       1.1     lukem 	>> $TESTOUT 2>&1 <<EOF
     85   1.1.1.2     lukem dn: cn=symas group example,cn=schema,cn=config
     86   1.1.1.2     lukem objectClass: olcSchemaConfig
     87   1.1.1.2     lukem cn: symas group example
     88   1.1.1.2     lukem olcAttributeTypes: ( 1.3.6.1.4.1.4754.31.1.1 
     89   1.1.1.2     lukem  NAME 'memberA' SUP distinguishedName )
     90   1.1.1.2     lukem olcAttributeTypes: ( 1.3.6.1.4.1.4754.31.1.2
     91   1.1.1.2     lukem  NAME 'memberOfA' SUP distinguishedName )
     92   1.1.1.2     lukem olcAttributeTypes: ( 1.3.6.1.4.1.4754.31.1.3 
     93   1.1.1.2     lukem  NAME 'memberB' SUP distinguishedName )
     94   1.1.1.2     lukem olcAttributeTypes: ( 1.3.6.1.4.1.4754.31.1.4 
     95   1.1.1.2     lukem  NAME 'memberOfB' SUP distinguishedName )
     96   1.1.1.7  christos olcAttributeTypes: ( 1.3.6.1.4.1.4754.31.1.5
     97   1.1.1.7  christos  NAME 'memberOfC' SUP distinguishedName )
     98   1.1.1.2     lukem olcObjectClasses: ( 1.3.6.1.4.1.4754.31.2.1 
     99   1.1.1.2     lukem  NAME 'groupA' SUP top STRUCTURAL MUST cn MAY memberA )
    100   1.1.1.2     lukem olcObjectClasses: ( 1.3.6.1.4.1.4754.31.2.2 
    101   1.1.1.7  christos  NAME 'groupMemberA' SUP top AUXILIARY MAY ( memberOfA $ memberOfC ) )
    102   1.1.1.2     lukem olcObjectClasses: ( 1.3.6.1.4.1.4754.31.2.3 
    103   1.1.1.2     lukem  NAME 'groupB' SUP top STRUCTURAL MUST cn MAY memberB )
    104   1.1.1.2     lukem olcObjectClasses: ( 1.3.6.1.4.1.4754.31.2.4 
    105   1.1.1.2     lukem  NAME 'groupMemberB' SUP top AUXILIARY MAY memberOfB )
    106   1.1.1.2     lukem 
    107       1.1     lukem dn: olcDatabase={1}$BACKEND,cn=config
    108       1.1     lukem objectClass: olcDatabaseConfig
    109   1.1.1.3      adam ${nullExclude}objectClass: olc${BACKEND}Config
    110       1.1     lukem olcDatabase: {1}$BACKEND
    111       1.1     lukem olcSuffix: $BASEDN
    112       1.1     lukem olcRootDN: cn=Manager,$BASEDN
    113       1.1     lukem olcRootPW:: c2VjcmV0
    114       1.1     lukem olcMonitoring: TRUE
    115   1.1.1.3      adam ${nullExclude}olcDbDirectory: $TESTDIR/db.1.a/
    116   1.1.1.4      tron ${indexInclude}olcDbIndex: objectClass eq
    117   1.1.1.4      tron ${indexInclude}olcDbIndex: cn pres,eq,sub
    118   1.1.1.4      tron ${indexInclude}olcDbIndex: uid pres,eq,sub
    119   1.1.1.4      tron ${indexInclude}olcDbIndex: sn pres,eq,sub
    120   1.1.1.4      tron ${mainInclude}olcDbMode: 384"
    121       1.1     lukem 
    122       1.1     lukem dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
    123       1.1     lukem objectClass: olcOverlayConfig
    124   1.1.1.9  christos objectClass: olcMemberOfConfig
    125       1.1     lukem olcOverlay: {0}memberof
    126       1.1     lukem olcMemberOfRefInt: TRUE
    127       1.1     lukem olcMemberOfGroupOC: groupOfNames
    128       1.1     lukem olcMemberOfMemberAD: member
    129       1.1     lukem olcMemberOfMemberOfAD: memberOf
    130   1.1.1.2     lukem 
    131   1.1.1.2     lukem dn: olcOverlay={1}memberof,olcDatabase={1}$BACKEND,cn=config
    132   1.1.1.2     lukem objectClass: olcOverlayConfig
    133   1.1.1.9  christos objectClass: olcMemberOfConfig
    134   1.1.1.2     lukem olcOverlay: {1}memberof
    135   1.1.1.2     lukem olcMemberOfRefInt: TRUE
    136   1.1.1.2     lukem olcMemberOfGroupOC: groupA
    137   1.1.1.2     lukem olcMemberOfMemberAD: memberA
    138   1.1.1.2     lukem olcMemberOfMemberOfAD: memberOfA
    139   1.1.1.2     lukem 
    140   1.1.1.2     lukem dn: olcOverlay={2}memberof,olcDatabase={1}$BACKEND,cn=config
    141   1.1.1.2     lukem objectClass: olcOverlayConfig
    142   1.1.1.9  christos objectClass: olcMemberOfConfig
    143   1.1.1.2     lukem olcOverlay: {2}memberof
    144   1.1.1.2     lukem olcMemberOfRefInt: TRUE
    145   1.1.1.2     lukem olcMemberOfGroupOC: groupB
    146   1.1.1.2     lukem olcMemberOfMemberAD: memberB
    147   1.1.1.2     lukem olcMemberOfMemberOfAD: memberOfB
    148   1.1.1.2     lukem 
    149       1.1     lukem EOF
    150       1.1     lukem RC=$?
    151       1.1     lukem if test $RC != 0 ; then
    152       1.1     lukem 	echo "ldapadd failed ($RC)!"
    153       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    154       1.1     lukem 	exit $RC
    155       1.1     lukem fi
    156       1.1     lukem 
    157       1.1     lukem echo "Running ldapadd to build slapd database..."
    158   1.1.1.9  christos $LDAPADD -H $URI1 \
    159       1.1     lukem 	-D "cn=Manager,$BASEDN" -w secret \
    160       1.1     lukem 	>> $TESTOUT 2>&1 << EOF
    161       1.1     lukem dn: $BASEDN
    162       1.1     lukem objectClass: organization
    163       1.1     lukem objectClass: dcObject
    164       1.1     lukem o: Example, Inc.
    165       1.1     lukem dc: example
    166       1.1     lukem 
    167       1.1     lukem dn: ou=People,$BASEDN
    168       1.1     lukem objectClass: organizationalUnit
    169       1.1     lukem ou: People
    170       1.1     lukem 
    171       1.1     lukem dn: ou=Groups,$BASEDN
    172       1.1     lukem objectClass: organizationalUnit
    173       1.1     lukem ou: Groups
    174       1.1     lukem 
    175       1.1     lukem dn: cn=Roger Rabbit,ou=People,$BASEDN
    176       1.1     lukem objectClass: inetOrgPerson
    177       1.1     lukem cn: Roger Rabbit
    178       1.1     lukem sn: Rabbit
    179       1.1     lukem 
    180       1.1     lukem dn: cn=Baby Herman,ou=People,$BASEDN
    181       1.1     lukem objectClass: inetOrgPerson
    182       1.1     lukem cn: Baby Herman
    183       1.1     lukem sn: Herman
    184       1.1     lukem 
    185       1.1     lukem dn: cn=Cartoonia,ou=Groups,$BASEDN
    186       1.1     lukem objectClass: groupOfNames
    187       1.1     lukem cn: Cartoonia
    188       1.1     lukem member: cn=Roger Rabbit,ou=People,$BASEDN
    189       1.1     lukem member: cn=Baby Herman,ou=People,$BASEDN
    190       1.1     lukem EOF
    191       1.1     lukem RC=$?
    192       1.1     lukem if test $RC != 0 ; then
    193       1.1     lukem 	echo "ldapadd failed ($RC)!"
    194       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    195       1.1     lukem 	exit $RC
    196       1.1     lukem fi
    197       1.1     lukem 
    198       1.1     lukem echo "Search the entire database..."
    199       1.1     lukem echo "# Search the entire database..." >> $SEARCHOUT
    200   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    201       1.1     lukem 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    202       1.1     lukem RC=$?
    203       1.1     lukem if test $RC != 0 ; then
    204       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    205       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    206       1.1     lukem 	exit $RC
    207       1.1     lukem fi
    208       1.1     lukem 
    209       1.1     lukem echo "Running ldapmodify to add a member..."
    210   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    211       1.1     lukem 	-D "cn=Manager,$BASEDN" -w secret \
    212       1.1     lukem 	>> $TESTOUT 2>&1 << EOF
    213       1.1     lukem dn: cn=Jessica Rabbit,ou=People,$BASEDN
    214       1.1     lukem changetype: add
    215       1.1     lukem objectClass: inetOrgPerson
    216       1.1     lukem cn: Jessica Rabbit
    217       1.1     lukem sn: Rabbit
    218       1.1     lukem 
    219       1.1     lukem dn: cn=Cartoonia,ou=Groups,$BASEDN
    220       1.1     lukem changetype: modify
    221       1.1     lukem add: member
    222       1.1     lukem member: cn=Jessica Rabbit,ou=People,$BASEDN
    223       1.1     lukem EOF
    224       1.1     lukem 
    225       1.1     lukem echo "Re-search the entire database..."
    226   1.1.1.4      tron echo "# Re-search the entire database after adding Jessica Rabbit and Cartoonia..." >> $SEARCHOUT
    227   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    228       1.1     lukem 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    229       1.1     lukem RC=$?
    230       1.1     lukem if test $RC != 0 ; then
    231       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    232       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    233       1.1     lukem 	exit $RC
    234       1.1     lukem fi
    235       1.1     lukem 
    236   1.1.1.4      tron echo "Running ldapmodify to rename a member..."
    237   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    238   1.1.1.4      tron 	-D "cn=Manager,$BASEDN" -w secret \
    239   1.1.1.4      tron 	>> $TESTOUT 2>&1 << EOF
    240   1.1.1.4      tron dn: cn=Baby Herman,ou=People,$BASEDN
    241   1.1.1.4      tron changetype: modrdn
    242   1.1.1.4      tron newrdn: cn=Baby Herman Jr
    243   1.1.1.4      tron deleteoldrdn: 1
    244   1.1.1.4      tron EOF
    245   1.1.1.4      tron 
    246   1.1.1.4      tron echo "Re-search the entire database..."
    247   1.1.1.4      tron echo "# Re-search the entire database after renaming Baby Herman..." >> $SEARCHOUT
    248   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    249   1.1.1.4      tron 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    250   1.1.1.4      tron RC=$?
    251   1.1.1.4      tron if test $RC != 0 ; then
    252   1.1.1.4      tron 	echo "ldapsearch failed ($RC)!"
    253   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    254   1.1.1.4      tron 	exit $RC
    255   1.1.1.4      tron fi
    256   1.1.1.4      tron 
    257   1.1.1.4      tron echo "Running ldapmodify to rename a group..."
    258   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    259       1.1     lukem 	-D "cn=Manager,$BASEDN" -w secret \
    260       1.1     lukem 	>> $TESTOUT 2>&1 << EOF
    261       1.1     lukem dn: cn=Cartoonia,ou=Groups,$BASEDN
    262   1.1.1.4      tron changetype: modrdn
    263   1.1.1.7  christos newrdn: cn=Toon town
    264   1.1.1.7  christos deleteoldrdn: 1
    265   1.1.1.7  christos 
    266   1.1.1.7  christos dn: cn=Toon town,ou=Groups,$BASEDN
    267   1.1.1.7  christos changetype: modrdn
    268   1.1.1.4      tron newrdn: cn=Toon Town
    269   1.1.1.4      tron deleteoldrdn: 1
    270   1.1.1.4      tron EOF
    271   1.1.1.4      tron 
    272   1.1.1.4      tron echo "Re-search the entire database..."
    273   1.1.1.4      tron echo "# Re-search the entire database after renaming Cartoonia..." >> $SEARCHOUT
    274   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    275   1.1.1.4      tron 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    276   1.1.1.4      tron RC=$?
    277   1.1.1.4      tron if test $RC != 0 ; then
    278   1.1.1.4      tron 	echo "ldapsearch failed ($RC)!"
    279   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    280   1.1.1.4      tron 	exit $RC
    281   1.1.1.4      tron fi
    282   1.1.1.4      tron 
    283   1.1.1.4      tron echo "Running ldapmodify to add self..."
    284   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    285   1.1.1.4      tron 	-D "cn=Manager,$BASEDN" -w secret \
    286   1.1.1.4      tron 	>> $TESTOUT 2>&1 << EOF
    287   1.1.1.4      tron dn: cn=Toon Town,ou=Groups,$BASEDN
    288       1.1     lukem changetype: modify
    289       1.1     lukem add: member
    290   1.1.1.4      tron member: cn=Toon Town,ou=Groups,$BASEDN
    291       1.1     lukem EOF
    292       1.1     lukem 
    293       1.1     lukem echo "Re-search the entire database..."
    294   1.1.1.4      tron echo "# Re-search the entire database after adding Toon Town to self..." >> $SEARCHOUT
    295   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    296       1.1     lukem 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    297       1.1     lukem RC=$?
    298       1.1     lukem if test $RC != 0 ; then
    299       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    300       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    301       1.1     lukem 	exit $RC
    302       1.1     lukem fi
    303       1.1     lukem 
    304       1.1     lukem echo "Running ldapdelete to remove a member..."
    305   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    306       1.1     lukem 	-D "cn=Manager,$BASEDN" -w secret \
    307       1.1     lukem 	>> $TESTOUT 2>&1 << EOF
    308   1.1.1.4      tron dn: cn=Baby Herman Jr,ou=People,$BASEDN
    309   1.1.1.4      tron changetype: delete
    310   1.1.1.4      tron EOF
    311   1.1.1.4      tron 
    312   1.1.1.4      tron echo "Re-search the entire database..."
    313   1.1.1.4      tron echo "# Re-search the entire database after deleting Baby Herman..." >> $SEARCHOUT
    314   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    315   1.1.1.4      tron 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    316   1.1.1.4      tron RC=$?
    317   1.1.1.4      tron if test $RC != 0 ; then
    318   1.1.1.4      tron 	echo "ldapsearch failed ($RC)!"
    319   1.1.1.4      tron 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    320   1.1.1.4      tron 	exit $RC
    321   1.1.1.4      tron fi
    322   1.1.1.4      tron 
    323   1.1.1.4      tron echo "Running ldapdelete to remove a group..."
    324   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    325   1.1.1.4      tron 	-D "cn=Manager,$BASEDN" -w secret \
    326   1.1.1.4      tron 	>> $TESTOUT 2>&1 << EOF
    327   1.1.1.4      tron dn: cn=Toon Town,ou=Groups,$BASEDN
    328       1.1     lukem changetype: delete
    329       1.1     lukem EOF
    330       1.1     lukem 
    331       1.1     lukem echo "Re-search the entire database..."
    332   1.1.1.4      tron echo "# Re-search the entire database after deleting Toon Town..." >> $SEARCHOUT
    333   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    334       1.1     lukem 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    335       1.1     lukem RC=$?
    336       1.1     lukem if test $RC != 0 ; then
    337       1.1     lukem 	echo "ldapsearch failed ($RC)!"
    338       1.1     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    339       1.1     lukem 	exit $RC
    340       1.1     lukem fi
    341       1.1     lukem 
    342   1.1.1.2     lukem echo "Adding groups with MAY member type schemas..."
    343   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    344   1.1.1.2     lukem 	-D "cn=Manager,$BASEDN" -w secret \
    345   1.1.1.2     lukem 	>> $TESTOUT 2>&1 <<EOF
    346   1.1.1.2     lukem dn: cn=Roger Rabbit,ou=People,$BASEDN
    347   1.1.1.2     lukem changetype: delete
    348   1.1.1.2     lukem 
    349   1.1.1.2     lukem dn: cn=Jessica Rabbit,ou=People,$BASEDN
    350   1.1.1.2     lukem changetype: delete
    351   1.1.1.2     lukem 
    352   1.1.1.2     lukem dn: cn=person1,ou=People,$BASEDN
    353   1.1.1.2     lukem changetype: add
    354   1.1.1.2     lukem objectClass: person
    355   1.1.1.2     lukem objectClass: groupMemberA
    356   1.1.1.2     lukem objectClass: groupMemberB
    357   1.1.1.2     lukem cn: person1
    358   1.1.1.2     lukem sn: person1
    359   1.1.1.2     lukem 
    360   1.1.1.2     lukem dn: cn=person2,ou=People,$BASEDN
    361   1.1.1.2     lukem changetype: add
    362   1.1.1.2     lukem objectClass: person
    363   1.1.1.2     lukem objectClass: groupMemberA
    364   1.1.1.2     lukem objectClass: groupMemberB
    365   1.1.1.2     lukem cn: person2
    366   1.1.1.2     lukem sn: person2
    367   1.1.1.2     lukem 
    368   1.1.1.2     lukem dn: cn=group1,ou=Groups,$BASEDN
    369   1.1.1.2     lukem changetype: add
    370   1.1.1.2     lukem objectclass: groupA
    371   1.1.1.2     lukem cn: group1
    372   1.1.1.2     lukem memberA: cn=person1,ou=People,$BASEDN
    373   1.1.1.2     lukem memberA: cn=person2,ou=People,$BASEDN
    374   1.1.1.2     lukem 
    375   1.1.1.2     lukem dn: cn=group2,ou=Groups,$BASEDN
    376   1.1.1.2     lukem changetype: add
    377   1.1.1.2     lukem objectclass: groupB
    378   1.1.1.2     lukem cn: group2
    379   1.1.1.2     lukem memberB: cn=person1,ou=People,$BASEDN
    380   1.1.1.2     lukem memberB: cn=person2,ou=People,$BASEDN
    381   1.1.1.2     lukem 
    382   1.1.1.2     lukem dn: cn=group1,ou=Groups,$BASEDN
    383   1.1.1.2     lukem changetype: modify
    384   1.1.1.2     lukem delete: memberA
    385   1.1.1.2     lukem 
    386   1.1.1.2     lukem EOF
    387   1.1.1.2     lukem 
    388   1.1.1.2     lukem echo "Re-search the entire database..."
    389   1.1.1.4      tron echo "# Re-search the entire database after adding groups with MAY member type schemas..." >> $SEARCHOUT
    390   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    391   1.1.1.2     lukem 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    392   1.1.1.2     lukem RC=$?
    393   1.1.1.2     lukem if test $RC != 0 ; then
    394   1.1.1.2     lukem 	echo "ldapsearch failed ($RC)!"
    395   1.1.1.2     lukem 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    396   1.1.1.2     lukem 	exit $RC
    397   1.1.1.2     lukem fi
    398   1.1.1.2     lukem 
    399   1.1.1.7  christos echo "Running ldapmodify to reconfigure the schema used..."
    400   1.1.1.9  christos $LDAPADD -H $URI1 -D 'cn=config' -w `cat $CONFIGPWF` \
    401   1.1.1.7  christos 	>> $TESTOUT 2>&1 <<EOF
    402   1.1.1.7  christos dn: olcOverlay={1}memberof,olcDatabase={1}$BACKEND,cn=config
    403   1.1.1.7  christos changetype: modify
    404   1.1.1.7  christos replace: olcMemberOfMemberOfAD
    405   1.1.1.7  christos olcMemberOfMemberOfAD: memberOfC
    406   1.1.1.7  christos 
    407   1.1.1.7  christos EOF
    408   1.1.1.7  christos RC=$?
    409   1.1.1.7  christos if test $RC != 0 ; then
    410   1.1.1.7  christos 	echo "ldapadd failed ($RC)!"
    411   1.1.1.7  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    412   1.1.1.7  christos 	exit $RC
    413   1.1.1.7  christos fi
    414   1.1.1.7  christos 
    415   1.1.1.7  christos echo "Updating groups to expose the new setting..."
    416   1.1.1.9  christos $LDAPMODIFY -H $URI1 \
    417   1.1.1.7  christos 	-D "cn=Manager,$BASEDN" -w secret \
    418   1.1.1.7  christos 	>> $TESTOUT 2>&1 <<EOF
    419   1.1.1.7  christos dn: cn=group1,ou=Groups,$BASEDN
    420   1.1.1.7  christos changetype: modify
    421   1.1.1.7  christos add: memberA
    422   1.1.1.7  christos memberA: cn=person1,ou=People,$BASEDN
    423   1.1.1.7  christos memberA: cn=person2,ou=People,$BASEDN
    424   1.1.1.7  christos 
    425   1.1.1.7  christos EOF
    426   1.1.1.7  christos RC=$?
    427   1.1.1.7  christos if test $RC != 0 ; then
    428   1.1.1.7  christos 	echo "ldapmodify failed ($RC)!"
    429   1.1.1.7  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    430   1.1.1.7  christos 	exit $RC
    431   1.1.1.7  christos fi
    432   1.1.1.7  christos 
    433   1.1.1.7  christos echo "Re-search the entire database..."
    434   1.1.1.7  christos echo "# Re-search the entire database after updating memberof configuration..." >> $SEARCHOUT
    435   1.1.1.9  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    436   1.1.1.7  christos 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    437   1.1.1.7  christos RC=$?
    438   1.1.1.7  christos if test $RC != 0 ; then
    439   1.1.1.7  christos 	echo "ldapsearch failed ($RC)!"
    440   1.1.1.7  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    441   1.1.1.7  christos 	exit $RC
    442   1.1.1.7  christos fi
    443   1.1.1.7  christos 
    444  1.1.1.10  christos echo "Running ldapmodify to enable add checking..."
    445  1.1.1.10  christos $LDAPMODIFY -H $URI1 -D 'cn=config' -w `cat $CONFIGPWF` \
    446  1.1.1.10  christos 	>> $TESTOUT 2>&1 <<EOF
    447  1.1.1.10  christos dn: olcOverlay={0}memberof,olcDatabase={1}$BACKEND,cn=config
    448  1.1.1.10  christos changetype: modify
    449  1.1.1.10  christos replace: olcMemberOfAddCheck
    450  1.1.1.10  christos olcMemberOfAddCheck: TRUE
    451  1.1.1.10  christos 
    452  1.1.1.10  christos EOF
    453  1.1.1.10  christos RC=$?
    454  1.1.1.10  christos if test $RC != 0 ; then
    455  1.1.1.10  christos 	echo "ldapmodify failed ($RC)!"
    456  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    457  1.1.1.10  christos 	exit $RC
    458  1.1.1.10  christos fi
    459  1.1.1.10  christos 
    460  1.1.1.10  christos echo "Adding group and users out of order..."
    461  1.1.1.10  christos $LDAPADD -H $URI1 \
    462  1.1.1.10  christos 	-D "cn=Manager,$BASEDN" -w secret \
    463  1.1.1.10  christos 	>> $TESTOUT 2>&1 <<EOF
    464  1.1.1.10  christos dn: cn=group3,ou=Groups,$BASEDN
    465  1.1.1.10  christos objectclass: groupOfNames
    466  1.1.1.10  christos cn: group3
    467  1.1.1.10  christos member: cn=New Person,ou=People,$BASEDN
    468  1.1.1.10  christos member: cn=New Group,ou=Groups,$BASEDN
    469  1.1.1.10  christos 
    470  1.1.1.10  christos dn: cn=New Group,ou=Groups,$BASEDN
    471  1.1.1.10  christos objectclass: groupOfNames
    472  1.1.1.10  christos cn: New Group
    473  1.1.1.10  christos member: cn=New Person,ou=People,$BASEDN
    474  1.1.1.10  christos 
    475  1.1.1.10  christos dn: cn=New Person,ou=People,$BASEDN
    476  1.1.1.10  christos objectclass: person
    477  1.1.1.10  christos cn: New Person
    478  1.1.1.10  christos sn: Person
    479  1.1.1.10  christos 
    480  1.1.1.10  christos EOF
    481  1.1.1.10  christos RC=$?
    482  1.1.1.10  christos if test $RC != 0 ; then
    483  1.1.1.10  christos 	echo "ldapadd failed ($RC)!"
    484  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    485  1.1.1.10  christos 	exit $RC
    486  1.1.1.10  christos fi
    487  1.1.1.10  christos 
    488  1.1.1.10  christos echo "Re-search the entire database..."
    489  1.1.1.10  christos echo "# Re-search the entire database after adding out-of-order groups/users..." >> $SEARCHOUT
    490  1.1.1.10  christos $LDAPSEARCH -S "" -b "$BASEDN" -H $URI1 \
    491  1.1.1.10  christos 	'(objectClass=*)' '*' memberOf >> $SEARCHOUT 2>&1
    492  1.1.1.10  christos RC=$?
    493  1.1.1.10  christos if test $RC != 0 ; then
    494  1.1.1.10  christos 	echo "ldapsearch failed ($RC)!"
    495  1.1.1.10  christos 	test $KILLSERVERS != no && kill -HUP $KILLPIDS
    496  1.1.1.10  christos 	exit $RC
    497  1.1.1.10  christos fi
    498  1.1.1.10  christos 
    499       1.1     lukem test $KILLSERVERS != no && kill -HUP $KILLPIDS
    500       1.1     lukem 
    501       1.1     lukem LDIF=$MEMBEROFOUT
    502       1.1     lukem 
    503       1.1     lukem echo "Filtering ldapsearch results..."
    504   1.1.1.3      adam $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
    505       1.1     lukem echo "Filtering original ldif used to create database..."
    506   1.1.1.3      adam $LDIFFILTER < $LDIF > $LDIFFLT
    507       1.1     lukem echo "Comparing filter output..."
    508       1.1     lukem $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
    509       1.1     lukem 
    510       1.1     lukem if test $? != 0 ; then
    511       1.1     lukem 	echo "Comparison failed"
    512       1.1     lukem 	exit 1
    513       1.1     lukem fi
    514       1.1     lukem 
    515       1.1     lukem echo ">>>>> Test succeeded"
    516       1.1     lukem 
    517       1.1     lukem test $KILLSERVERS != no && wait
    518       1.1     lukem 
    519       1.1     lukem exit 0
    520