1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
#! /bin/sh
## $OpenLDAP$
## This work is part of OpenLDAP Software <http://www.openldap.org/>.
##
## Copyright 2016-2024 The OpenLDAP Foundation.
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted only as authorized by the OpenLDAP
## Public License.
##
## A copy of this license is available in the file LICENSE in the
## top-level directory of the distribution or, alternatively, at
## <http://www.OpenLDAP.org/license.html>.
##
## ACKNOWLEDGEMENTS:
## This module was written in 2016 by Ondřej Kuzník for Symas Corp.
case "$BACKEND" in ldif | null)
echo "$BACKEND backend does not support access controls, test skipped"
exit 0
esac
echo "running defines.sh"
. $SRCDIR/scripts/defines.sh
CONF=$ACLCONF
. ${SCRIPTDIR}/common.sh
echo "Applying test-specific configuration..."
. $CONFFILTER $BACKEND $MONITORDB < data/test006-config.ldif | \
$LDAPMODIFY -v -D cn=config -H $URI1 -y $CONFIGPWF \
>> $TESTOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD >> \
$TESTOUT 2>&1 << EOMODS
dn: ou=Add & Delete,dc=example,dc=com
changetype: add
objectClass: organizationalUnit
ou: Add & Delete
dn: cn=group,ou=Add & Delete,dc=example,dc=com
changetype: add
objectclass: groupOfNames
member: dc=example,dc=com
dn: sn=Doe,ou=Add & Delete,dc=example,dc=com
changetype: add
objectclass: OpenLDAPperson
cn: John
uid: jd
dn: sn=Elliot,ou=Add & Delete,dc=example,dc=com
changetype: add
objectclass: OpenLDAPperson
cn: Mark
uid: me
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
echo "Testing search ACL processing..."
echo "# Try to read an entry inside the Alumni Association container.
# It should give us noSuchObject if we're not bound..." \
>> $SEARCHOUT
# FIXME: temporarily remove the "No such object" message to make
# the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
$LDAPSEARCH -b "$MELLIOTDN" -H $URI1 "(objectclass=*)" \
2>&1 | grep -v "No such object" >> $SEARCHOUT
echo >>$SEARCHOUT
echo "# ... and should return appropriate attributes if we're bound as anyone
# under Example." \
>> $SEARCHOUT
$LDAPSEARCH -b "$MELLIOTDN" -H $URI1 \
-D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
$LDAPSEARCH -b "$MELLIOTDN" -H $URI1 \
-D "$BJORNSDN" -w bjorn "(objectclass=*)" >> $SEARCHOUT 2>&1
echo >>$SEARCHOUT
echo "# Add & Delete subtree contents as seen by Babs" >> $SEARCHOUT
$LDAPSEARCH -b "ou=Add & Delete,dc=example,dc=com" -H $URI1 \
-D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
echo >>$SEARCHOUT
echo "# Add & Delete subtree contents as seen by Bjorn" >> $SEARCHOUT
$LDAPSEARCH -b "ou=Add & Delete,dc=example,dc=com" -H $URI1 \
-D "$BJORNSDN" -w bjorn "(objectclass=*)" >> $SEARCHOUT 2>&1
echo "Testing modifications..."
echo "... ACL on the alternative entry"
$LDAPMODIFY -D "$BJORNSDN" -H $URI1 -w bjorn >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=group,ou=Add & Delete,dc=example,dc=com
changetype: modify
add: seealso
seealso: $BJORNSDN
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BABSDN" -H $URI1 -w bjensen >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
changetype: modify
add: description
description: added by bjensen (should fail)
EOMODS
RC=$?
case $RC in
50)
;;
0)
echo "ldapmodify should have failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit -1
;;
*)
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
;;
esac
$LDAPMODIFY -D "$MANAGERDN" -H $URI1 -w $PASSWD >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=group,ou=Add & Delete,dc=example,dc=com
changetype: modify
add: seealso
seealso: $BABSDN
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BJORNSDN" -H $URI1 -w bjorn >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
changetype: modify
add: description
description: added by bjorn (removed later)
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BABSDN" -H $URI1 -w bjensen >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Group,ou=Add & Delete,dc=example,dc=com
changetype: modify
delete: description
description: added by bjorn (removed later)
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BJORNSDN" -H $URI1 -w bjorn >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Added by Bjorn,ou=Add & Delete,dc=example,dc=com
changetype: add
objectClass: inetOrgPerson
sn: Jensen
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BJORNSDN" -H $URI1 -w bjorn >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Group,ou=Add & Delete,dc=example,dc=com
changetype: modify
add: description
description: another one added by bjorn (should succeed)
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
echo "... ACL on the variant entry"
$LDAPMODIFY -D "$BABSDN" -H $URI1 -w bjensen >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Group,ou=Add & Delete,dc=example,dc=com
changetype: modify
add: description
description: added by bjensen (should fail)
EOMODS
RC=$?
case $RC in
50)
;;
0)
echo "ldapmodify should have failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit -1
;;
*)
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
;;
esac
$LDAPMODIFY -D "$BJORNSDN" -H $URI1 -w bjorn >> \
$TESTOUT 2>&1 << EOMODS
dn: sn=Doe,ou=Add & Delete,dc=example,dc=com
changetype: modify
add: description
description: added by bjorn (will be removed)
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
$LDAPMODIFY -D "$BABSDN" -H $URI1 -w bjensen >> \
$TESTOUT 2>&1 << EOMODS
dn: cn=Added by Bjorn,ou=Add & Delete,dc=example,dc=com
changetype: modify
replace: description
description: added by bjensen (should fail)
EOMODS
RC=$?
case $RC in
50)
;;
0)
echo "ldapmodify should have failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit -1
;;
*)
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
;;
esac
$LDAPMODIFY -D "$JAJDN" -H $URI1 -w jaj >> \
$TESTOUT 2>&1 << EOMODS
dn: sn=Elliot,ou=Add & Delete,dc=example,dc=com
changetype: modify
delete: description
description: added by bjorn (will be removed)
-
add: description
description: added by jaj (should succeed)
EOMODS
RC=$?
if test $RC != 0 ; then
echo "ldapmodify failed ($RC)!"
test $KILLSERVERS != no && kill -HUP $KILLPIDS
exit $RC
fi
sleep $SLEEP0
echo >>$SEARCHOUT
echo "Using ldapsearch to retrieve all the entries..."
echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
$LDAPSEARCH -S "" -b "ou=Add & Delete,dc=example,dc=com" \
-D "$MANAGERDN" -H $URI1 -w $PASSWD \
'objectClass=*' >> $SEARCHOUT 2>&1
RC=$?
if test $RC != 0 ; then
echo "ldapsearch failed ($RC)!"
exit $RC
fi
test $KILLSERVERS != no && kill -HUP $KILLPIDS
LDIF=data/test006-out.ldif
echo "Filtering ldapsearch results..."
$LDIFFILTER -s e < $SEARCHOUT > $SEARCHFLT
echo "Filtering expected entries..."
$LDIFFILTER -s e < $LDIF > $LDIFFLT
echo "Comparing filter output..."
$CMP $SEARCHFLT $LDIFFLT > $CMPOUT
if test $? != 0 ; then
echo "comparison failed - operations did not complete correctly"
exit 1
fi
echo ">>>>> Test succeeded"
test $KILLSERVERS != no && wait
exit 0
|