slapi_pblock.c 36.4 KB
Newer Older
Kurt Zeilenga's avatar
Kurt Zeilenga committed
1
/* $OpenLDAP$ */
2
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
4
 * Copyright 2002-2019 The OpenLDAP Foundation.
5
6
7
 * Portions Copyright 1997,2002-2003 IBM Corporation.
 * All rights reserved.
 *
8
9
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted only as authorized by the OpenLDAP
10
11
12
13
14
15
16
17
18
19
20
 * 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 work was initially developed by IBM Corporation for use in
 * IBM products and subsequently ported to OpenLDAP Software by
 * Steve Omrani.  Additional significant contributors include:
 *   Luke Howard
21
22
23
24
25
26
 */

#include "portable.h"
#include <slap.h>
#include <slapi.h>

27
28
29
30
#ifdef LDAP_SLAPI

/* some parameters require a valid connection and operation */
#define PBLOCK_LOCK_CONN( _pb )		do { \
31
		ldap_pvt_thread_mutex_lock( &(_pb)->pb_conn->c_mutex ); \
32
33
34
	} while (0)

#define PBLOCK_UNLOCK_CONN( _pb )	do { \
35
		ldap_pvt_thread_mutex_unlock( &(_pb)->pb_conn->c_mutex ); \
36
37
38
	} while (0)

/* some parameters are only settable for internal operations */
39
#define PBLOCK_VALIDATE_IS_INTOP( _pb )	do { if ( (_pb)->pb_intop == 0 ) break; } while ( 0 )
40

41
static slapi_pblock_class_t 
42
pblock_get_param_class( int param ) 
43
44
{
	switch ( param ) {
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
	case SLAPI_PLUGIN_TYPE:
	case SLAPI_PLUGIN_ARGC:
	case SLAPI_PLUGIN_OPRETURN:
	case SLAPI_PLUGIN_INTOP_RESULT:
	case SLAPI_CONFIG_LINENO:
	case SLAPI_CONFIG_ARGC:
	case SLAPI_BIND_METHOD:
	case SLAPI_MODRDN_DELOLDRDN:
	case SLAPI_SEARCH_SCOPE:
	case SLAPI_SEARCH_DEREF:
	case SLAPI_SEARCH_SIZELIMIT:
	case SLAPI_SEARCH_TIMELIMIT:
	case SLAPI_SEARCH_ATTRSONLY:
	case SLAPI_NENTRIES:
	case SLAPI_CHANGENUMBER:
	case SLAPI_DBSIZE:
61
62
63
	case SLAPI_REQUESTOR_ISROOT:
	case SLAPI_BE_READONLY:
	case SLAPI_BE_LASTMOD:
64
65
66
	case SLAPI_DB2LDIF_PRINTKEY:
	case SLAPI_LDIF2DB_REMOVEDUPVALS:
	case SLAPI_MANAGEDSAIT:
Kurt Zeilenga's avatar
Kurt Zeilenga committed
67
	case SLAPI_X_RELAX:
68
	case SLAPI_X_OPERATION_NO_SCHEMA_CHECK:
69
	case SLAPI_IS_REPLICATED_OPERATION:
70
	case SLAPI_X_CONN_IS_UDP:
71
	case SLAPI_X_CONN_SSF:
72
	case SLAPI_RESULT_CODE:
73
	case SLAPI_LOG_OPERATION:
Luke Howard's avatar
Luke Howard committed
74
	case SLAPI_IS_INTERNAL_OPERATION:
75
76
77
78
79
80
81
		return PBLOCK_CLASS_INTEGER;
		break;

	case SLAPI_CONN_ID:
	case SLAPI_OPERATION_ID:
	case SLAPI_OPINITIATED_TIME:
	case SLAPI_ABANDON_MSGID:
82
	case SLAPI_X_OPERATION_DELETE_GLUE_PARENT:
Luke Howard's avatar
Luke Howard committed
83
	case SLAPI_OPERATION_MSGID:
84
85
86
		return PBLOCK_CLASS_LONG_INTEGER;
		break;

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
	case SLAPI_PLUGIN_DESTROY_FN:
	case SLAPI_PLUGIN_DB_BIND_FN:
	case SLAPI_PLUGIN_DB_UNBIND_FN:
	case SLAPI_PLUGIN_DB_SEARCH_FN:
	case SLAPI_PLUGIN_DB_COMPARE_FN:
	case SLAPI_PLUGIN_DB_MODIFY_FN:
	case SLAPI_PLUGIN_DB_MODRDN_FN:
	case SLAPI_PLUGIN_DB_ADD_FN:
	case SLAPI_PLUGIN_DB_DELETE_FN:
	case SLAPI_PLUGIN_DB_ABANDON_FN:
	case SLAPI_PLUGIN_DB_CONFIG_FN:
	case SLAPI_PLUGIN_CLOSE_FN:
	case SLAPI_PLUGIN_DB_FLUSH_FN:
	case SLAPI_PLUGIN_START_FN:
	case SLAPI_PLUGIN_DB_SEQ_FN:
	case SLAPI_PLUGIN_DB_ENTRY_FN:
	case SLAPI_PLUGIN_DB_REFERRAL_FN:
	case SLAPI_PLUGIN_DB_RESULT_FN:
	case SLAPI_PLUGIN_DB_LDIF2DB_FN:
	case SLAPI_PLUGIN_DB_DB2LDIF_FN:
	case SLAPI_PLUGIN_DB_BEGIN_FN:
	case SLAPI_PLUGIN_DB_COMMIT_FN:
	case SLAPI_PLUGIN_DB_ABORT_FN:
	case SLAPI_PLUGIN_DB_ARCHIVE2DB_FN:
	case SLAPI_PLUGIN_DB_DB2ARCHIVE_FN:
	case SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_FN:
	case SLAPI_PLUGIN_DB_FREE_RESULT_SET_FN:
	case SLAPI_PLUGIN_DB_SIZE_FN:
	case SLAPI_PLUGIN_DB_TEST_FN:
	case SLAPI_PLUGIN_DB_NO_ACL:
	case SLAPI_PLUGIN_EXT_OP_FN:
	case SLAPI_PLUGIN_EXT_OP_OIDLIST:
	case SLAPI_PLUGIN_PRE_BIND_FN:
	case SLAPI_PLUGIN_PRE_UNBIND_FN:
	case SLAPI_PLUGIN_PRE_SEARCH_FN:
	case SLAPI_PLUGIN_PRE_COMPARE_FN:
	case SLAPI_PLUGIN_PRE_MODIFY_FN:
	case SLAPI_PLUGIN_PRE_MODRDN_FN:
	case SLAPI_PLUGIN_PRE_ADD_FN:
	case SLAPI_PLUGIN_PRE_DELETE_FN:
	case SLAPI_PLUGIN_PRE_ABANDON_FN:
	case SLAPI_PLUGIN_PRE_ENTRY_FN:
	case SLAPI_PLUGIN_PRE_REFERRAL_FN:
	case SLAPI_PLUGIN_PRE_RESULT_FN:
131
132
133
134
135
136
137
138
	case SLAPI_PLUGIN_INTERNAL_PRE_ADD_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_MODIFY_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_MODRDN_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_DELETE_FN:
	case SLAPI_PLUGIN_BE_PRE_ADD_FN:
	case SLAPI_PLUGIN_BE_PRE_MODIFY_FN:
	case SLAPI_PLUGIN_BE_PRE_MODRDN_FN:
	case SLAPI_PLUGIN_BE_PRE_DELETE_FN:
139
140
141
142
143
144
145
146
147
148
149
150
	case SLAPI_PLUGIN_POST_BIND_FN:
	case SLAPI_PLUGIN_POST_UNBIND_FN:
	case SLAPI_PLUGIN_POST_SEARCH_FN:
	case SLAPI_PLUGIN_POST_COMPARE_FN:
	case SLAPI_PLUGIN_POST_MODIFY_FN:
	case SLAPI_PLUGIN_POST_MODRDN_FN:
	case SLAPI_PLUGIN_POST_ADD_FN:
	case SLAPI_PLUGIN_POST_DELETE_FN:
	case SLAPI_PLUGIN_POST_ABANDON_FN:
	case SLAPI_PLUGIN_POST_ENTRY_FN:
	case SLAPI_PLUGIN_POST_REFERRAL_FN:
	case SLAPI_PLUGIN_POST_RESULT_FN:
151
152
153
154
155
156
157
158
	case SLAPI_PLUGIN_INTERNAL_POST_ADD_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_MODIFY_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_MODRDN_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_DELETE_FN:
	case SLAPI_PLUGIN_BE_POST_ADD_FN:
	case SLAPI_PLUGIN_BE_POST_MODIFY_FN:
	case SLAPI_PLUGIN_BE_POST_MODRDN_FN:
	case SLAPI_PLUGIN_BE_POST_DELETE_FN:
159
160
161
162
163
164
	case SLAPI_PLUGIN_MR_FILTER_CREATE_FN:
	case SLAPI_PLUGIN_MR_INDEXER_CREATE_FN:
	case SLAPI_PLUGIN_MR_FILTER_MATCH_FN:
	case SLAPI_PLUGIN_MR_FILTER_INDEX_FN:
	case SLAPI_PLUGIN_MR_FILTER_RESET_FN:
	case SLAPI_PLUGIN_MR_INDEX_FN:
165
166
167
168
169
170
	case SLAPI_PLUGIN_COMPUTE_EVALUATOR_FN:
	case SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN:
	case SLAPI_PLUGIN_ACL_ALLOW_ACCESS:
	case SLAPI_X_PLUGIN_PRE_GROUP_FN:
	case SLAPI_X_PLUGIN_POST_GROUP_FN:
	case SLAPI_PLUGIN_AUDIT_FN:
171
172
173
174
175
176
177
178
179
180
	case SLAPI_PLUGIN_INTERNAL_PRE_BIND_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_UNBIND_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_SEARCH_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_COMPARE_FN:
	case SLAPI_PLUGIN_INTERNAL_PRE_ABANDON_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_BIND_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_UNBIND_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_SEARCH_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_COMPARE_FN:
	case SLAPI_PLUGIN_INTERNAL_POST_ABANDON_FN:
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
		return PBLOCK_CLASS_FUNCTION_POINTER;
		break;

	case SLAPI_BACKEND:
	case SLAPI_CONNECTION:
	case SLAPI_OPERATION:
	case SLAPI_OPERATION_PARAMETERS:
	case SLAPI_OPERATION_TYPE:
	case SLAPI_OPERATION_AUTHTYPE:
	case SLAPI_BE_MONITORDN:
	case SLAPI_BE_TYPE:
	case SLAPI_REQUESTOR_DN:
	case SLAPI_CONN_DN:
	case SLAPI_CONN_CLIENTIP:
	case SLAPI_CONN_SERVERIP:
	case SLAPI_CONN_AUTHTYPE:
	case SLAPI_CONN_AUTHMETHOD:
	case SLAPI_CONN_CERT:
	case SLAPI_X_CONN_CLIENTPATH:
	case SLAPI_X_CONN_SERVERPATH:
	case SLAPI_X_CONN_SASL_CONTEXT:
202
	case SLAPI_X_CONFIG_ARGV:
203
	case SLAPI_X_INTOP_FLAGS:
Luke Howard's avatar
Luke Howard committed
204
205
206
207
	case SLAPI_X_INTOP_RESULT_CALLBACK:
	case SLAPI_X_INTOP_SEARCH_ENTRY_CALLBACK:
	case SLAPI_X_INTOP_REFERRAL_ENTRY_CALLBACK:
	case SLAPI_X_INTOP_CALLBACK_DATA:
208
209
210
211
212
	case SLAPI_PLUGIN_MR_OID:
	case SLAPI_PLUGIN_MR_TYPE:
	case SLAPI_PLUGIN_MR_VALUE:
	case SLAPI_PLUGIN_MR_VALUES:
	case SLAPI_PLUGIN_MR_KEYS:
213
214
215
216
217
	case SLAPI_PLUGIN:
	case SLAPI_PLUGIN_PRIVATE:
	case SLAPI_PLUGIN_ARGV:
	case SLAPI_PLUGIN_OBJECT:
	case SLAPI_PLUGIN_DESCRIPTION:
218
	case SLAPI_PLUGIN_IDENTITY:
219
220
	case SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES:
	case SLAPI_PLUGIN_INTOP_SEARCH_REFERRALS:
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
	case SLAPI_PLUGIN_MR_FILTER_REUSABLE:
	case SLAPI_PLUGIN_MR_QUERY_OPERATOR:
	case SLAPI_PLUGIN_MR_USAGE:
	case SLAPI_OP_LESS:
	case SLAPI_OP_LESS_OR_EQUAL:
	case SLAPI_PLUGIN_MR_USAGE_INDEX:
	case SLAPI_PLUGIN_SYNTAX_FILTER_AVA:
	case SLAPI_PLUGIN_SYNTAX_FILTER_SUB:
	case SLAPI_PLUGIN_SYNTAX_VALUES2KEYS:
	case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_AVA:
	case SLAPI_PLUGIN_SYNTAX_ASSERTION2KEYS_SUB:
	case SLAPI_PLUGIN_SYNTAX_NAMES:
	case SLAPI_PLUGIN_SYNTAX_OID:
	case SLAPI_PLUGIN_SYNTAX_FLAGS:
	case SLAPI_PLUGIN_SYNTAX_COMPARE:
	case SLAPI_CONFIG_FILENAME:
	case SLAPI_CONFIG_ARGV:
238
239
	case SLAPI_TARGET_ADDRESS:
	case SLAPI_TARGET_UNIQUEID:
240
241
242
243
244
	case SLAPI_TARGET_DN:
	case SLAPI_REQCONTROLS:
	case SLAPI_ENTRY_PRE_OP:
	case SLAPI_ENTRY_POST_OP:
	case SLAPI_RESCONTROLS:
245
	case SLAPI_X_OLD_RESCONTROLS:
246
	case SLAPI_ADD_RESCONTROL:
247
	case SLAPI_CONTROLS_ARG:
248
	case SLAPI_ADD_ENTRY:
249
250
251
252
	case SLAPI_ADD_EXISTING_DN_ENTRY:
	case SLAPI_ADD_PARENT_ENTRY:
	case SLAPI_ADD_PARENT_UNIQUEID:
	case SLAPI_ADD_EXISTING_UNIQUEID_ENTRY:
253
254
255
256
257
258
259
260
	case SLAPI_BIND_CREDENTIALS:
	case SLAPI_BIND_SASLMECHANISM:
	case SLAPI_BIND_RET_SASLCREDS:
	case SLAPI_COMPARE_TYPE:
	case SLAPI_COMPARE_VALUE:
	case SLAPI_MODIFY_MODS:
	case SLAPI_MODRDN_NEWRDN:
	case SLAPI_MODRDN_NEWSUPERIOR:
261
262
263
264
	case SLAPI_MODRDN_PARENT_ENTRY:
	case SLAPI_MODRDN_NEWPARENT_ENTRY:
	case SLAPI_MODRDN_TARGET_ENTRY:
	case SLAPI_MODRDN_NEWSUPERIOR_ADDRESS:
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
	case SLAPI_SEARCH_FILTER:
	case SLAPI_SEARCH_STRFILTER:
	case SLAPI_SEARCH_ATTRS:
	case SLAPI_SEQ_TYPE:
	case SLAPI_SEQ_ATTRNAME:
	case SLAPI_SEQ_VAL:
	case SLAPI_EXT_OP_REQ_OID:
	case SLAPI_EXT_OP_REQ_VALUE:
	case SLAPI_EXT_OP_RET_OID:
	case SLAPI_EXT_OP_RET_VALUE:
	case SLAPI_MR_FILTER_ENTRY:
	case SLAPI_MR_FILTER_TYPE:
	case SLAPI_MR_FILTER_VALUE:
	case SLAPI_MR_FILTER_OID:
	case SLAPI_MR_FILTER_DNATTRS:
	case SLAPI_LDIF2DB_FILE:
	case SLAPI_PARENT_TXN:
	case SLAPI_TXN:
	case SLAPI_SEARCH_RESULT_SET:
	case SLAPI_SEARCH_RESULT_ENTRY:
	case SLAPI_SEARCH_REFERRALS:
286
287
	case SLAPI_RESULT_TEXT:
	case SLAPI_RESULT_MATCHED:
288
289
290
	case SLAPI_X_GROUP_ENTRY:
	case SLAPI_X_GROUP_ATTRIBUTE:
	case SLAPI_X_GROUP_OPERATION_DN:
291
	case SLAPI_X_GROUP_TARGET_ENTRY:
292
	case SLAPI_X_ADD_STRUCTURAL_CLASS:
293
294
	case SLAPI_PLUGIN_AUDIT_DATA:
	case SLAPI_IBM_PBLOCK:
295
	case SLAPI_PLUGIN_VERSION:
296
297
		return PBLOCK_CLASS_POINTER;
		break;
298
	default:
299
		break;
300
301
	}

302
	return PBLOCK_CLASS_INVALID;
303
304
305
}

static void
306
pblock_lock( Slapi_PBlock *pb )
307
{
Luke Howard's avatar
Luke Howard committed
308
	ldap_pvt_thread_mutex_lock( &pb->pb_mutex );
309
310
311
}

static void
312
pblock_unlock( Slapi_PBlock *pb )
313
{
Luke Howard's avatar
Luke Howard committed
314
	ldap_pvt_thread_mutex_unlock( &pb->pb_mutex );
315
316
317
}

static int 
318
pblock_get_default( Slapi_PBlock *pb, int param, void **value ) 
319
320
{	
	int i;
321
	slapi_pblock_class_t pbClass;
322

323
	pbClass = pblock_get_param_class( param );
324
	if ( pbClass == PBLOCK_CLASS_INVALID ) {
325
326
327
		return PBLOCK_ERROR;
	}
	
328
329
	switch ( pbClass ) {
	case PBLOCK_CLASS_INTEGER:
330
		*((int *)value) = 0;
331
332
		break;
	case PBLOCK_CLASS_LONG_INTEGER:
333
		*((long *)value) = 0L;
334
335
336
		break;
	case PBLOCK_CLASS_POINTER:
	case PBLOCK_CLASS_FUNCTION_POINTER:
337
		*value = NULL;
338
		break;
339
340
	case PBLOCK_CLASS_INVALID:
		return PBLOCK_ERROR;
341
342
	}

343
344
	for ( i = 0; i < pb->pb_nParams; i++ ) {
		if ( pb->pb_params[i] == param ) {
345
346
			switch ( pbClass ) {
			case PBLOCK_CLASS_INTEGER:
347
				*((int *)value) = pb->pb_values[i].pv_integer;
348
349
				break;
			case PBLOCK_CLASS_LONG_INTEGER:
350
				*((long *)value) = pb->pb_values[i].pv_long_integer;
351
352
				break;
			case PBLOCK_CLASS_POINTER:
353
				*value = pb->pb_values[i].pv_pointer;
354
				break;
355
			case PBLOCK_CLASS_FUNCTION_POINTER:
356
				*value = pb->pb_values[i].pv_function_pointer;
357
358
359
360
				break;
			default:
				break;
			}
361
362
363
			break;
	  	}
	}
364

365
	return PBLOCK_SUCCESS;
366
367
}

368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
static char *
pblock_get_authtype( AuthorizationInformation *authz, int is_tls )
{
	char *authType;

	switch ( authz->sai_method ) {
	case LDAP_AUTH_SASL:
		authType = SLAPD_AUTH_SASL;
		break;
	case LDAP_AUTH_SIMPLE:
		authType = SLAPD_AUTH_SIMPLE;
		break;
	case LDAP_AUTH_NONE:
		authType = SLAPD_AUTH_NONE;
		break;
	default:
		authType = NULL;
		break;
	}

	if ( is_tls && authType == NULL ) {
		authType = SLAPD_AUTH_SSL;
	}

	return authType;
}

395
static int 
396
pblock_set_default( Slapi_PBlock *pb, int param, void *value ) 
397
{
398
	slapi_pblock_class_t pbClass;
Quanah Gibson-Mount's avatar
Quanah Gibson-Mount committed
399
	int i;
400

401
	pbClass = pblock_get_param_class( param );
402
	if ( pbClass == PBLOCK_CLASS_INVALID ) {
403
404
405
		return PBLOCK_ERROR;
	}

406
	if ( pb->pb_nParams == PBLOCK_MAX_PARAMS ) {
407
		return PBLOCK_ERROR;
408
409
	}

410
411
	for ( i = 0; i < pb->pb_nParams; i++ ) {
		if ( pb->pb_params[i] == param )
412
			break;
413
414
415
416
	}
	if ( i >= pb->pb_nParams ) {
		pb->pb_params[i] = param;
	  	pb->pb_nParams++;
417
418
	}

419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
	switch ( pbClass ) {
	case PBLOCK_CLASS_INTEGER:
		pb->pb_values[i].pv_integer = (*((int *)value));
		break;
	case PBLOCK_CLASS_LONG_INTEGER:
		pb->pb_values[i].pv_long_integer = (*((long *)value));
		break;
	case PBLOCK_CLASS_POINTER:
		pb->pb_values[i].pv_pointer = value;
		break;
	case PBLOCK_CLASS_FUNCTION_POINTER:
		pb->pb_values[i].pv_function_pointer = value;
		break;
	default:
		break;
434
435
436
437
438
	}

	return PBLOCK_SUCCESS;
}

439
440
441
442
443
444
445
446
447
448
449
static int
pblock_be_call( Slapi_PBlock *pb, int (*bep)(Operation *) )
{
	BackendDB *be_orig;
	Operation *op;
	int rc;

	PBLOCK_ASSERT_OP( pb, 0 );
	op = pb->pb_op;

	be_orig = op->o_bd;
450
	op->o_bd = select_backend( &op->o_req_ndn, 0 );
451
452
453
454
455
456
	rc = (*bep)( op );
	op->o_bd = be_orig;

	return rc;
}

457
458
459
460
461
462
463
static int 
pblock_get( Slapi_PBlock *pb, int param, void **value ) 
{
	int rc = PBLOCK_SUCCESS;

	pblock_lock( pb );

Howard Chu's avatar
Howard Chu committed
464
	switch ( param ) {
465
	case SLAPI_OPERATION:
466
		*value = pb->pb_op;
467
468
469
		break;
	case SLAPI_OPINITIATED_TIME:
		PBLOCK_ASSERT_OP( pb, 0 );
470
		*((long *)value) = pb->pb_op->o_time;
471
472
473
		break;
	case SLAPI_OPERATION_ID:
		PBLOCK_ASSERT_OP( pb, 0 );
474
		*((long *)value) = pb->pb_op->o_opid;
475
476
477
		break;
	case SLAPI_OPERATION_TYPE:
		PBLOCK_ASSERT_OP( pb, 0 );
478
		*((ber_tag_t *)value) = pb->pb_op->o_tag;
479
		break;
Luke Howard's avatar
Luke Howard committed
480
481
482
483
	case SLAPI_OPERATION_MSGID:
		PBLOCK_ASSERT_OP( pb, 0 );
		*((long *)value) = pb->pb_op->o_msgid;
		break;
484
485
	case SLAPI_X_OPERATION_DELETE_GLUE_PARENT:
		PBLOCK_ASSERT_OP( pb, 0 );
486
		*((int *)value) = pb->pb_op->o_delete_glue_parent;
487
		break;
488
489
490
491
	case SLAPI_X_OPERATION_NO_SCHEMA_CHECK:
		PBLOCK_ASSERT_OP( pb, 0 );
		*((int *)value) = get_no_schema_check( pb->pb_op );
		break;
492
493
494
495
496
497
498
499
	case SLAPI_X_ADD_STRUCTURAL_CLASS:
		PBLOCK_ASSERT_OP( pb, 0 );

		if ( pb->pb_op->o_tag == LDAP_REQ_ADD ) {
			struct berval tmpval = BER_BVNULL;

			rc = mods_structural_class( pb->pb_op->ora_modlist,
				&tmpval, &pb->pb_rs->sr_text,
500
501
				pb->pb_textbuf, sizeof( pb->pb_textbuf ),
				pb->pb_op->o_tmpmemctx );
502
503
504
505
506
			*((char **)value) = tmpval.bv_val;
		} else {
			rc = PBLOCK_ERROR;
		}
		break;
507
508
	case SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE:
		PBLOCK_ASSERT_OP( pb, 0 );
509
		*((int *)value) = pb->pb_op->o_no_subordinate_glue;
510
		break;
511
512
	case SLAPI_REQCONTROLS:
		PBLOCK_ASSERT_OP( pb, 0 );
513
		*((LDAPControl ***)value) = pb->pb_op->o_ctrls;
514
515
516
		break;
	case SLAPI_REQUESTOR_DN:
		PBLOCK_ASSERT_OP( pb, 0 );
517
		*((char **)value) = pb->pb_op->o_dn.bv_val;
518
519
520
		break;
	case SLAPI_MANAGEDSAIT:
		PBLOCK_ASSERT_OP( pb, 0 );
521
		*((int *)value) = get_manageDSAit( pb->pb_op );
522
		break;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
523
	case SLAPI_X_RELAX:
524
		PBLOCK_ASSERT_OP( pb, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
525
		*((int *)value) = get_relax( pb->pb_op );
526
		break;
527
528
	case SLAPI_BACKEND:
		PBLOCK_ASSERT_OP( pb, 0 );
529
		*((BackendDB **)value) = select_backend( &pb->pb_op->o_req_ndn, 0 );
530
531
532
		break;
	case SLAPI_BE_TYPE:
		PBLOCK_ASSERT_OP( pb, 0 );
533
534
		if ( pb->pb_op->o_bd != NULL )
			*((char **)value) = pb->pb_op->o_bd->bd_info->bi_type;
535
536
537
538
		else
			*value = NULL;
		break;
	case SLAPI_CONNECTION:
539
		*value = pb->pb_conn;
540
541
542
		break;
	case SLAPI_X_CONN_SSF:
		PBLOCK_ASSERT_OP( pb, 0 );
543
		*((slap_ssf_t *)value) = pb->pb_conn->c_ssf;
544
545
		break;
	case SLAPI_X_CONN_SASL_CONTEXT:
Luke Howard's avatar
Luke Howard committed
546
		PBLOCK_ASSERT_CONN( pb );
547
548
		if ( pb->pb_conn->c_sasl_authctx != NULL )
			*value = pb->pb_conn->c_sasl_authctx;
549
		else
550
			*value = pb->pb_conn->c_sasl_sockctx;
551
552
553
		break;
	case SLAPI_TARGET_DN:
		PBLOCK_ASSERT_OP( pb, 0 );
554
		*((char **)value) = pb->pb_op->o_req_dn.bv_val;
555
556
		break;
	case SLAPI_REQUESTOR_ISROOT:
557
		*((int *)value) = pblock_be_call( pb, be_isroot );
558
		break;
559
	case SLAPI_IS_REPLICATED_OPERATION:
560
		*((int *)value) = pblock_be_call( pb, be_slurp_update );
561
562
563
		break;
	case SLAPI_CONN_AUTHTYPE:
	case SLAPI_CONN_AUTHMETHOD: /* XXX should return SASL mech */
Luke Howard's avatar
Luke Howard committed
564
		PBLOCK_ASSERT_CONN( pb );
565
		*((char **)value) = pblock_get_authtype( &pb->pb_conn->c_authz,
566
#ifdef HAVE_TLS
567
							 pb->pb_conn->c_is_tls
568
569
570
571
572
#else
							 0
#endif
							 );
		break;
Luke Howard's avatar
Luke Howard committed
573
574
575
	case SLAPI_IS_INTERNAL_OPERATION:
		*((int *)value) = pb->pb_intop;
		break;
576
	case SLAPI_X_CONN_IS_UDP:
Luke Howard's avatar
Luke Howard committed
577
		PBLOCK_ASSERT_CONN( pb );
578
#ifdef LDAP_CONNECTIONLESS
579
		*((int *)value) = pb->pb_conn->c_is_udp;
580
581
582
583
584
#else
		*((int *)value) = 0;
#endif
		break;
	case SLAPI_CONN_ID:
Luke Howard's avatar
Luke Howard committed
585
		PBLOCK_ASSERT_CONN( pb );
586
		*((long *)value) = pb->pb_conn->c_connid;
587
588
		break;
	case SLAPI_CONN_DN:
Luke Howard's avatar
Luke Howard committed
589
		PBLOCK_ASSERT_CONN( pb );
590
591
592
593
594
595
#if 0
		/* This would be necessary to keep plugin compat after the fix in ITS#4158 */
		if ( pb->pb_op->o_tag == LDAP_REQ_BIND && pb->pb_rs->sr_err == LDAP_SUCCESS )
			*((char **)value) = pb->pb_op->orb_edn.bv_val;
		else
#endif
596
		*((char **)value) = pb->pb_conn->c_dn.bv_val;
597
598
		break;
	case SLAPI_CONN_CLIENTIP:
Luke Howard's avatar
Luke Howard committed
599
		PBLOCK_ASSERT_CONN( pb );
600
601
		if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "IP=", 3 ) == 0 )
			*((char **)value) = &pb->pb_conn->c_peer_name.bv_val[3];
602
603
604
605
		else
			*value = NULL;
		break;
	case SLAPI_X_CONN_CLIENTPATH:
Luke Howard's avatar
Luke Howard committed
606
		PBLOCK_ASSERT_CONN( pb );
607
608
		if ( strncmp( pb->pb_conn->c_peer_name.bv_val, "PATH=", 3 ) == 0 )
			*((char **)value) = &pb->pb_conn->c_peer_name.bv_val[5];
609
610
611
612
		else
			*value = NULL;
		break;
	case SLAPI_CONN_SERVERIP:
Luke Howard's avatar
Luke Howard committed
613
		PBLOCK_ASSERT_CONN( pb );
614
		if ( strncmp( pb->pb_conn->c_sock_name.bv_val, "IP=", 3 ) == 0 )
615
			*((char **)value) = &pb->pb_conn->c_sock_name.bv_val[3];
616
617
618
619
		else
			*value = NULL;
		break;
	case SLAPI_X_CONN_SERVERPATH:
Luke Howard's avatar
Luke Howard committed
620
		PBLOCK_ASSERT_CONN( pb );
621
		if ( strncmp( pb->pb_conn->c_sock_name.bv_val, "PATH=", 3 ) == 0 )
622
			*((char **)value) = &pb->pb_conn->c_sock_name.bv_val[5];
623
624
625
626
627
		else
			*value = NULL;
		break;
	case SLAPI_RESULT_CODE:
	case SLAPI_PLUGIN_INTOP_RESULT:
628
629
		PBLOCK_ASSERT_OP( pb, 0 );
		*((int *)value) = pb->pb_rs->sr_err;
630
		break;
Howard Chu's avatar
Howard Chu committed
631
        case SLAPI_RESULT_TEXT:
632
633
		PBLOCK_ASSERT_OP( pb, 0 );
		*((const char **)value) = pb->pb_rs->sr_text;
634
		break;
Howard Chu's avatar
Howard Chu committed
635
        case SLAPI_RESULT_MATCHED:
636
637
		PBLOCK_ASSERT_OP( pb, 0 );
		*((const char **)value) = pb->pb_rs->sr_matched;
638
639
640
		break;
	case SLAPI_ADD_ENTRY:
		PBLOCK_ASSERT_OP( pb, 0 );
641
642
		if ( pb->pb_op->o_tag == LDAP_REQ_ADD )
			*((Slapi_Entry **)value) = pb->pb_op->ora_e;
643
644
645
646
647
		else
			*value = NULL;
		break;
	case SLAPI_MODIFY_MODS: {
		LDAPMod **mods = NULL;
Howard Chu's avatar
Howard Chu committed
648
		Modifications *ml = NULL;
649
650

		pblock_get_default( pb, param, (void **)&mods );
651
		if ( mods == NULL && pb->pb_intop == 0 ) {
652
653
654
655
656
657
658
			switch ( pb->pb_op->o_tag ) {
			case LDAP_REQ_MODIFY:
				ml = pb->pb_op->orm_modlist;
				break;
			case LDAP_REQ_MODRDN:
				ml = pb->pb_op->orr_modlist;
				break;
Howard Chu's avatar
Howard Chu committed
659
			default:
660
661
662
				rc = PBLOCK_ERROR;
				break;
			}
Howard Chu's avatar
Howard Chu committed
663
664
665
666
			if ( rc != PBLOCK_ERROR ) {
				mods = slapi_int_modifications2ldapmods( ml );
				pblock_set_default( pb, param, (void *)mods );
			}
667
668
669
670
671
672
		}
		*((LDAPMod ***)value) = mods;
		break;
	}
	case SLAPI_MODRDN_NEWRDN:
		PBLOCK_ASSERT_OP( pb, 0 );
673
674
		if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN )
			*((char **)value) = pb->pb_op->orr_newrdn.bv_val;
675
676
677
678
679
		else
			*value = NULL;
		break;
	case SLAPI_MODRDN_NEWSUPERIOR:
		PBLOCK_ASSERT_OP( pb, 0 );
680
681
		if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN && pb->pb_op->orr_newSup != NULL )
			*((char **)value) = pb->pb_op->orr_newSup->bv_val;
682
683
684
685
686
		else
			*value = NULL;
		break;
	case SLAPI_MODRDN_DELOLDRDN:
		PBLOCK_ASSERT_OP( pb, 0 );
687
688
		if ( pb->pb_op->o_tag == LDAP_REQ_MODRDN )
			*((int *)value) = pb->pb_op->orr_deleteoldrdn;
689
690
691
692
693
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_SCOPE:
		PBLOCK_ASSERT_OP( pb, 0 );
694
695
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((int *)value) = pb->pb_op->ors_scope;
696
697
698
699
700
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_DEREF:
		PBLOCK_ASSERT_OP( pb, 0 );
701
702
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((int *)value) = pb->pb_op->ors_deref;
703
704
705
706
707
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_SIZELIMIT:
		PBLOCK_ASSERT_OP( pb, 0 );
708
709
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((int *)value) = pb->pb_op->ors_slimit;
710
711
712
713
714
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_TIMELIMIT:
		PBLOCK_ASSERT_OP( pb, 0 );
715
716
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((int *)value) = pb->pb_op->ors_tlimit;
717
718
719
720
721
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_FILTER:
		PBLOCK_ASSERT_OP( pb, 0 );
722
723
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((Slapi_Filter **)value) = pb->pb_op->ors_filter;
724
725
726
727
728
		else
			*((Slapi_Filter **)value) = NULL;
		break;
	case SLAPI_SEARCH_STRFILTER:
		PBLOCK_ASSERT_OP( pb, 0 );
729
730
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((char **)value) = pb->pb_op->ors_filterstr.bv_val;
731
732
733
734
735
736
737
		else
			*((char **)value) = NULL;
		break;
	case SLAPI_SEARCH_ATTRS: {
		char **attrs = NULL;

		PBLOCK_ASSERT_OP( pb, 0 );
738
		if ( pb->pb_op->o_tag != LDAP_REQ_SEARCH ) {
739
740
741
742
			rc = PBLOCK_ERROR;
			break;
		}
		pblock_get_default( pb, param, (void **)&attrs );
743
744
		if ( attrs == NULL && pb->pb_intop == 0 ) {
			attrs = anlist2charray_x( pb->pb_op->ors_attrs, 0, pb->pb_op->o_tmpmemctx );
745
746
			pblock_set_default( pb, param, (void *)attrs );
		}
747
		*((char ***)value) = attrs;
748
		break;
749
750
751
	}
	case SLAPI_SEARCH_ATTRSONLY:
		PBLOCK_ASSERT_OP( pb, 0 );
752
753
		if ( pb->pb_op->o_tag == LDAP_REQ_SEARCH )
			*((int *)value) = pb->pb_op->ors_attrsonly;
754
755
756
757
		else
			*((int *)value) = 0;
		break;
	case SLAPI_SEARCH_RESULT_ENTRY:
758
759
		PBLOCK_ASSERT_OP( pb, 0 );
		*((Slapi_Entry **)value) = pb->pb_rs->sr_entry;
760
761
		break;
	case SLAPI_BIND_RET_SASLCREDS:
762
763
		PBLOCK_ASSERT_OP( pb, 0 );
		*((struct berval **)value) = pb->pb_rs->sr_sasldata;
764
765
		break;
	case SLAPI_EXT_OP_REQ_OID:
766
		*((const char **)value) = pb->pb_op->ore_reqoid.bv_val;
767
768
		break;
	case SLAPI_EXT_OP_REQ_VALUE:
769
		*((struct berval **)value) = pb->pb_op->ore_reqdata;
770
771
		break;
	case SLAPI_EXT_OP_RET_OID:
772
773
		PBLOCK_ASSERT_OP( pb, 0 );
		*((const char **)value) = pb->pb_rs->sr_rspoid;
774
775
		break;
	case SLAPI_EXT_OP_RET_VALUE:
776
777
		PBLOCK_ASSERT_OP( pb, 0 );
		*((struct berval **)value) = pb->pb_rs->sr_rspdata;
778
779
		break;
	case SLAPI_BIND_METHOD:
780
781
		if ( pb->pb_op->o_tag == LDAP_REQ_BIND )
			*((int *)value) = pb->pb_op->orb_method;
782
783
784
785
		else
			*((int *)value) = 0;
		break;
	case SLAPI_BIND_CREDENTIALS:
786
787
		if ( pb->pb_op->o_tag == LDAP_REQ_BIND )
			*((struct berval **)value) = &pb->pb_op->orb_cred;
788
789
790
791
		else
			*value = NULL;
		break;
	case SLAPI_COMPARE_TYPE:
792
793
		if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE )
			*((char **)value) = pb->pb_op->orc_ava->aa_desc->ad_cname.bv_val;
794
795
796
797
		else
			*value = NULL;
		break;
	case SLAPI_COMPARE_VALUE:
798
799
		if ( pb->pb_op->o_tag == LDAP_REQ_COMPARE )
			*((struct berval **)value) = &pb->pb_op->orc_ava->aa_value;
800
801
		else
			*value = NULL;
802
		break;
Luke Howard's avatar
Luke Howard committed
803
	case SLAPI_ABANDON_MSGID:
804
805
		if ( pb->pb_op->o_tag == LDAP_REQ_ABANDON )
			*((int *)value) = pb->pb_op->orn_msgid;
Luke Howard's avatar
Luke Howard committed
806
807
808
		else
			*((int *)value) = 0;
		break;
Howard Chu's avatar
Howard Chu committed
809
	default:
810
		rc = pblock_get_default( pb, param, value );
811
		break;
Howard Chu's avatar
Howard Chu committed
812
	}
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835

	pblock_unlock( pb );

	return rc;
}

static int
pblock_add_control( Slapi_PBlock *pb, LDAPControl *control )
{
	LDAPControl **controls = NULL;
	size_t i;

	pblock_get_default( pb, SLAPI_RESCONTROLS, (void **)&controls );

	if ( controls != NULL ) {
		for ( i = 0; controls[i] != NULL; i++ )
			;
	} else {
		i = 0;
	}

	controls = (LDAPControl **)slapi_ch_realloc( (char *)controls,
		( i + 2 ) * sizeof(LDAPControl *));
836
837
	controls[i++] = slapi_dup_control( control );
	controls[i] = NULL;
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856

	return pblock_set_default( pb, SLAPI_RESCONTROLS, (void *)controls );
}

static int
pblock_set_dn( void *value, struct berval *dn, struct berval *ndn, void *memctx )
{
	struct berval bv;

	if ( !BER_BVISNULL( dn )) {
		slap_sl_free( dn->bv_val, memctx );
		BER_BVZERO( dn );
	}
	if ( !BER_BVISNULL( ndn )) {
		slap_sl_free( ndn->bv_val, memctx );
		BER_BVZERO( ndn );
	}

	bv.bv_val = (char *)value;
857
	bv.bv_len = ( value != NULL ) ? strlen( bv.bv_val ) : 0;
858
859
860
861
862
863
864
865
866
867
868
869
870

	return dnPrettyNormal( NULL, &bv, dn, ndn, memctx );
}

static int 
pblock_set( Slapi_PBlock *pb, int param, void *value ) 
{
	int rc = PBLOCK_SUCCESS;

	pblock_lock( pb );	

	switch ( param ) {
	case SLAPI_OPERATION:
871
		pb->pb_op = (Operation *)value;
872
873
874
		break;
	case SLAPI_OPINITIATED_TIME:
		PBLOCK_ASSERT_OP( pb, 0 );
875
		pb->pb_op->o_time = *((long *)value);
876
877
878
		break;
	case SLAPI_OPERATION_ID:
		PBLOCK_ASSERT_OP( pb, 0 );
879
		pb->pb_op->o_opid = *((long *)value);
880
881
882
		break;
	case SLAPI_OPERATION_TYPE:
		PBLOCK_ASSERT_OP( pb, 0 );
883
		pb->pb_op->o_tag = *((ber_tag_t *)value);
884
		break;
Luke Howard's avatar
Luke Howard committed
885
886
887
888
	case SLAPI_OPERATION_MSGID:
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_op->o_msgid = *((long *)value);
		break;
889
890
891
892
	case SLAPI_X_OPERATION_DELETE_GLUE_PARENT:
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_op->o_delete_glue_parent = *((int *)value);
		break;
893
894
895
896
	case SLAPI_X_OPERATION_NO_SCHEMA_CHECK:
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_op->o_no_schema_check = *((int *)value);
		break;
897
898
899
900
	case SLAPI_X_OPERATION_NO_SUBORDINATE_GLUE:
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_op->o_no_subordinate_glue = *((int *)value);
		break;
901
902
	case SLAPI_REQCONTROLS:
		PBLOCK_ASSERT_OP( pb, 0 );
903
		pb->pb_op->o_ctrls = (LDAPControl **)value;
904
905
906
907
908
		break;
	case SLAPI_RESCONTROLS: {
		LDAPControl **ctrls = NULL;

		pblock_get_default( pb, param, (void **)&ctrls );
909
		if ( ctrls != NULL ) {
910
911
912
913
914
915
916
917
918
919
920
921
			/* free old ones first */
			ldap_controls_free( ctrls );
		}
		rc = pblock_set_default( pb, param, value );
		break;
	}
	case SLAPI_ADD_RESCONTROL:
		PBLOCK_ASSERT_OP( pb, 0 );
		rc = pblock_add_control( pb, (LDAPControl *)value );
		break;
	case SLAPI_REQUESTOR_DN:
		PBLOCK_ASSERT_OP( pb, 0 );
922
		rc = pblock_set_dn( value, &pb->pb_op->o_dn, &pb->pb_op->o_ndn, pb->pb_op->o_tmpmemctx );
923
924
925
		break;
	case SLAPI_MANAGEDSAIT:
		PBLOCK_ASSERT_OP( pb, 0 );
926
		pb->pb_op->o_managedsait = *((int *)value);
927
		break;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
928
	case SLAPI_X_RELAX:
929
		PBLOCK_ASSERT_OP( pb, 0 );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
930
		pb->pb_op->o_relax = *((int *)value);
931
		break;
932
933
	case SLAPI_BACKEND:
		PBLOCK_ASSERT_OP( pb, 0 );
934
		pb->pb_op->o_bd = (BackendDB *)value;
935
936
		break;
	case SLAPI_CONNECTION:
937
		pb->pb_conn = (Connection *)value;
938
939
		break;
	case SLAPI_X_CONN_SSF:
Luke Howard's avatar
Luke Howard committed
940
		PBLOCK_ASSERT_CONN( pb );
941
		PBLOCK_LOCK_CONN( pb );
Pierangelo Masarati's avatar
Pierangelo Masarati committed
942
		pb->pb_conn->c_ssf = (slap_ssf_t)(long)value;
943
944
945
		PBLOCK_UNLOCK_CONN( pb );
		break;
	case SLAPI_X_CONN_SASL_CONTEXT:
Luke Howard's avatar
Luke Howard committed
946
		PBLOCK_ASSERT_CONN( pb );
947
		PBLOCK_LOCK_CONN( pb );
948
		pb->pb_conn->c_sasl_authctx = value;
949
950
951
952
		PBLOCK_UNLOCK_CONN( pb );
		break;
	case SLAPI_TARGET_DN:
		PBLOCK_ASSERT_OP( pb, 0 );
953
		rc = pblock_set_dn( value, &pb->pb_op->o_req_dn, &pb->pb_op->o_req_ndn, pb->pb_op->o_tmpmemctx );
954
955
		break;
	case SLAPI_CONN_ID:
Luke Howard's avatar
Luke Howard committed
956
		PBLOCK_ASSERT_CONN( pb );
957
		PBLOCK_LOCK_CONN( pb );
958
		pb->pb_conn->c_connid = *((long *)value);
959
960
961
		PBLOCK_UNLOCK_CONN( pb );
		break;
	case SLAPI_CONN_DN:
Luke Howard's avatar
Luke Howard committed
962
		PBLOCK_ASSERT_CONN( pb );
963
		PBLOCK_LOCK_CONN( pb );
964
		rc = pblock_set_dn( value, &pb->pb_conn->c_dn, &pb->pb_conn->c_ndn, NULL );
965
966
967
968
		PBLOCK_UNLOCK_CONN( pb );
		break;
	case SLAPI_RESULT_CODE:
	case SLAPI_PLUGIN_INTOP_RESULT:
969
970
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_rs->sr_err = *((int *)value);
971
972
		break;
	case SLAPI_RESULT_TEXT:
973
		PBLOCK_ASSERT_OP( pb, 0 );
974
		snprintf( pb->pb_textbuf, sizeof( pb->pb_textbuf ), "%s", (char *)value );
975
		pb->pb_rs->sr_text = pb->pb_textbuf;
976
977
		break;
	case SLAPI_RESULT_MATCHED:
978
979
		PBLOCK_ASSERT_OP( pb, 0 );
		pb->pb_rs->sr_matched = (char *)value; /* XXX should dup? */
980
981
982
		break;
	case SLAPI_ADD_ENTRY:
		PBLOCK_ASSERT_OP( pb, 0 );
983
		if ( pb->pb_op->o_tag == LDAP_REQ_ADD )
984
			pb->pb_op->ora_e = (Slapi_Entry *)value;
985
		else
986
987
988
989
			rc = PBLOCK_ERROR;
		break;
	case SLAPI_MODIFY_MODS: {
		Modifications **mlp;
990
		Modifications *newmods;
991
992
993
994

		PBLOCK_ASSERT_OP( pb, 0 );
		rc = pblock_set_default( pb, param, value );
		if ( rc != PBLOCK_SUCCESS ) {
995
996
			break;
		}
997

998
999
1000
		if ( pb->pb_op->o_tag == LDAP_REQ_MODIFY ) {
			mlp = &pb->pb_op->orm_modlist;
		} else if ( pb->pb_op->o_tag == LDAP_REQ_ADD ) {
For faster browsing, not all history is shown. View entire blame