3 * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1995 Regents of the University of Michigan.
10 * Redistribution and use in source and binary forms are permitted
11 * provided that this notice is preserved and that due credit is given
12 * to the University of Michigan at Ann Arbor. The name of the University
13 * may not be used to endorse or promote products derived from this
14 * software without specific prior written permission. This software
15 * is provided ``as is'' without express or implied warranty.
22 #include <ac/socket.h>
23 #include <ac/string.h>
39 struct berval dn = { 0, NULL };
43 Modifications *modlist = NULL;
44 Modifications **modtail = &modlist;
49 LDAPMod **modv = NULL;
50 Slapi_PBlock *pb = op->o_pb;
55 LDAP_LOG( OPERATION, ENTRY, "do_modify: enter\n", 0, 0, 0 );
57 Debug( LDAP_DEBUG_TRACE, "do_modify\n", 0, 0, 0 );
61 * Parse the modify request. It looks like this:
63 * ModifyRequest := [APPLICATION 6] SEQUENCE {
64 * name DistinguishedName,
65 * mods SEQUENCE OF SEQUENCE {
66 * operation ENUMERATED {
71 * modification SEQUENCE {
73 * values SET OF AttributeValue
79 if ( ber_scanf( op->o_ber, "{m" /*}*/, &dn ) == LBER_ERROR ) {
81 LDAP_LOG( OPERATION, ERR, "do_modify: ber_scanf failed\n", 0, 0, 0 );
83 Debug( LDAP_DEBUG_ANY, "do_modify: ber_scanf failed\n", 0, 0, 0 );
86 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding error" );
87 return SLAPD_DISCONNECT;
91 LDAP_LOG( OPERATION, ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
93 Debug( LDAP_DEBUG_ARGS, "do_modify: dn (%s)\n", dn.bv_val, 0, 0 );
97 /* collect modifications & save for later */
99 for ( tag = ber_first_element( op->o_ber, &len, &last );
101 tag = ber_next_element( op->o_ber, &len, last ) )
104 Modifications tmp, *mod;
106 tmp.sml_nvalues = NULL;
108 if ( ber_scanf( op->o_ber, "{i{m[W]}}", &mop,
109 &tmp.sml_type, &tmp.sml_values )
112 send_ldap_discon( op, rs, LDAP_PROTOCOL_ERROR, "decoding modlist error" );
113 rs->sr_err = SLAPD_DISCONNECT;
117 mod = (Modifications *) ch_malloc( sizeof(Modifications) );
119 mod->sml_type = tmp.sml_type;
120 mod->sml_values = tmp.sml_values;
121 mod->sml_nvalues = NULL;
122 mod->sml_desc = NULL;
123 mod->sml_next = NULL;
128 if ( mod->sml_values == NULL ) {
130 LDAP_LOG( OPERATION, ERR,
131 "do_modify: modify/add operation (%ld) requires values\n",
134 Debug( LDAP_DEBUG_ANY,
135 "do_modify: modify/add operation (%ld) requires values\n",
139 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
140 "modify/add operation requires values" );
146 case LDAP_MOD_DELETE:
147 case LDAP_MOD_REPLACE:
152 LDAP_LOG( OPERATION, ERR,
153 "do_modify: invalid modify operation (%ld)\n",
156 Debug( LDAP_DEBUG_ANY,
157 "do_modify: invalid modify operation (%ld)\n",
161 send_ldap_error( op, rs, LDAP_PROTOCOL_ERROR,
162 "unrecognized modify operation" );
167 modtail = &mod->sml_next;
171 if( get_ctrls( op, rs, 1 ) != LDAP_SUCCESS ) {
173 LDAP_LOG( OPERATION, ERR, "do_modify: get_ctrls failed\n", 0, 0, 0 );
175 Debug( LDAP_DEBUG_ANY, "do_modify: get_ctrls failed\n", 0, 0, 0 );
181 rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn,
183 if( rs->sr_err != LDAP_SUCCESS ) {
185 LDAP_LOG( OPERATION, INFO, "do_modify: conn %d invalid dn (%s)\n",
186 op->o_connid, dn.bv_val, 0 );
188 Debug( LDAP_DEBUG_ANY,
189 "do_modify: invalid dn (%s)\n", dn.bv_val, 0, 0 );
191 send_ldap_error( op, rs, LDAP_INVALID_DN_SYNTAX, "invalid DN" );
195 if( op->o_req_ndn.bv_len == 0 ) {
197 LDAP_LOG( OPERATION, ERR,
198 "do_modify: attempt to modify root DSE.\n",0, 0, 0 );
200 Debug( LDAP_DEBUG_ANY, "do_modify: root dse!\n", 0, 0, 0 );
203 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
204 "modify upon the root DSE not supported" );
207 } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
209 LDAP_LOG( OPERATION, ERR,
210 "do_modify: attempt to modify subschema subentry.\n" , 0, 0, 0 );
212 Debug( LDAP_DEBUG_ANY, "do_modify: subschema subentry!\n", 0, 0, 0 );
215 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
216 "modification of subschema subentry not supported" );
222 LDAP_LOG( OPERATION, DETAIL1, "do_modify: modifications:\n", 0, 0, 0 );
224 Debug( LDAP_DEBUG_ARGS, "modifications:\n", 0, 0, 0 );
227 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
229 LDAP_LOG( OPERATION, DETAIL1, "\t%s: %s\n",
230 tmp->sml_op == LDAP_MOD_ADD ?
231 "add" : (tmp->sml_op == LDAP_MOD_DELETE ?
232 "delete" : "replace"), tmp->sml_type.bv_val, 0 );
234 if ( tmp->sml_values == NULL ) {
235 LDAP_LOG( OPERATION, DETAIL1, "\t\tno values", 0, 0, 0 );
236 } else if ( tmp->sml_values[0].bv_val == NULL ) {
237 LDAP_LOG( OPERATION, DETAIL1, "\t\tzero values", 0, 0, 0 );
238 } else if ( tmp->sml_values[1].bv_val == NULL ) {
239 LDAP_LOG( OPERATION, DETAIL1, "\t\tone value", 0, 0, 0 );
241 LDAP_LOG( OPERATION, DETAIL1, "\t\tmultiple values", 0, 0, 0 );
245 Debug( LDAP_DEBUG_ARGS, "\t%s: %s\n",
246 tmp->sml_op == LDAP_MOD_ADD
247 ? "add" : (tmp->sml_op == LDAP_MOD_DELETE
248 ? "delete" : "replace"), tmp->sml_type.bv_val, 0 );
250 if ( tmp->sml_values == NULL ) {
251 Debug( LDAP_DEBUG_ARGS, "%s\n",
252 "\t\tno values", NULL, NULL );
253 } else if ( tmp->sml_values[0].bv_val == NULL ) {
254 Debug( LDAP_DEBUG_ARGS, "%s\n",
255 "\t\tzero values", NULL, NULL );
256 } else if ( tmp->sml_values[1].bv_val == NULL ) {
257 Debug( LDAP_DEBUG_ARGS, "%s, length %ld\n",
258 "\t\tone value", (long) tmp->sml_values[0].bv_len, NULL );
260 Debug( LDAP_DEBUG_ARGS, "%s\n",
261 "\t\tmultiple values", NULL, NULL );
266 if ( StatslogTest( LDAP_DEBUG_STATS ) ) {
267 char abuf[BUFSIZ/2], *ptr = abuf;
270 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD dn=\"%s\"\n",
271 op->o_connid, op->o_opid, dn.bv_val, 0, 0 );
273 for ( tmp = modlist; tmp != NULL; tmp = tmp->sml_next ) {
274 if (len + 1 + tmp->sml_type.bv_len > sizeof(abuf)) {
275 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
276 op->o_connid, op->o_opid, abuf, 0, 0 );
284 ptr = lutil_strcopy(ptr, tmp->sml_type.bv_val);
285 len += tmp->sml_type.bv_len;
288 Statslog( LDAP_DEBUG_STATS, "conn=%lu op=%lu MOD attr=%s\n",
289 op->o_connid, op->o_opid, abuf, 0, 0 );
292 #endif /* LDAP_DEBUG */
294 manageDSAit = get_manageDSAit( op );
297 * We could be serving multiple database backends. Select the
298 * appropriate one, or send a referral to our "referral server"
299 * if we don't hold it.
301 op->o_bd = select_backend( &op->o_req_ndn, manageDSAit, 0 );
302 if ( op->o_bd == NULL ) {
303 rs->sr_ref = referral_rewrite( default_referral,
304 NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT );
305 if (!rs->sr_ref) rs->sr_ref = default_referral;
307 if (rs->sr_ref != NULL ) {
308 rs->sr_err = LDAP_REFERRAL;
309 send_ldap_result( op, rs );
311 if (rs->sr_ref != default_referral) ber_bvarray_free( rs->sr_ref );
313 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
314 "referral missing" );
319 /* check restrictions */
320 if( backend_check_restrictions( op, rs, NULL ) != LDAP_SUCCESS ) {
321 send_ldap_result( op, rs );
325 /* check for referrals */
326 if( backend_check_referrals( op, rs ) != LDAP_SUCCESS ) {
330 #if defined( LDAP_SLAPI )
331 slapi_x_pblock_set_operation( pb, op );
332 slapi_pblock_set( pb, SLAPI_MODIFY_TARGET, (void *)dn.bv_val );
333 slapi_pblock_set( pb, SLAPI_MANAGEDSAIT, (void *)manageDSAit );
334 modv = slapi_x_modifications2ldapmods( &modlist );
335 slapi_pblock_set( pb, SLAPI_MODIFY_MODS, (void *)modv );
337 rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_MODIFY_FN, pb );
338 if ( rs->sr_err < 0 ) {
340 * A preoperation plugin failure will abort the
344 LDAP_LOG( OPERATION, INFO, "do_modify: modify preoperation plugin "
345 "failed\n", 0, 0, 0 );
347 Debug(LDAP_DEBUG_TRACE, "do_modify: modify preoperation plugin failed.\n",
350 if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 ) ||
351 rs->sr_err == LDAP_SUCCESS ) {
352 rs->sr_err = LDAP_OTHER;
354 slapi_x_free_ldapmods( modv );
360 * It's possible that the preoperation plugin changed the
361 * modification array, so we need to convert it back to
362 * a Modification list.
364 * Calling slapi_x_modifications2ldapmods() destroyed modlist so
365 * we don't need to free it.
367 slapi_pblock_get( pb, SLAPI_MODIFY_MODS, (void **)&modv );
368 modlist = slapi_x_ldapmods2modifications( modv );
371 * NB: it is valid for the plugin to return no modifications
372 * (for example, a plugin might store some attributes elsewhere
373 * and remove them from the modification list; if only those
374 * attribute types were included in the modification request,
375 * then slapi_x_ldapmods2modifications() above will return
378 if ( modlist == NULL ) {
379 rs->sr_err = LDAP_SUCCESS;
380 send_ldap_result( op, rs );
383 #endif /* defined( LDAP_SLAPI ) */
386 * do the modify if 1 && (2 || 3)
387 * 1) there is a modify function implemented in this backend;
388 * 2) this backend is master for what it holds;
389 * 3) it's a replica and the dn supplied is the update_ndn.
391 if ( op->o_bd->be_modify ) {
392 /* do the update here */
393 int repl_user = be_isupdate( op->o_bd, &op->o_ndn );
395 /* Multimaster slapd does not have to check for replicator dn
396 * because it accepts each modify request
398 #if defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
399 if ( !op->o_bd->syncinfo &&
400 ( !op->o_bd->be_update_ndn.bv_len || repl_user ))
401 #elif defined(LDAP_SYNCREPL) && defined(SLAPD_MULTIMASTER)
402 if ( !op->o_bd->syncinfo ) /* LDAP_SYNCREPL overrides MM */
403 #elif !defined(LDAP_SYNCREPL) && !defined(SLAPD_MULTIMASTER)
404 if ( !op->o_bd->be_update_ndn.bv_len || repl_user )
407 int update = op->o_bd->be_update_ndn.bv_len;
408 char textbuf[SLAP_TEXT_BUFLEN];
409 size_t textlen = sizeof textbuf;
411 rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
412 textbuf, textlen, NULL );
414 if( rs->sr_err != LDAP_SUCCESS ) {
415 send_ldap_result( op, rs );
420 for( modtail = &modlist;
422 modtail = &(*modtail)->sml_next )
427 rs->sr_err = slap_mods_opattrs( op, modlist, modtail,
428 &rs->sr_text, textbuf, textlen );
429 if( rs->sr_err != LDAP_SUCCESS ) {
430 send_ldap_result( op, rs );
435 op->orm_modlist = modlist;
436 if ( (op->o_bd->be_modify)( op, rs ) == 0
437 #ifdef SLAPD_MULTIMASTER
441 /* but we log only the ones not from a replicator user */
445 #if defined(LDAP_SYNCREPL) || !defined(SLAPD_MULTIMASTER)
446 /* send a referral */
448 BerVarray defref = NULL;
450 if ( op->o_bd->syncinfo ) {
451 defref = op->o_bd->syncinfo->masteruri;
455 defref = op->o_bd->be_update_refs
456 ? op->o_bd->be_update_refs : default_referral;
458 if ( defref != NULL ) {
459 rs->sr_ref = referral_rewrite( defref,
461 LDAP_SCOPE_DEFAULT );
462 if (!rs->sr_ref) rs->sr_ref = defref;
463 rs->sr_err = LDAP_REFERRAL;
464 send_ldap_result( op, rs );
465 if (rs->sr_ref != defref) {
466 ber_bvarray_free( rs->sr_ref );
469 send_ldap_error( op, rs,
470 LDAP_UNWILLING_TO_PERFORM,
471 "referral missing" );
476 send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
477 "operation not supported within namingContext" );
480 #if defined( LDAP_SLAPI )
481 if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_MODIFY_FN, pb ) < 0 ) {
483 LDAP_LOG( OPERATION, INFO, "do_modify: modify postoperation plugins "
484 "failed\n", 0, 0, 0 );
486 Debug(LDAP_DEBUG_TRACE, "do_modify: modify postoperation plugins "
487 "failed.\n", 0, 0, 0);
490 #endif /* defined( LDAP_SLAPI ) */
493 op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
494 op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
495 if ( modlist != NULL ) slap_mods_free( modlist );
496 #if defined( LDAP_SLAPI )
497 if ( modv != NULL ) slapi_x_free_ldapmods( modv );
503 * Do basic attribute type checking and syntax validation.
515 for( ; ml != NULL; ml = ml->sml_next ) {
516 AttributeDescription *ad = NULL;
518 /* convert to attribute description */
519 rc = slap_bv2ad( &ml->sml_type, &ml->sml_desc, text );
521 if( rc != LDAP_SUCCESS ) {
522 snprintf( textbuf, textlen, "%s: %s",
523 ml->sml_type.bv_val, *text );
530 if( slap_syntax_is_binary( ad->ad_type->sat_syntax )
531 && !slap_ad_is_binary( ad ))
533 /* attribute requires binary transfer */
534 snprintf( textbuf, textlen,
535 "%s: requires ;binary transfer",
536 ml->sml_type.bv_val );
538 return LDAP_UNDEFINED_TYPE;
541 if( !slap_syntax_is_binary( ad->ad_type->sat_syntax )
542 && slap_ad_is_binary( ad ))
544 /* attribute requires binary transfer */
545 snprintf( textbuf, textlen,
546 "%s: disallows ;binary transfer",
547 ml->sml_type.bv_val );
549 return LDAP_UNDEFINED_TYPE;
552 if( slap_ad_is_tag_range( ad )) {
553 /* attribute requires binary transfer */
554 snprintf( textbuf, textlen,
555 "%s: inappropriate use of tag range option",
556 ml->sml_type.bv_val );
558 return LDAP_UNDEFINED_TYPE;
561 if (!update && is_at_no_user_mod( ad->ad_type )) {
562 /* user modification disallowed */
563 snprintf( textbuf, textlen,
564 "%s: no user modification allowed",
565 ml->sml_type.bv_val );
567 return LDAP_CONSTRAINT_VIOLATION;
570 if ( is_at_obsolete( ad->ad_type ) &&
571 ( ml->sml_op == LDAP_MOD_ADD || ml->sml_values != NULL ) )
574 * attribute is obsolete,
575 * only allow replace/delete with no values
577 snprintf( textbuf, textlen,
578 "%s: attribute is obsolete",
579 ml->sml_type.bv_val );
581 return LDAP_CONSTRAINT_VIOLATION;
587 if( ml->sml_values != NULL ) {
589 slap_syntax_validate_func *validate =
590 ad->ad_type->sat_syntax->ssyn_validate;
591 slap_syntax_transform_func *pretty =
592 ad->ad_type->sat_syntax->ssyn_pretty;
594 if( !pretty && !validate ) {
595 *text = "no validator for syntax";
596 snprintf( textbuf, textlen,
597 "%s: no validator for syntax %s",
599 ad->ad_type->sat_syntax->ssyn_oid );
601 return LDAP_INVALID_SYNTAX;
605 * check that each value is valid per syntax
606 * and pretty if appropriate
608 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
611 rc = pretty( ad->ad_type->sat_syntax,
612 &ml->sml_values[nvals], &pval, ctx );
614 rc = validate( ad->ad_type->sat_syntax,
615 &ml->sml_values[nvals] );
619 snprintf( textbuf, textlen,
620 "%s: value #%ld invalid per syntax",
621 ml->sml_type.bv_val, (long) nvals );
623 return LDAP_INVALID_SYNTAX;
627 ber_memfree_x( ml->sml_values[nvals].bv_val, ctx );
628 ml->sml_values[nvals] = pval;
633 * a rough single value check... an additional check is needed
634 * to catch add of single value to existing single valued attribute
636 if ((ml->sml_op == LDAP_MOD_ADD || ml->sml_op == LDAP_MOD_REPLACE)
637 && nvals > 1 && is_at_single_value( ad->ad_type ))
639 snprintf( textbuf, textlen,
640 "%s: multiple values provided",
641 ml->sml_type.bv_val );
643 return LDAP_CONSTRAINT_VIOLATION;
646 if( nvals && ad->ad_type->sat_equality &&
647 ad->ad_type->sat_equality->smr_normalize )
649 ml->sml_nvalues = ber_memalloc_x(
650 (nvals+1)*sizeof(struct berval), ctx );
652 for( nvals = 0; ml->sml_values[nvals].bv_val; nvals++ ) {
653 rc = ad->ad_type->sat_equality->smr_normalize(
655 ad->ad_type->sat_syntax,
656 ad->ad_type->sat_equality,
657 &ml->sml_values[nvals], &ml->sml_nvalues[nvals], ctx );
660 LDAP_LOG( OPERATION, DETAIL1,
661 "str2entry: NULL (ssyn_normalize %d)\n",
664 Debug( LDAP_DEBUG_ANY,
665 "<= str2entry NULL (ssyn_normalize %d)\n",
668 snprintf( textbuf, textlen,
669 "%s: value #%ld normalization failed",
670 ml->sml_type.bv_val, (long) nvals );
676 ml->sml_nvalues[nvals].bv_val = NULL;
677 ml->sml_nvalues[nvals].bv_len = 0;
687 int slap_mods_opattrs(
690 Modifications **modtail,
692 char *textbuf, size_t textlen )
694 struct berval name, timestamp, csn;
696 char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
697 char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
700 int mop = op->o_tag == LDAP_REQ_ADD
701 ? LDAP_MOD_ADD : LDAP_MOD_REPLACE;
703 assert( modtail != NULL );
704 assert( *modtail == NULL );
706 if( SLAP_LASTMOD(op->o_bd) ) {
708 time_t now = slap_get_time();
710 ldap_pvt_thread_mutex_lock( &gmtime_mutex );
711 ltm = gmtime( &now );
712 lutil_gentime( timebuf, sizeof(timebuf), ltm );
714 csn.bv_len = lutil_csnstr( csnbuf, sizeof( csnbuf ), 0, 0 );
715 ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
718 timestamp.bv_val = timebuf;
719 timestamp.bv_len = strlen(timebuf);
721 if( op->o_dn.bv_len == 0 ) {
722 name.bv_val = SLAPD_ANONYMOUS;
723 name.bv_len = sizeof(SLAPD_ANONYMOUS)-1;
731 if( op->o_tag == LDAP_REQ_ADD ) {
732 struct berval tmpval;
734 if( global_schemacheck ) {
735 int rc = mods_structural_class( mods, &tmpval,
736 text, textbuf, textlen );
737 if( rc != LDAP_SUCCESS ) {
741 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
743 mod->sml_type.bv_val = NULL;
744 mod->sml_desc = slap_schema.si_ad_structuralObjectClass;
746 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
747 ber_dupbv( &mod->sml_values[0], &tmpval );
748 mod->sml_values[1].bv_len = 0;
749 mod->sml_values[1].bv_val = NULL;
750 assert( mod->sml_values[0].bv_val );
752 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
753 ber_dupbv( &mod->sml_nvalues[0], &tmpval );
754 mod->sml_nvalues[1].bv_len = 0;
755 mod->sml_nvalues[1].bv_val = NULL;
756 assert( mod->sml_nvalues[0].bv_val );
758 modtail = &mod->sml_next;
761 if( SLAP_LASTMOD(op->o_bd) ) {
762 char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
764 tmpval.bv_len = lutil_uuidstr( uuidbuf, sizeof( uuidbuf ) );
765 tmpval.bv_val = uuidbuf;
767 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
769 mod->sml_type.bv_val = NULL;
770 mod->sml_desc = slap_schema.si_ad_entryUUID;
772 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
773 ber_dupbv( &mod->sml_values[0], &tmpval );
774 mod->sml_values[1].bv_len = 0;
775 mod->sml_values[1].bv_val = NULL;
776 assert( mod->sml_values[0].bv_val );
777 mod->sml_nvalues = NULL;
779 modtail = &mod->sml_next;
781 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
783 mod->sml_type.bv_val = NULL;
784 mod->sml_desc = slap_schema.si_ad_creatorsName;
785 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
786 ber_dupbv( &mod->sml_values[0], &name );
787 mod->sml_values[1].bv_len = 0;
788 mod->sml_values[1].bv_val = NULL;
789 assert( mod->sml_values[0].bv_val );
791 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
792 ber_dupbv( &mod->sml_nvalues[0], &nname );
793 mod->sml_nvalues[1].bv_len = 0;
794 mod->sml_nvalues[1].bv_val = NULL;
795 assert( mod->sml_nvalues[0].bv_val );
797 modtail = &mod->sml_next;
799 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
801 mod->sml_type.bv_val = NULL;
802 mod->sml_desc = slap_schema.si_ad_createTimestamp;
803 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
804 ber_dupbv( &mod->sml_values[0], ×tamp );
805 mod->sml_values[1].bv_len = 0;
806 mod->sml_values[1].bv_val = NULL;
807 assert( mod->sml_values[0].bv_val );
808 mod->sml_nvalues = NULL;
810 modtail = &mod->sml_next;
814 if( SLAP_LASTMOD(op->o_bd) ) {
815 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
817 mod->sml_type.bv_val = NULL;
818 mod->sml_desc = slap_schema.si_ad_entryCSN;
819 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
820 ber_dupbv( &mod->sml_values[0], &csn );
821 mod->sml_values[1].bv_len = 0;
822 mod->sml_values[1].bv_val = NULL;
823 assert( mod->sml_values[0].bv_val );
824 mod->sml_nvalues = NULL;
826 modtail = &mod->sml_next;
828 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
830 mod->sml_type.bv_val = NULL;
831 mod->sml_desc = slap_schema.si_ad_modifiersName;
832 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
833 ber_dupbv( &mod->sml_values[0], &name );
834 mod->sml_values[1].bv_len = 0;
835 mod->sml_values[1].bv_val = NULL;
836 assert( mod->sml_values[0].bv_val );
838 (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
839 ber_dupbv( &mod->sml_nvalues[0], &nname );
840 mod->sml_nvalues[1].bv_len = 0;
841 mod->sml_nvalues[1].bv_val = NULL;
842 assert( mod->sml_nvalues[0].bv_val );
844 modtail = &mod->sml_next;
846 mod = (Modifications *) ch_malloc( sizeof( Modifications ) );
848 mod->sml_type.bv_val = NULL;
849 mod->sml_desc = slap_schema.si_ad_modifyTimestamp;
850 mod->sml_values = (BerVarray) ch_malloc( 2 * sizeof( struct berval ) );
851 ber_dupbv( &mod->sml_values[0], ×tamp );
852 mod->sml_values[1].bv_len = 0;
853 mod->sml_values[1].bv_val = NULL;
854 assert( mod->sml_values[0].bv_val );
855 mod->sml_nvalues = NULL;
857 modtail = &mod->sml_next;